client: Ensure keyboard focus is not lost when main window leaflets fold

See GNOME/libhandy#179
This commit is contained in:
Michael Gratton 2021-04-14 09:17:30 +10:00 committed by Michael James Gratton
parent 2222c6af87
commit 1667a7b2da
2 changed files with 29 additions and 4 deletions

View file

@ -2113,10 +2113,33 @@ public class Application.MainWindow :
update_conversation_actions( update_conversation_actions(
ConversationCount.for_size(selected) ConversationCount.for_size(selected)
); );
if (this.has_composer && if (this.outer_leaflet.folded) {
this.outer_leaflet.folded && // Ensure something useful gets the keyboard focus, given
(this.is_folder_list_shown || this.is_conversation_list_shown)) { // GNOME/libhandy#179
close_composer(false, false); 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();
}
} }
} }

View file

@ -30,6 +30,8 @@
<property name="hexpand_set">True</property> <property name="hexpand_set">True</property>
<property name="can_swipe_back">True</property> <property name="can_swipe_back">True</property>
<property name="transition_type">over</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> <child>
<object class="GtkBox" id="folder_box"> <object class="GtkBox" id="folder_box">
<property name="visible">True</property> <property name="visible">True</property>