From 1667a7b2da079d43b48f57b7cf1812ad9ea97cbe Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Wed, 14 Apr 2021 09:17:30 +1000 Subject: [PATCH] client: Ensure keyboard focus is not lost when main window leaflets fold See GNOME/libhandy#179 --- .../application/application-main-window.vala | 31 ++++++++++++++++--- ui/application-main-window.ui | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/client/application/application-main-window.vala b/src/client/application/application-main-window.vala index 53a48cf0..ff87acd5 100644 --- a/src/client/application/application-main-window.vala +++ b/src/client/application/application-main-window.vala @@ -2113,10 +2113,33 @@ public class Application.MainWindow : update_conversation_actions( ConversationCount.for_size(selected) ); - if (this.has_composer && - this.outer_leaflet.folded && - (this.is_folder_list_shown || this.is_conversation_list_shown)) { - close_composer(false, false); + if (this.outer_leaflet.folded) { + // Ensure something useful gets the keyboard focus, given + // GNOME/libhandy#179 + if (this.is_conversation_list_shown) { + this.conversation_list_view.grab_focus(); + } else if (this.is_folder_list_shown) { + this.folder_list.grab_focus(); + } + + // Close any open composer that is no longer visible + if (this.has_composer && + (this.is_folder_list_shown || this.is_conversation_list_shown)) { + close_composer(false, false); + } + } + } + + [GtkCallback] + private void on_inner_leaflet_changed() { + if (this.inner_leaflet.folded) { + // Ensure something useful gets the keyboard focus, given + // GNOME/libhandy#179 + if (this.is_conversation_list_shown) { + this.conversation_list_view.grab_focus(); + } else if (this.is_folder_list_shown) { + this.folder_list.grab_focus(); + } } } diff --git a/ui/application-main-window.ui b/ui/application-main-window.ui index 289c6013..374c14c2 100644 --- a/ui/application-main-window.ui +++ b/ui/application-main-window.ui @@ -30,6 +30,8 @@ True True over + + True