mirror of
https://github.com/X11Libre/xf86-input-synaptics.git
synced 2026-03-24 01:34:04 +00:00
syndaemon: enable touchpad when pressing a modifier combo
When ignoring modifiers, ensure the touchpad is enabled once a modifier key is pressed disregarding any previous key press that caused the touchpad to be disabled. Signed-off-by: Anton Lindqvist <anton.lindqvist@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Peter Hutterer
parent
248c5936a0
commit
cd9f979923
@@ -47,6 +47,12 @@
|
||||
|
||||
#include "synaptics-properties.h"
|
||||
|
||||
enum KeyboardActivity {
|
||||
ActivityNew,
|
||||
ActivityNone,
|
||||
ActivityReset
|
||||
};
|
||||
|
||||
enum TouchpadState {
|
||||
TouchpadOn = 0,
|
||||
TouchpadOff = 1,
|
||||
@@ -181,29 +187,29 @@ install_signal_handler(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return non-zero if the keyboard state has changed since the last call.
|
||||
*/
|
||||
static int
|
||||
static enum KeyboardActivity
|
||||
keyboard_activity(Display * display)
|
||||
{
|
||||
static unsigned char old_key_state[KEYMAP_SIZE];
|
||||
unsigned char key_state[KEYMAP_SIZE];
|
||||
int i;
|
||||
int ret = 0;
|
||||
int ret = ActivityNone;
|
||||
|
||||
XQueryKeymap(display, (char *) key_state);
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++) {
|
||||
if ((key_state[i] & ~old_key_state[i]) & keyboard_mask[i]) {
|
||||
ret = 1;
|
||||
ret = ActivityNew;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ignore_modifier_combos) {
|
||||
for (i = 0; i < KEYMAP_SIZE; i++) {
|
||||
if (key_state[i] & ~keyboard_mask[i]) {
|
||||
ret = 0;
|
||||
if (old_key_state[i] & ~keyboard_mask[i])
|
||||
ret = ActivityNone;
|
||||
else
|
||||
ret = ActivityReset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -232,8 +238,17 @@ main_loop(Display * display, double idle_time, int poll_delay)
|
||||
|
||||
for (;;) {
|
||||
current_time = get_time();
|
||||
if (keyboard_activity(display))
|
||||
last_activity = current_time;
|
||||
switch (keyboard_activity(display)) {
|
||||
case ActivityNew:
|
||||
last_activity = current_time;
|
||||
break;
|
||||
case ActivityNone:
|
||||
/* NOP */;
|
||||
break;
|
||||
case ActivityReset:
|
||||
last_activity = 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* If system times goes backwards, touchpad can get locked. Make
|
||||
* sure our last activity wasn't in the future and reset if it was. */
|
||||
@@ -423,6 +438,7 @@ record_main_loop(Display * display, double idle_time)
|
||||
fd_set read_fds;
|
||||
int ret;
|
||||
int disable_event = 0;
|
||||
int modifier_event = 0;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&read_fds);
|
||||
@@ -454,9 +470,14 @@ record_main_loop(Display * display, double idle_time)
|
||||
disable_event = 1;
|
||||
}
|
||||
|
||||
if (cbres.non_modifier_event &&
|
||||
!(ignore_modifier_combos && is_modifier_pressed(&cbres))) {
|
||||
disable_event = 1;
|
||||
if (cbres.non_modifier_event) {
|
||||
if (ignore_modifier_combos && is_modifier_pressed(&cbres)) {
|
||||
modifier_event = 1;
|
||||
} else {
|
||||
disable_event = 1;
|
||||
}
|
||||
} else if (ignore_modifier_keys) {
|
||||
modifier_event = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,10 +489,13 @@ record_main_loop(Display * display, double idle_time)
|
||||
toggle_touchpad(False);
|
||||
}
|
||||
|
||||
if (ret == 0 && pad_disabled) { /* timeout => enable event */
|
||||
if (modifier_event && pad_disabled) {
|
||||
toggle_touchpad(True);
|
||||
}
|
||||
|
||||
if (ret == 0 && pad_disabled) { /* timeout => enable event */
|
||||
toggle_touchpad(True);
|
||||
}
|
||||
} /* end while(1) */
|
||||
|
||||
XFreeModifiermap(cbres.modifiers);
|
||||
|
||||
Reference in New Issue
Block a user