[geary/mjog/responsive-layout-fixes: 22/23] client: Ensure keyboard focus is not lost when main window leaflets fold
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/responsive-layout-fixes: 22/23] client: Ensure keyboard focus is not lost when main window leaflets fold
- Date: Wed, 14 Apr 2021 09:08:47 +0000 (UTC)
commit 1667a7b2da079d43b48f57b7cf1812ad9ea97cbe
Author: Michael Gratton <mike vee net>
Date: Wed Apr 14 09:17:30 2021 +1000
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 53a48cf0e..ff87acd56 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 289c60131..374c14c26 100644
--- a/ui/application-main-window.ui
+++ b/ui/application-main-window.ui
@@ -30,6 +30,8 @@
<property name="hexpand_set">True</property>
<property name="can_swipe_back">True</property>
<property name="transition_type">over</property>
+ <signal name="notify::folded" handler="on_inner_leaflet_changed" swapped="no"/>
+ <signal name="notify::visible-child" handler="on_inner_leaflet_changed" swapped="no"/>
<child>
<object class="GtkBox" id="folder_box">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]