Skip to content

Commit c7afefa

Browse files
committed
accessibility/cinnamon-hover-click: Keep the active click action
in sync with Clutter. Muffin resets the click mode back to single after performing a non- single-click dwell-click action, but the user control does not update to reflect this. ClutterSeat has a signal to notify about this already, use it to update gsettings, and add a listener to cinnamon-hover-click to sync the button state. Fixes #13360.
1 parent 78b92bd commit c7afefa

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

files/usr/bin/cinnamon-hover-click

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class HoverClickWindow(XApp.GtkWindow):
9999

100100
self.show_all()
101101
self.settings.connect("changed::hoverclick-layout", self.update_layout)
102+
self.settings.connect("changed::hoverclick-action", self.on_action_changed)
102103
self.connect("delete-event", self.exit)
103104
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, self.exit)
104105

@@ -111,6 +112,24 @@ class HoverClickWindow(XApp.GtkWindow):
111112

112113
self.settings.set_string("hoverclick-action", action)
113114

115+
def on_action_changed(self, settings, key):
116+
if self.doing_setup:
117+
return
118+
119+
action = settings.get_string("hoverclick-action")
120+
button_map = {
121+
"single": self.single_click_button,
122+
"double": self.double_click_button,
123+
"drag": self.drag_button,
124+
"secondary": self.right_click_button
125+
}
126+
127+
button = button_map.get(action)
128+
if button and not button.get_active():
129+
self.doing_setup = True
130+
button.set_active(True)
131+
self.doing_setup = False
132+
114133
def on_button_press_event(self, button, event):
115134
had_button, button = event.get_button()
116135

js/ui/accessibility.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const HOVERKEY_ACTIONS = {
2020
"secondary": Clutter.PointerA11yDwellClickType.SECONDARY
2121
}
2222

23+
const HOVERKEY_ACTION_NAMES = Object.fromEntries(
24+
Object.entries(HOVERKEY_ACTIONS).map(([k, v]) => [v, k])
25+
);
26+
2327
function A11yHandler(){
2428
this._init();
2529
}
@@ -41,6 +45,7 @@ A11yHandler.prototype = {
4145
this._events_flash = false;
4246
this._events_sound = false
4347
this._hoverclick_enabled = false;
48+
this._updatingHoverclickAction = false;
4449

4550
/* Options */
4651
this.state_on_sound = null;
@@ -51,6 +56,10 @@ A11yHandler.prototype = {
5156
let seat = Clutter.get_default_backend().get_default_seat();
5257
this.keymap = seat.get_keymap();
5358

59+
seat.connect('ptr-a11y-dwell-click-type-changed', (seat, clickType) => {
60+
this._onDwellClickTypeChanged(clickType);
61+
});
62+
5463
this.caps = this.keymap.get_caps_lock_state();
5564
this.num = this.keymap.get_num_lock_state();
5665

@@ -89,6 +98,10 @@ A11yHandler.prototype = {
8998
},
9099

91100
hoverkey_action_changed: function(settings, key) {
101+
if (this._updatingHoverclickAction) {
102+
return;
103+
}
104+
92105
let action = global.settings.get_string("hoverclick-action");
93106

94107
seat = Clutter.get_default_backend().get_default_seat();
@@ -100,6 +113,15 @@ A11yHandler.prototype = {
100113
}
101114
},
102115

116+
_onDwellClickTypeChanged: function(clickType) {
117+
let actionName = HOVERKEY_ACTION_NAMES[clickType];
118+
if (actionName && global.settings.get_string("hoverclick-action") !== actionName) {
119+
this._updatingHoverclickAction = true;
120+
global.settings.set_string("hoverclick-action", actionName);
121+
this._updatingHoverclickAction = false;
122+
}
123+
},
124+
103125
on_keymap_state_changed: function(keymap) {
104126
let new_caps = this.keymap.get_caps_lock_state();
105127
let new_num = this.keymap.get_num_lock_state();

0 commit comments

Comments
 (0)