From faeec495a4c26c3324071d31427b8e1f50ae8cf8 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 30 Dec 2020 08:38:44 -0800 Subject: [PATCH] mouse: Add "Disable While Typing" toggle for touchpad https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/125 As mentioned there, this is exposed in Gnome Tweaks. It is on by default, but completely break touchpad usage of certain kinds of games and other software requiring simultaneous use of the mouse and keyboard. I like the idea in the issue of automatically detecting games, but I'm not sure how/if it can be done reliably (and it's not an issue only for games). In lieu of that, it seems good to expose the setting here. --- panels/mouse/cc-mouse-panel.c | 14 ++++++++++++++ panels/mouse/cc-mouse-panel.ui | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/panels/mouse/cc-mouse-panel.c b/panels/mouse/cc-mouse-panel.c index 8427a49259..f0f7f2a662 100644 --- a/panels/mouse/cc-mouse-panel.c +++ b/panels/mouse/cc-mouse-panel.c @@ -35,6 +35,8 @@ struct _CcMousePanel { CcPanel parent_instance; + GtkSwitch *disable_while_typing_row; + GtkSwitch *disable_while_typing_switch; GtkListBoxRow *edge_scrolling_row; GtkSwitch *edge_scrolling_switch; AdwPreferencesGroup *mouse_group; @@ -280,6 +282,12 @@ setup_dialog (CcMousePanel *self) touchpad_enabled_get_mapping, touchpad_enabled_set_mapping, NULL, NULL); + g_settings_bind_with_mapping (self->touchpad_settings, "send-events", + self->disable_while_typing_row, "sensitive", + G_SETTINGS_BIND_GET, + touchpad_enabled_get_mapping, + touchpad_enabled_set_mapping, + NULL, NULL); g_settings_bind (self->touchpad_settings, "natural-scroll", self->touchpad_natural_scrolling_switch, "active", @@ -301,6 +309,10 @@ setup_dialog (CcMousePanel *self) self->edge_scrolling_switch, "state", G_SETTINGS_BIND_GET); + g_settings_bind (self->touchpad_settings, "disable-while-typing", + self->disable_while_typing_switch, "active", + G_SETTINGS_BIND_DEFAULT); + setup_touchpad_options (self); } @@ -385,6 +397,8 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/mouse/cc-mouse-panel.ui"); + gtk_widget_class_bind_template_child (widget_class, CcMousePanel, disable_while_typing_row); + gtk_widget_class_bind_template_child (widget_class, CcMousePanel, disable_while_typing_switch); gtk_widget_class_bind_template_child (widget_class, CcMousePanel, edge_scrolling_row); gtk_widget_class_bind_template_child (widget_class, CcMousePanel, edge_scrolling_switch); gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_group); diff --git a/panels/mouse/cc-mouse-panel.ui b/panels/mouse/cc-mouse-panel.ui index abdb4a4339..07252c295b 100644 --- a/panels/mouse/cc-mouse-panel.ui +++ b/panels/mouse/cc-mouse-panel.ui @@ -209,6 +209,21 @@ + + + Disable While Typing + disable_while_typing_switch + + + center + + Disable While Typing + + + + + + -- GitLab