From f9cf70cc0ecc04daa78d90a8bdc648c0dbcc3c74 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Wed, 30 Oct 2019 14:27:52 +1100 Subject: [PATCH] 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 @@ False +