[geary/mjog/account-command-stacks: 65/77] Fix MainWindow shift button detection



commit 9170fa64f5117933bdf5fe2f2b9b6db43cb5f761
Author: Michael Gratton <mike vee net>
Date:   Wed Oct 30 14:27:52 2019 +1100

    Fix MainWindow shift button detection
    
    Ensure shift button is assumed to be up on both focus in and focus out,
    so when e.g. invoking the inspector the button is assumed to be
    released. Remove the signal in preference for using notifiy when needed,
    and ensure main toolbar state is updated on focus changes as well.

 src/client/components/main-window.vala | 19 +++++++++----------
 ui/main-window.ui                      |  1 +
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index bdf43fbf..6f510205 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -258,9 +258,6 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
     /** Fired when the user requests an account status be retried. */
     public signal void retry_service_problem(Geary.ClientService.Status problem);
 
-    /** Fired when the shift key is pressed or released. */
-    public signal void on_shift_key(bool pressed);
-
 
     public MainWindow(GearyApplication application) {
         Object(
@@ -1247,6 +1244,13 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         }
     }
 
+    private void set_shift_key_down(bool down) {
+        this.is_shift_down = down;
+        this.main_toolbar.update_trash_button(
+            !down && this.selected_folder_supports_trash
+        );
+    }
+
     private inline void check_shift_event(Gdk.EventKey event) {
         // FIXME: it's possible the user will press two shift keys.  We want
         // the shift key to report as released when they release ALL of them.
@@ -1255,12 +1259,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
             Gtk.Widget? focus = get_focus();
             if (focus == null ||
                 (!(focus is Gtk.Entry) && !(focus is ComposerWebView))) {
-                this.is_shift_down = (event.type == Gdk.EventType.KEY_PRESS);
-                this.main_toolbar.update_trash_button(
-                    !this.is_shift_down &&
-                    selected_folder_supports_trash()
-                );
-                on_shift_key(this.is_shift_down);
+                set_shift_key_down(event.type == Gdk.EventType.KEY_PRESS);
             }
         }
     }
@@ -1308,7 +1307,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
     [GtkCallback]
     private bool on_focus_event() {
-        on_shift_key(false);
+        this.set_shift_key_down(false);
         return false;
     }
 
diff --git a/ui/main-window.ui b/ui/main-window.ui
index bbd330d7..2729c0fb 100644
--- a/ui/main-window.ui
+++ b/ui/main-window.ui
@@ -9,6 +9,7 @@
     <property name="show_menubar">False</property>
     <signal name="delete-event" handler="on_delete_event" swapped="no"/>
     <signal name="focus-in-event" handler="on_focus_event" swapped="no"/>
+    <signal name="focus-out-event" handler="on_focus_event" swapped="no"/>
     <signal name="map" handler="on_map" swapped="no"/>
     <signal name="unmap" handler="on_unmap" swapped="no"/>
     <child type="titlebar">


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