[buoh] Test for modifier keys correctly



commit 7ffa1a859d050048a572db8783119de0cd2e7cfe
Author: Jan Tojnar <jtojnar gmail com>
Date:   Sat Feb 2 22:36:58 2019 +0100

    Test for modifier keys correctly
    
    https://developer.gnome.org/gtk3/stable/checklist-modifiers.html

 src/buoh-view-comic.c |  8 ++++----
 src/buoh-window.c     | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/buoh-view-comic.c b/src/buoh-view-comic.c
index c995f63..6694878 100644
--- a/src/buoh-view-comic.c
+++ b/src/buoh-view-comic.c
@@ -325,12 +325,12 @@ buoh_view_comic_key_press_event (GtkWidget *widget, GdkEventKey *event)
 static gboolean
 buoh_view_comic_scroll_event (GtkWidget *widget, GdkEventScroll *event)
 {
-        BuohViewComic *c_view = BUOH_VIEW_COMIC (widget);
-        guint          state;
+        BuohViewComic   *c_view = BUOH_VIEW_COMIC (widget);
+        GdkModifierType  modifiers;
 
-        state = event->state & GDK_CONTROL_MASK;
+        modifiers = gtk_accelerator_get_default_mod_mask ();
 
-        if (state == GDK_CONTROL_MASK) {
+        if ((event->state & modifiers) == GDK_CONTROL_MASK) {
                 switch (event->direction) {
                 case GDK_SCROLL_UP:
                 case GDK_SCROLL_LEFT:
diff --git a/src/buoh-window.c b/src/buoh-window.c
index 57e3436..4f56347 100644
--- a/src/buoh-window.c
+++ b/src/buoh-window.c
@@ -962,11 +962,11 @@ buoh_window_comic_list_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpoi
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         GtkTreeSelection *selection;
-        guint             state;
+        GdkModifierType   modifiers;
 
-        state = event->state & GDK_SHIFT_MASK;
+        modifiers = gtk_accelerator_get_default_mod_mask ();
 
-        if (state == GDK_SHIFT_MASK &&
+        if ((event->state & modifiers) == GDK_SHIFT_MASK &&
             event->keyval == GDK_KEY_F10) {
                 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
                 if (gtk_tree_selection_get_selected (selection, NULL, NULL)) {
@@ -1016,8 +1016,8 @@ static gboolean
 buoh_window_comic_view_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer gdata)
 {
         BuohWindow     *window = BUOH_WINDOW (gdata);
-        guint           state;
         BuohViewStatus  view_status;
+        GdkModifierType modifiers;
 
         view_status = buoh_view_get_status (BUOH_VIEW (window->view));
         if (view_status != STATE_COMIC_LOADING &&
@@ -1025,9 +1025,9 @@ buoh_window_comic_view_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpoi
                 return FALSE;
         }
 
-        state = event->state & GDK_SHIFT_MASK;
+        modifiers = gtk_accelerator_get_default_mod_mask ();
 
-        if (state == GDK_SHIFT_MASK &&
+        if ((event->state & modifiers) == GDK_SHIFT_MASK &&
             event->keyval == GDK_KEY_F10) {
                 gtk_menu_popup_at_pointer (GTK_MENU (window->view_popup), (const GdkEvent *) event);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]