summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Osterlund <petero2@telia.com>2005-11-05 22:55:43 +0100
committerPeter Osterlund <petero2@telia.com>2006-04-09 04:03:34 +0200
commit04fdc33b0650968978339deb722e8a910bcabb69 (patch)
treedb495c357d04a7025f829fb5c12968d431e913fb
parentf88fab7622e5b8bf8825df794536a3c4b3ce5cc5 (diff)
Added option to syndaemon to ignore "modifier+another key"
combos. This way you can press for example "alt-f1" to switch desktop without disabling the touchpad. Patch from Mattia Dongili <malattia@linux.it>, but modified by me so that syndaemon only monitors key presses. This way the touchpad is not disabled if you press alt-f1, but release the alt key before the f1 key.
-rw-r--r--manpages/syndaemon.16
-rw-r--r--syndaemon.c31
2 files changed, 27 insertions, 10 deletions
diff --git a/manpages/syndaemon.1 b/manpages/syndaemon.1
index 873f40d..00cba10 100644
--- a/manpages/syndaemon.1
+++ b/manpages/syndaemon.1
@@ -6,7 +6,7 @@ the touchpad when the keyboard is being used.
.SH "SYNTAX"
.LP
syndaemon [\fI\-i idle\-time\fP] [\fI\-d\fP] [\fI\-p pid\-file\fP]
-[\fI\-t\fP] [\fI\-k\fP]
+[\fI\-t\fP] [\fI\-k\fP] [\fI\-K\fP]
.SH "DESCRIPTION"
.LP
Disabling the touchpad while typing avoids unwanted movements of the
@@ -42,6 +42,10 @@ to keyboard activity.
.TP
\fB\-k\fP
Ignore modifier keys when monitoring keyboard activity.
+.LP
+.TP
+\fB\-K\fP
+Like \-k but also ignore Modifier+Key combos.
.SH "ENVIRONMENT VARIABLES"
.LP
.TP
diff --git a/syndaemon.c b/syndaemon.c
index 985ef5d..4730460 100644
--- a/syndaemon.c
+++ b/syndaemon.c
@@ -33,6 +33,7 @@
static SynapticsSHM *synshm;
static int pad_disabled;
static int disable_taps_only;
+static int ignore_modifier_combos;
static int background;
static const char *pid_file;
@@ -49,6 +50,7 @@ usage()
fprintf(stderr, " -p Create a pid file with the specified name.\n");
fprintf(stderr, " -t Only disable tapping and scrolling, not mouse movements.\n");
fprintf(stderr, " -k Ignore modifier keys when monitoring keyboard activity.\n");
+ fprintf(stderr, " -K Like -k but also ignore Modifier+Key combos.\n");
exit(1);
}
@@ -107,20 +109,27 @@ keyboard_activity(Display *display)
static unsigned char old_key_state[KEYMAP_SIZE];
unsigned char key_state[KEYMAP_SIZE];
int i;
+ int ret = 0;
XQueryKeymap(display, (char*)key_state);
- for (i = 0; i < KEYMAP_SIZE; i++)
- key_state[i] &= keyboard_mask[i];
-
for (i = 0; i < KEYMAP_SIZE; i++) {
- if (key_state[i] != old_key_state[i]) {
- for (i = 0; i < KEYMAP_SIZE; i++)
- old_key_state[i] = key_state[i];
- return 1;
+ if ((key_state[i] & ~old_key_state[i]) & keyboard_mask[i]) {
+ ret = 1;
+ break;
}
}
- return 0;
+ if (ignore_modifier_combos) {
+ for (i = 0; i < KEYMAP_SIZE; i++) {
+ if (key_state[i] & ~keyboard_mask[i]) {
+ ret = 0;
+ break;
+ }
+ }
+ }
+ for (i = 0; i < KEYMAP_SIZE; i++)
+ old_key_state[i] = key_state[i];
+ return ret;
}
/**
@@ -225,7 +234,7 @@ main(int argc, char *argv[])
int ignore_modifier_keys = 0;
/* Parse command line parameters */
- while ((c = getopt(argc, argv, "i:dtp:k?")) != EOF) {
+ while ((c = getopt(argc, argv, "i:dtp:kK?")) != EOF) {
switch(c) {
case 'i':
idle_time = atof(optarg);
@@ -242,6 +251,10 @@ main(int argc, char *argv[])
case 'k':
ignore_modifier_keys = 1;
break;
+ case 'K':
+ ignore_modifier_combos = 1;
+ ignore_modifier_keys = 1;
+ break;
default:
usage();
break;