From d8bc49135d57185da38e82bc71d916655f7941e3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 22:47:18 +0100 Subject: Keystroke.c: use Bool type where appropriate --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 6237b9dac..9cb08e892 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -139,7 +139,7 @@ struct nxagentSpecialKeystrokeMap default_map[] = { }; struct nxagentSpecialKeystrokeMap *map = default_map; -static int modifier_matches(unsigned int mask, int compare_alt_meta, unsigned int state) +static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned int state) { /* nxagentAltMetaMask needs special handling * it seems to me its an and-ed mask of all possible meta and alt keys @@ -147,11 +147,11 @@ static int modifier_matches(unsigned int mask, int compare_alt_meta, unsigned in * * otherwise this function would be just a simple bitop */ - int ret = 1; + Bool ret = True; if (compare_alt_meta) { if (! (state & nxagentAltMetaMask)) { - ret = 0; + ret = False; } mask &= ~nxagentAltMetaMask; @@ -159,7 +159,7 @@ static int modifier_matches(unsigned int mask, int compare_alt_meta, unsigned in /* all modifiers except meta/alt have to match exactly, extra bits are evil */ if ((mask & state) != mask) { - ret = 0; + ret = False; } return ret; -- cgit v1.2.3 From 7a61c62cd6aaabe40d788d3da7f1b736107fbddb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 22:48:18 +0100 Subject: Keystroke.c: rework read_binding_from_xmlnode() code cleanup --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 84 +++++++++----------------- 1 file changed, 30 insertions(+), 54 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 9cb08e892..8959768d8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -167,8 +167,12 @@ static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned i static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystrokeMap *ret) { - int successful = 0; - struct nxagentSpecialKeystrokeMap new = {0, 0, 0, 0}; + struct nxagentSpecialKeystrokeMap newkm = { + .stroke = 0, + .modifierMask = 0, + .modifierAltMeta = 0, + .keysym = NoSymbol + }; xmlAttr *attr; for (attr = node->properties; attr; attr = attr->next) @@ -176,20 +180,21 @@ static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystro /* ignore attributes without data (which should never happen anyways) */ if (attr->children->content == NULL) { + #ifdef DEBUG char *aname = (attr->name)?((char *)attr->name):"unknown"; fprintf(stderr, "attribute %s with NULL value", aname); + #endif continue; } if (strcmp((char *)attr->name, "action") == 0) { - int i; - for (i = 0; nxagentSpecialKeystrokeNames[i] != NULL; i++) + for (int i = 0; nxagentSpecialKeystrokeNames[i] != NULL; i++) { if (strcmp(nxagentSpecialKeystrokeNames[i],(char *)attr->children->content) == 0) { /* this relies on the values of enum nxagentSpecialKeystroke and the * indices of nxagentSpecialKeystrokeNames being in sync */ - new.stroke = i; + newkm.stroke = i; break; } } @@ -197,12 +202,9 @@ static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystro } else if (strcmp((char *)attr->name, "key") == 0) { - new.keysym = XStringToKeysym((char *)attr->children->content); - /* NoSymbol is usually 0, but could there be weird implementations? */ - if (new.keysym == NoSymbol) - { - new.keysym = 0; - } + if (strcmp((char *)attr->children->content, "0") != 0 && strcmp((char *)attr->children->content, "false") != 0) + newkm.keysym = XStringToKeysym((char *)attr->children->content); + continue; } @@ -210,47 +212,24 @@ static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystro if (strcmp((char *)attr->children->content, "0") == 0 || strcmp((char *)attr->children->content, "false") == 0) continue; - if (strcmp((char *)attr->name, "Mod1") == 0) - { - new.modifierMask |= Mod1Mask; - } - else if (strcmp((char *)attr->name, "Mod2") == 0) - { - new.modifierMask |= Mod2Mask; - } - else if (strcmp((char *)attr->name, "Mod3") == 0) - { - new.modifierMask |= Mod3Mask; - } - else if (strcmp((char *)attr->name, "Mod4") == 0) - { - new.modifierMask |= Mod4Mask; - } - else if (strcmp((char *)attr->name, "Control") == 0) - { - new.modifierMask |= ControlMask; - } - else if (strcmp((char *)attr->name, "Shift") == 0) - { - new.modifierMask |= ShiftMask; - } - else if (strcmp((char *)attr->name, "Lock") == 0) - { - new.modifierMask |= LockMask; - } - else if (strcmp((char *)attr->name, "AltMeta") == 0) - { - new.modifierAltMeta = 1; - } + if (strcmp((char *)attr->name, "Mod1") == 0) { newkm.modifierMask |= Mod1Mask; } + else if (strcmp((char *)attr->name, "Mod2") == 0) { newkm.modifierMask |= Mod2Mask; } + else if (strcmp((char *)attr->name, "Mod3") == 0) { newkm.modifierMask |= Mod3Mask; } + else if (strcmp((char *)attr->name, "Mod4") == 0) { newkm.modifierMask |= Mod4Mask; } + else if (strcmp((char *)attr->name, "Control") == 0) { newkm.modifierMask |= ControlMask; } + else if (strcmp((char *)attr->name, "Shift") == 0) { newkm.modifierMask |= ShiftMask; } + else if (strcmp((char *)attr->name, "Lock") == 0) { newkm.modifierMask |= LockMask; } + else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = 1; } } - if (new.stroke != 0 && new.keysym != 0) + if (newkm.stroke != 0 && newkm.keysym != NoSymbol) { /* keysym and stroke are required, everything else is optional */ - successful = 1; - memcpy(ret, &new, sizeof(struct nxagentSpecialKeystrokeMap)); + memcpy(ret, &newkm, sizeof(struct nxagentSpecialKeystrokeMap)); + return True; } - return successful; + else + return False; } /* @@ -378,13 +357,10 @@ free(filename); for (bindings = cur->children; bindings; bindings = bindings->next) { - if (bindings->type == XML_ELEMENT_NODE && strcmp((char *)bindings->name, "keystroke") == 0) - { - int res = 0; - res = read_binding_from_xmlnode(bindings, &(map[idx])); - if (res) - idx++; - } + if (bindings->type == XML_ELEMENT_NODE && + strcmp((char *)bindings->name, "keystroke") == 0 && + read_binding_from_xmlnode(bindings, &(map[idx]))) + idx++; } map[idx].stroke = KEYSTROKE_END_MARKER; -- cgit v1.2.3 From dfa8bb27bbab2709f0d29fa825a3ebe5e83bcfdb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 22:53:09 +0100 Subject: Keystroke.c: fix code formatting --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 8959768d8..93bb48cba 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -282,7 +282,7 @@ static void parse_keystroke_file(void) if (homedir == NULL) { fprintf(stderr, "malloc failed"); -exit(EXIT_FAILURE); + exit(EXIT_FAILURE); } filename = calloc(1, strlen(homefile) + strlen(homedir) + 1); if (filename == NULL) @@ -316,7 +316,7 @@ exit(EXIT_FAILURE); else { if (filename) -free(filename); + free(filename); filename = NULL; } } @@ -336,7 +336,7 @@ free(filename); for (cur = root; cur; cur = cur->next) { if (cur->type == XML_ELEMENT_NODE && strcmp((char *)cur->name, "keystrokes") == 0) -{ + { xmlNode *bindings = NULL; int num = 0; int idx = 0; @@ -351,7 +351,7 @@ free(filename); map = calloc((num + 1), sizeof(struct nxagentSpecialKeystrokeMap)); if (map == NULL) { - fprintf(stderr, "malloc failed"); + fprintf(stderr, "calloc failed"); exit(EXIT_FAILURE); } @@ -388,7 +388,6 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) 1, &keysyms_per_keycode_return); - struct nxagentSpecialKeystrokeMap *cur = map; if (! nxagentKeystrokeFileParsed) -- cgit v1.2.3 From 7804c9c697b6aab9a984deb370eda69884eecd64 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 22:55:37 +0100 Subject: Keystroke.c: simplify nxagentCheckSpecialKeystroke --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 93bb48cba..7148cadf0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -414,31 +414,15 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) { enum nxagentSpecialKeystroke stroke = find_keystroke(X); - *result = doNothing; - /* - * I don't know how much hard work is doing this operation. - * Do we need a cache ? - */ - - int keysyms_per_keycode_return; - XlibKeySym *sym = XGetKeyboardMapping(nxagentDisplay, - X->keycode, - 1, - &keysyms_per_keycode_return); - - if (sym[0] == XK_VoidSymbol || sym[0] == NoSymbol) - { - free(sym); + if (stroke == KEYSTROKE_NOTHING) return 0; - } #ifdef TEST - fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - sym %lx\n", - X -> keycode, X -> state, sym[0]); + fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d\n", + X -> keycode, X -> state, stroke); #endif - free(sym); /* * Check special keys. -- cgit v1.2.3 From 06c83be7e3b65a43ce78776f205d3589cb18852b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 22:58:27 +0100 Subject: Keystroke.c: handle parsing state in parse_keystroke_file() --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 7148cadf0..28d6d2467 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -249,6 +249,11 @@ static void parse_keystroke_file(void) char *homefile = "/.nx/config/keystrokes.cfg"; char *etcfile = "/etc/nxagent/keystrokes.cfg"; + if (nxagentKeystrokeFileParsed) + return; + + nxagentKeystrokeFileParsed = True; + if (nxagentX2go) { homefile = "/.x2go/config/keystrokes.cfg"; etcfile = "/etc/x2go/keystrokes.cfg"; @@ -390,11 +395,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) struct nxagentSpecialKeystrokeMap *cur = map; - if (! nxagentKeystrokeFileParsed) - { - parse_keystroke_file(); - nxagentKeystrokeFileParsed = True; - } + parse_keystroke_file(); enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; -- cgit v1.2.3 From ac3794c5fb0e8e4e1c48e19c2672b9b6135936ad Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:08:40 +0100 Subject: Keystroke.c: reorder parse_keystroke_file for better readability --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 28d6d2467..ae3ba7808 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -387,21 +387,19 @@ static void parse_keystroke_file(void) static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) { + enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; int keysyms_per_keycode_return; - XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, - X->keycode, - 1, - &keysyms_per_keycode_return); - struct nxagentSpecialKeystrokeMap *cur = map; parse_keystroke_file(); - enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; + XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, + X->keycode, + 1, + &keysyms_per_keycode_return); while (cur->stroke != KEYSTROKE_END_MARKER) { if (cur->keysym == keysym[0] && modifier_matches(cur->modifierMask, cur->modifierAltMeta, X->state)) { - free(keysym); return cur->stroke; } -- cgit v1.2.3 From c80605a19c0c92d9a0e91bfcc84657527dd8d5ac Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:09:24 +0100 Subject: Keystroke.c: Boolify nxagentCheckSpecialKeystroke --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 14 +++++++------- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index ae3ba7808..8bf9779a5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -410,13 +410,13 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) return ret; } -int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) +Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) { enum nxagentSpecialKeystroke stroke = find_keystroke(X); *result = doNothing; if (stroke == KEYSTROKE_NOTHING) - return 0; + return False; #ifdef TEST fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d\n", @@ -436,7 +436,7 @@ int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) { *result = doStartKbd; - return 1; + return True; } switch (stroke) { @@ -492,7 +492,7 @@ int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) break; case KEYSTROKE_IGNORE: /* this is used e.g. to ignore C-A-Backspace aka XK_Terminate_Server */ - return 1; + return True; break; case KEYSTROKE_FORCE_SYNCHRONIZATION: nxagentForceSynchronization = 1; @@ -517,7 +517,7 @@ int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) nxagentLastInputDevicesDumpTime = 0; } } - return 1; + return True; #endif break; case KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB: @@ -525,7 +525,7 @@ int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) if (X->type == KeyPress) { nxagentDeactivateInputDevicesGrab(); } - return 1; + return True; #endif break; case KEYSTROKE_FULLSCREEN: @@ -562,5 +562,5 @@ int nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) case KEYSTROKE_MAX: break; } - return (*result == doNothing) ? 0 : 1; + return (*result == doNothing); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 45791f9ba..28374e807 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -28,7 +28,7 @@ #include "Events.h" -extern int nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); +extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); unsigned int nxagentAltMetaMask; -- cgit v1.2.3 From f78e673fb0285b4adb89d3afa9a73576a5387266 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:29:11 +0100 Subject: Keystroke.c: Boolify read_binding_from_xmlnode --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 88 +++++++++++++------------- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 2 +- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 8bf9779a5..e61ecd2a5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -95,47 +95,47 @@ char * nxagentSpecialKeystrokeNames[] = { struct nxagentSpecialKeystrokeMap default_map[] = { /* stroke, modifierMask, modifierAltMeta, keysym */ - {KEYSTROKE_DEBUG_TREE, ControlMask, 1, XK_q}, - {KEYSTROKE_DEBUG_TREE, ControlMask, 1, XK_Q}, - {KEYSTROKE_CLOSE_SESSION, ControlMask, 1, XK_t}, - {KEYSTROKE_CLOSE_SESSION, ControlMask, 1, XK_T}, - {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, 1, XK_f}, - {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, 1, XK_F}, - {KEYSTROKE_MINIMIZE, ControlMask, 1, XK_m}, - {KEYSTROKE_MINIMIZE, ControlMask, 1, XK_M}, - {KEYSTROKE_LEFT, ControlMask, 1, XK_Left}, - {KEYSTROKE_LEFT, ControlMask, 1, XK_KP_Left}, - {KEYSTROKE_UP, ControlMask, 1, XK_Up}, - {KEYSTROKE_UP, ControlMask, 1, XK_KP_Up}, - {KEYSTROKE_RIGHT, ControlMask, 1, XK_Right}, - {KEYSTROKE_RIGHT, ControlMask, 1, XK_KP_Right}, - {KEYSTROKE_DOWN, ControlMask, 1, XK_Down}, - {KEYSTROKE_DOWN, ControlMask, 1, XK_KP_Down}, - {KEYSTROKE_RESIZE, ControlMask, 1, XK_r}, - {KEYSTROKE_RESIZE, ControlMask, 1, XK_R}, - {KEYSTROKE_DEFER, ControlMask, 1, XK_e}, - {KEYSTROKE_DEFER, ControlMask, 1, XK_E}, - {KEYSTROKE_IGNORE, ControlMask, 1, XK_BackSpace}, - {KEYSTROKE_IGNORE, 0, 0, XK_Terminate_Server}, - {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, 1, XK_j}, - {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, 1, XK_J}, - {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, 1, XK_a}, - {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, 1, XK_A}, - {KEYSTROKE_TEST_INPUT, ControlMask, 1, XK_x}, - {KEYSTROKE_TEST_INPUT, ControlMask, 1, XK_X}, - {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, 1, XK_y}, - {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, 1, XK_Y}, - {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, 1, XK_f}, - {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, 1, XK_F}, - {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, 1, XK_Left}, - {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, 1, XK_KP_Left}, - {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, 1, XK_Up}, - {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, 1, XK_KP_Up}, - {KEYSTROKE_VIEWPORT_MOVE_RIGHT, ControlMask | ShiftMask, 1, XK_Right}, - {KEYSTROKE_VIEWPORT_MOVE_RIGHT, ControlMask | ShiftMask, 1, XK_KP_Right}, - {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, 1, XK_Down}, - {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, 1, XK_KP_Down}, - {KEYSTROKE_END_MARKER, 0, 0, 0}, + {KEYSTROKE_DEBUG_TREE, ControlMask, True, XK_q}, + {KEYSTROKE_DEBUG_TREE, ControlMask, True, XK_Q}, + {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_t}, + {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_T}, + {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_f}, + {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_F}, + {KEYSTROKE_MINIMIZE, ControlMask, True, XK_m}, + {KEYSTROKE_MINIMIZE, ControlMask, True, XK_M}, + {KEYSTROKE_LEFT, ControlMask, True, XK_Left}, + {KEYSTROKE_LEFT, ControlMask, True, XK_KP_Left}, + {KEYSTROKE_UP, ControlMask, True, XK_Up}, + {KEYSTROKE_UP, ControlMask, True, XK_KP_Up}, + {KEYSTROKE_RIGHT, ControlMask, True, XK_Right}, + {KEYSTROKE_RIGHT, ControlMask, True, XK_KP_Right}, + {KEYSTROKE_DOWN, ControlMask, True, XK_Down}, + {KEYSTROKE_DOWN, ControlMask, True, XK_KP_Down}, + {KEYSTROKE_RESIZE, ControlMask, True, XK_r}, + {KEYSTROKE_RESIZE, ControlMask, True, XK_R}, + {KEYSTROKE_DEFER, ControlMask, True, XK_e}, + {KEYSTROKE_DEFER, ControlMask, True, XK_E}, + {KEYSTROKE_IGNORE, ControlMask, True, XK_BackSpace}, + {KEYSTROKE_IGNORE, 0, False, XK_Terminate_Server}, + {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, True, XK_j}, + {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, True, XK_J}, + {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, True, XK_a}, + {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, True, XK_A}, + {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_x}, + {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_X}, + {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_y}, + {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_Y}, + {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, + {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_F}, + {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_Left}, + {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_KP_Left}, + {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, True, XK_Up}, + {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, True, XK_KP_Up}, + {KEYSTROKE_VIEWPORT_MOVE_RIGHT, ControlMask | ShiftMask, True, XK_Right}, + {KEYSTROKE_VIEWPORT_MOVE_RIGHT, ControlMask | ShiftMask, True, XK_KP_Right}, + {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, True, XK_Down}, + {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, True, XK_KP_Down}, + {KEYSTROKE_END_MARKER, 0, False, NoSymbol}, }; struct nxagentSpecialKeystrokeMap *map = default_map; @@ -165,12 +165,12 @@ static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned i return ret; } -static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystrokeMap *ret) +static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystrokeMap *ret) { struct nxagentSpecialKeystrokeMap newkm = { .stroke = 0, .modifierMask = 0, - .modifierAltMeta = 0, + .modifierAltMeta = False, .keysym = NoSymbol }; xmlAttr *attr; @@ -219,7 +219,7 @@ static int read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystro else if (strcmp((char *)attr->name, "Control") == 0) { newkm.modifierMask |= ControlMask; } else if (strcmp((char *)attr->name, "Shift") == 0) { newkm.modifierMask |= ShiftMask; } else if (strcmp((char *)attr->name, "Lock") == 0) { newkm.modifierMask |= LockMask; } - else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = 1; } + else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = True; } } if (newkm.stroke != 0 && newkm.keysym != NoSymbol) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 28374e807..3f1c5885d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -75,7 +75,7 @@ enum nxagentSpecialKeystroke { struct nxagentSpecialKeystrokeMap { enum nxagentSpecialKeystroke stroke; unsigned int modifierMask; /* everything except alt/meta */ - int modifierAltMeta; /* modifier combination should include alt/meta */ + Bool modifierAltMeta; /* modifier combination should include alt/meta */ KeySym keysym; }; -- cgit v1.2.3 From 13a7c4a7335a6695ede3f2f3a58a06479ea9a6a2 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:30:02 +0100 Subject: Keystroke.c: use symbols instead of integers We have defined them, so use them! --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index e61ecd2a5..281fec243 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -168,7 +168,7 @@ static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned i static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystrokeMap *ret) { struct nxagentSpecialKeystrokeMap newkm = { - .stroke = 0, + .stroke = KEYSTROKE_END_MARKER, .modifierMask = 0, .modifierAltMeta = False, .keysym = NoSymbol @@ -186,8 +186,10 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr #endif continue; } + if (strcmp((char *)attr->name, "action") == 0) { + newkm.stroke = KEYSTROKE_END_MARKER; for (int i = 0; nxagentSpecialKeystrokeNames[i] != NULL; i++) { if (strcmp(nxagentSpecialKeystrokeNames[i],(char *)attr->children->content) == 0) @@ -222,7 +224,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = True; } } - if (newkm.stroke != 0 && newkm.keysym != NoSymbol) + if (newkm.stroke != KEYSTROKE_END_MARKER && newkm.keysym != NoSymbol) { /* keysym and stroke are required, everything else is optional */ memcpy(ret, &newkm, sizeof(struct nxagentSpecialKeystrokeMap)); -- cgit v1.2.3 From 25db7413afabc3ece4702e95ae289468898c930d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:31:27 +0100 Subject: Keystroke.c: Simplify read_binding_from_xmlnode --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 281fec243..6346962c8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -167,6 +167,7 @@ static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned i static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystrokeMap *ret) { + /* init the struct to have proper values in case not all attributes are found */ struct nxagentSpecialKeystrokeMap newkm = { .stroke = KEYSTROKE_END_MARKER, .modifierMask = 0, @@ -204,24 +205,24 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr } else if (strcmp((char *)attr->name, "key") == 0) { - if (strcmp((char *)attr->children->content, "0") != 0 && strcmp((char *)attr->children->content, "false") != 0) - newkm.keysym = XStringToKeysym((char *)attr->children->content); - + newkm.keysym = XStringToKeysym((char *)attr->children->content); continue; } - - /* ignore attributes with value="0" or "false", everything else is interpreted as true */ - if (strcmp((char *)attr->children->content, "0") == 0 || strcmp((char *)attr->children->content, "false") == 0) - continue; - - if (strcmp((char *)attr->name, "Mod1") == 0) { newkm.modifierMask |= Mod1Mask; } - else if (strcmp((char *)attr->name, "Mod2") == 0) { newkm.modifierMask |= Mod2Mask; } - else if (strcmp((char *)attr->name, "Mod3") == 0) { newkm.modifierMask |= Mod3Mask; } - else if (strcmp((char *)attr->name, "Mod4") == 0) { newkm.modifierMask |= Mod4Mask; } - else if (strcmp((char *)attr->name, "Control") == 0) { newkm.modifierMask |= ControlMask; } - else if (strcmp((char *)attr->name, "Shift") == 0) { newkm.modifierMask |= ShiftMask; } - else if (strcmp((char *)attr->name, "Lock") == 0) { newkm.modifierMask |= LockMask; } - else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = True; } + else + { + /* ignore attributes with value="0" or "false", everything else is interpreted as true */ + if (strcmp((char *)attr->children->content, "0") == 0 || strcmp((char *)attr->children->content, "false") == 0) + continue; + + if (strcmp((char *)attr->name, "Mod1") == 0) { newkm.modifierMask |= Mod1Mask; } + else if (strcmp((char *)attr->name, "Mod2") == 0) { newkm.modifierMask |= Mod2Mask; } + else if (strcmp((char *)attr->name, "Mod3") == 0) { newkm.modifierMask |= Mod3Mask; } + else if (strcmp((char *)attr->name, "Mod4") == 0) { newkm.modifierMask |= Mod4Mask; } + else if (strcmp((char *)attr->name, "Control") == 0) { newkm.modifierMask |= ControlMask; } + else if (strcmp((char *)attr->name, "Shift") == 0) { newkm.modifierMask |= ShiftMask; } + else if (strcmp((char *)attr->name, "Lock") == 0) { newkm.modifierMask |= LockMask; } + else if (strcmp((char *)attr->name, "AltMeta") == 0) { newkm.modifierAltMeta = True; } + } } if (newkm.stroke != KEYSTROKE_END_MARKER && newkm.keysym != NoSymbol) -- cgit v1.2.3 From 93a360c5d8b98869d6a3c60a6da7800a0763734c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:40:17 +0100 Subject: Keystroke.c: add another FIXME --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 6346962c8..cc41d557e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -394,6 +394,8 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) int keysyms_per_keycode_return; struct nxagentSpecialKeystrokeMap *cur = map; + /* FIXME: we do late parsing here, this should be done at startup, + not at first keypress! */ parse_keystroke_file(); XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, -- cgit v1.2.3 From b39ec4c45abac55bf0cb3faafb5a7ffc2adfa758 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 10 Mar 2017 23:49:49 +0100 Subject: Keystroke.c: improve TEST output --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index cc41d557e..ce74dd82c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -420,14 +420,14 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) enum nxagentSpecialKeystroke stroke = find_keystroke(X); *result = doNothing; - if (stroke == KEYSTROKE_NOTHING) - return False; - #ifdef TEST fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d\n", X -> keycode, X -> state, stroke); #endif + if (stroke == KEYSTROKE_NOTHING) + return False; + /* * Check special keys. */ -- cgit v1.2.3 From 8f0d885cd21f90722c19ad316623c57db7012fde Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 11 Mar 2017 00:07:13 +0100 Subject: Keystroke.c: print keystroke name in TEST mode --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index ce74dd82c..6cb28e938 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -421,8 +421,12 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doNothing; #ifdef TEST - fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d\n", - X -> keycode, X -> state, stroke); + if (stroke != KEYSTROKE_NOTHING && stroke != KEYSTROKE_END_MARKER) + fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d (%s)\n", + X -> keycode, X -> state, stroke, nxagentSpecialKeystrokeNames[stroke]); + else + fprintf(stderr, "nxagentCheckSpecialKeystroke: got code %x - state %x - stroke %d (unused)\n", + X -> keycode, X -> state, stroke); #endif if (stroke == KEYSTROKE_NOTHING) -- cgit v1.2.3 From 8f7b0b75b83c3651f92d6a6e6f8ff6c8f17de061 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 11 Mar 2017 00:21:53 +0100 Subject: Keystroke.c: arrange switch_all_screens and fullscreen close together Both use the same keystroke 'f' (with different modifiers) for a very similar function. --- etc/keystrokes.cfg | 2 +- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 6 +++--- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 28 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg index 007a18288..1716d6abe 100644 --- a/etc/keystrokes.cfg +++ b/etc/keystrokes.cfg @@ -2,6 +2,7 @@ + @@ -11,7 +12,6 @@ - diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 6cb28e938..fc4868d1c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -70,6 +70,7 @@ char * nxagentSpecialKeystrokeNames[] = { "end_marker", "close_session", "switch_all_screens", + "fullscreen", "minimize", "left", "up", @@ -85,7 +86,6 @@ char * nxagentSpecialKeystrokeNames[] = { "test_input", "deactivate_input_devices_grab", - "fullscreen", "viewport_move_left", "viewport_move_up", "viewport_move_right", @@ -101,6 +101,8 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_T}, {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_f}, {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_F}, + {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, + {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_F}, {KEYSTROKE_MINIMIZE, ControlMask, True, XK_m}, {KEYSTROKE_MINIMIZE, ControlMask, True, XK_M}, {KEYSTROKE_LEFT, ControlMask, True, XK_Left}, @@ -125,8 +127,6 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_X}, {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_y}, {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_Y}, - {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, - {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_F}, {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_Left}, {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_KP_Left}, {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, True, XK_Up}, diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 3f1c5885d..45f507d51 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -42,23 +42,23 @@ enum nxagentSpecialKeystroke { KEYSTROKE_END_MARKER = 0, KEYSTROKE_CLOSE_SESSION = 1, KEYSTROKE_SWITCH_ALL_SCREENS = 2, - KEYSTROKE_MINIMIZE = 3, - KEYSTROKE_LEFT = 4, - KEYSTROKE_UP = 5, - KEYSTROKE_RIGHT = 6, - KEYSTROKE_DOWN = 7, - KEYSTROKE_RESIZE = 8, - KEYSTROKE_DEFER = 9, - KEYSTROKE_IGNORE = 10, - KEYSTROKE_FORCE_SYNCHRONIZATION = 11, + KEYSTROKE_FULLSCREEN = 3, + KEYSTROKE_MINIMIZE = 4, + KEYSTROKE_LEFT = 5, + KEYSTROKE_UP = 6, + KEYSTROKE_RIGHT = 7, + KEYSTROKE_DOWN = 8, + KEYSTROKE_RESIZE = 9, + KEYSTROKE_DEFER = 10, + KEYSTROKE_IGNORE = 11, + KEYSTROKE_FORCE_SYNCHRONIZATION = 12, /* stuff used for debugging, probably not useful for most people */ - KEYSTROKE_DEBUG_TREE = 12, - KEYSTROKE_REGIONS_ON_SCREEN = 13, - KEYSTROKE_TEST_INPUT = 14, - KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB = 15, + KEYSTROKE_DEBUG_TREE = 13, + KEYSTROKE_REGIONS_ON_SCREEN = 14, + KEYSTROKE_TEST_INPUT = 15, + KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB = 16, - KEYSTROKE_FULLSCREEN = 16, KEYSTROKE_VIEWPORT_MOVE_LEFT = 17, KEYSTROKE_VIEWPORT_MOVE_UP = 18, KEYSTROKE_VIEWPORT_MOVE_RIGHT = 19, -- cgit v1.2.3 From af8e5e03a8dfac2bd245b82e437cf4b1996a995d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:17:51 +0100 Subject: Keystroke: whitespace fixes --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index fc4868d1c..7eb7451c6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -193,7 +193,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr newkm.stroke = KEYSTROKE_END_MARKER; for (int i = 0; nxagentSpecialKeystrokeNames[i] != NULL; i++) { - if (strcmp(nxagentSpecialKeystrokeNames[i],(char *)attr->children->content) == 0) + if (strcmp(nxagentSpecialKeystrokeNames[i], (char *)attr->children->content) == 0) { /* this relies on the values of enum nxagentSpecialKeystroke and the * indices of nxagentSpecialKeystrokeNames being in sync */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 45f507d51..56c977418 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -69,7 +69,7 @@ enum nxagentSpecialKeystroke { /* insert more here, increment KEYSTROKE_MAX accordingly. * then update string translation below */ - KEYSTROKE_MAX=22, + KEYSTROKE_MAX = 22, }; struct nxagentSpecialKeystrokeMap { -- cgit v1.2.3 From af5a83bbadd7983a2d14147815bf9b180a0d87be Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:20:53 +0100 Subject: Keystroke.c: more/fixed debug output --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 7eb7451c6..12a5cd49b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -356,7 +356,10 @@ static void parse_keystroke_file(void) num++; } } - map = calloc((num + 1), sizeof(struct nxagentSpecialKeystrokeMap)); + #ifdef DEBUG + fprintf(stderr, "%s: found %d keystrokes in %s\n", __func__, num, filename); + #endif + map = calloc(num+1, sizeof(struct nxagentSpecialKeystrokeMap)); if (map == NULL) { fprintf(stderr, "calloc failed"); @@ -370,6 +373,9 @@ static void parse_keystroke_file(void) read_binding_from_xmlnode(bindings, &(map[idx]))) idx++; } + #ifdef DEBUG + fprintf(stderr, "%s: read %d keystrokes", __func__, idx); + #endif map[idx].stroke = KEYSTROKE_END_MARKER; } @@ -381,7 +387,7 @@ static void parse_keystroke_file(void) else { #ifdef DEBUG - fprintf("XML parsing for %s failed\n", filename); + fprintf(stderr, "XML parsing for %s failed\n", filename); #endif } free(filename); @@ -403,8 +409,17 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) 1, &keysyms_per_keycode_return); + #ifdef DEBUG + fprintf(stderr, "%s: got keysym '%c' (%d)\n", __func__, keysym[0], keysym[0]); + #endif while (cur->stroke != KEYSTROKE_END_MARKER) { + #ifdef DEBUG + fprintf(stderr, "%s: checking keysym '%c' (%d)\n", __func__, cur->keysym, cur->keysym); + #endif if (cur->keysym == keysym[0] && modifier_matches(cur->modifierMask, cur->modifierAltMeta, X->state)) { + #ifdef DEBUG + fprintf(stderr, "%s: match including modifiers for keysym '%c' (%d), stroke %d (%s)\n", __func__, cur->keysym, cur->keysym, cur->stroke, nxagentSpecialKeystrokeNames[cur->stroke]); + #endif free(keysym); return cur->stroke; } -- cgit v1.2.3 From 5595e3d16cdae57544b91f01ee6cb6458850aa37 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:21:57 +0100 Subject: Keystroke.c: Fix modifier handling Code could not distinguish between ctrl-alt-shift and ctrl-alt. Fixes ArcticaProject/nx-libs#395 --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 12a5cd49b..6e8c9c2a8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -155,10 +155,11 @@ static Bool modifier_matches(unsigned int mask, int compare_alt_meta, unsigned i } mask &= ~nxagentAltMetaMask; + state &= ~nxagentAltMetaMask; } /* all modifiers except meta/alt have to match exactly, extra bits are evil */ - if ((mask & state) != mask) { + if (mask != state) { ret = False; } -- cgit v1.2.3 From d2c811564f7a1c955a95defc5f7d2c27a5e9f828 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:23:32 +0100 Subject: Keyboard.c: Introduce separate masks for Alt and Meta Unclear why they have been merged at all. --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 208ae0653..5fc01c976 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -202,6 +202,8 @@ extern char *nxagentKeyboard; static char *nxagentXkbGetRules(void); unsigned int nxagentAltMetaMask; +unsigned int nxagentAltMask; +unsigned int nxagentMetaMask; static void nxagentCheckAltMetaKeys(CARD8, int); @@ -788,6 +790,8 @@ N/A #endif /* #ifdef _XSERVER64 */ nxagentAltMetaMask = 0; + nxagentAltMask = 0; + nxagentMetaMask = 0; for (i = 0; i < 256; i++) modmap[i] = 0; @@ -1378,21 +1382,25 @@ void nxagentCheckAltMetaKeys(CARD8 keycode, int j) if (keycode == XKeysymToKeycode(nxagentDisplay, XK_Meta_L)) { nxagentAltMetaMask |= 1 << j; + nxagentMetaMask |= 1 << j; } if (keycode == XKeysymToKeycode(nxagentDisplay, XK_Meta_R)) { nxagentAltMetaMask |= 1 << j; + nxagentMetaMask |= 1 << j; } if (keycode == XKeysymToKeycode(nxagentDisplay, XK_Alt_L)) { nxagentAltMetaMask |= 1 << j; + nxagentAltMask |= 1 << j; } if (keycode == XKeysymToKeycode(nxagentDisplay, XK_Alt_R)) { nxagentAltMetaMask |= 1 << j; + nxagentAltMask |= 1 << j; } } -- cgit v1.2.3 From 2c721f484d9177d28f27a4a33eb2cd0e6c4798fd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:25:15 +0100 Subject: Keystroke.h: sane struct init Correctly use constant for unused structs instead of implicitly setting it through calloc(). --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 6e8c9c2a8..9165a057a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -369,6 +369,7 @@ static void parse_keystroke_file(void) for (bindings = cur->children; bindings; bindings = bindings->next) { + map[idx].stroke = KEYSTROKE_NOTHING; if (bindings->type == XML_ELEMENT_NODE && strcmp((char *)bindings->name, "keystroke") == 0 && read_binding_from_xmlnode(bindings, &(map[idx]))) -- cgit v1.2.3 From 57081e55fdb8a90488574b732793bf1056f4c6ab Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:27:50 +0100 Subject: Keystroke.c: fix code order Do not use map before calling parse_keystroke_file() since it will malloc map. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 9165a057a..501eea8b0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -400,12 +400,14 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) { enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; int keysyms_per_keycode_return; - struct nxagentSpecialKeystrokeMap *cur = map; + struct nxagentSpecialKeystrokeMap *cur; /* FIXME: we do late parsing here, this should be done at startup, not at first keypress! */ parse_keystroke_file(); + cur = map; + XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, X->keycode, 1, -- cgit v1.2.3 From 3042c5064b0bde6e27ed010386d7941deb83179e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 20:50:53 +0100 Subject: Keystroke.c: add missing Mod5 modifier --- doc/nxagent/README.keystrokes | 2 +- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index 08cdafb46..32197a79f 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -52,7 +52,7 @@ XStringToKeysym function. A list of possible keys can be found in 'Space' and 'escape' won't. Modifiers are given as boolean attributes, possible modifiers are Mod1, Mod2, -Mod3, Mod4, Control, Shift, Lock. Sensible combinations strongly depend on your +Mod3, Mod4, Mod5, Control, Shift, Lock. Sensible combinations strongly depend on your keyboard configuration, but usually you will need Mod1 and Control. Boolean in this context means '0', 'false' and an unspecified attribute are false, anything else is considered true. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 501eea8b0..55936db6d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -219,6 +219,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr else if (strcmp((char *)attr->name, "Mod2") == 0) { newkm.modifierMask |= Mod2Mask; } else if (strcmp((char *)attr->name, "Mod3") == 0) { newkm.modifierMask |= Mod3Mask; } else if (strcmp((char *)attr->name, "Mod4") == 0) { newkm.modifierMask |= Mod4Mask; } + else if (strcmp((char *)attr->name, "Mod5") == 0) { newkm.modifierMask |= Mod5Mask; } else if (strcmp((char *)attr->name, "Control") == 0) { newkm.modifierMask |= ControlMask; } else if (strcmp((char *)attr->name, "Shift") == 0) { newkm.modifierMask |= ShiftMask; } else if (strcmp((char *)attr->name, "Lock") == 0) { newkm.modifierMask |= LockMask; } -- cgit v1.2.3 From 8f2679abc6910155fa2e5ddeb54cd7cfd4dcf17f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 21:14:20 +0100 Subject: Keystroke.c: make nxagentKeystrokeFileParsed local --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 55936db6d..f655e3b95 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -45,7 +45,6 @@ extern Bool nxagentWMIsRunning; extern Bool nxagentIpaq; extern char *nxagentKeystrokeFile; -Bool nxagentKeystrokeFileParsed = False; #ifdef NX_DEBUG_INPUT int nxagentDebugInputDevices = 0; @@ -254,10 +253,12 @@ static void parse_keystroke_file(void) char *homefile = "/.nx/config/keystrokes.cfg"; char *etcfile = "/etc/nxagent/keystrokes.cfg"; - if (nxagentKeystrokeFileParsed) + /* used for tracking if the config file parsing has already been + done (regardless of the result) */ + static Bool done = False; + if (done) return; - - nxagentKeystrokeFileParsed = True; + done = True; if (nxagentX2go) { homefile = "/.x2go/config/keystrokes.cfg"; -- cgit v1.2.3 From c134b93ac09ff520539dd73482455808c0e22a38 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 21:19:48 +0100 Subject: Keystroke.c: use an own environment variable for X2Go --- doc/nxagent/README.keystrokes | 2 +- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index 32197a79f..ad850f6df 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -16,7 +16,7 @@ If nxagent is called without branding, it searches: If nxagent is called with X2Go branding (i.e., as x2goagent), it searches: - in the location given by the '-keystrokefile' command line parameter -- in the location given by the NXAGENT_KEYSTROKEFILE environment variable +- in the location given by the X2GO_KEYSTROKEFILE environment variable - in ~/.x2go/config/keystrokes.cfg - in /etc/x2go/keystrokes.cfg diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index f655e3b95..ec408d3c2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -245,13 +245,15 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr * - $HOME/.nx/config/keystrokes.cfg * - /etc/nxagent/keystrokes.cfg * - hardcoded traditional NX default settings + * If run in x2go flavour different filenames and varnames are used. */ static void parse_keystroke_file(void) { char *filename = NULL; - char *homefile = "/.nx/config/keystrokes.cfg"; - char *etcfile = "/etc/nxagent/keystrokes.cfg"; + char *homefile; + char *etcfile; + char *envvar; /* used for tracking if the config file parsing has already been done (regardless of the result) */ @@ -263,6 +265,11 @@ static void parse_keystroke_file(void) if (nxagentX2go) { homefile = "/.x2go/config/keystrokes.cfg"; etcfile = "/etc/x2go/keystrokes.cfg"; + envvar = "X2GO_KEYSTROKEFILE"; + } else { + homefile = "/.nx/config/keystrokes.cfg"; + etcfile = "/etc/nxagent/keystrokes.cfg"; + envvar = "NXAGENT_KEYSTROKEFILE"; } if (nxagentKeystrokeFile != NULL && access(nxagentKeystrokeFile, R_OK) == 0) @@ -274,7 +281,7 @@ static void parse_keystroke_file(void) exit(EXIT_FAILURE); } } - else if ((filename = getenv("NXAGENT_KEYSTROKEFILE")) != NULL && access(filename, R_OK) == 0) + else if ((filename = getenv(envvar)) != NULL && access(filename, R_OK) == 0) { filename = strdup(filename); if (filename == NULL) -- cgit v1.2.3 From f97bb3f13c2b071fa92c9d4fba172258fa141023 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 21:26:31 +0100 Subject: Keystroke.c: fix formatting --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index ec408d3c2..532c0c8a8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -300,7 +300,7 @@ static void parse_keystroke_file(void) if (homedir == NULL) { fprintf(stderr, "malloc failed"); - exit(EXIT_FAILURE); + exit(EXIT_FAILURE); } filename = calloc(1, strlen(homefile) + strlen(homedir) + 1); if (filename == NULL) -- cgit v1.2.3 From aadcac452379ae0da59f1a16c60189a69ef822d6 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 21:42:24 +0100 Subject: Keystroke.c: simplify parse_keystroke_file --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 51 ++++++++------------------ 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 532c0c8a8..e0f8925fb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -272,19 +272,17 @@ static void parse_keystroke_file(void) envvar = "NXAGENT_KEYSTROKEFILE"; } - if (nxagentKeystrokeFile != NULL && access(nxagentKeystrokeFile, R_OK) == 0) + if (nxagentKeystrokeFile && access(nxagentKeystrokeFile, R_OK) == 0) { - filename = strdup(nxagentKeystrokeFile); - if (filename == NULL) + if (!(filename = strdup(nxagentKeystrokeFile))) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); } } - else if ((filename = getenv(envvar)) != NULL && access(filename, R_OK) == 0) + else if ((filename = getenv(envvar)) && access(filename, R_OK) == 0) { - filename = strdup(filename); - if (filename == NULL) + if (!(filename = strdup(filename))) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); @@ -294,26 +292,15 @@ static void parse_keystroke_file(void) { char *homedir = getenv("HOME"); filename = NULL; - if (homedir != NULL) + if (homedir) { - homedir = strdup(homedir); - if (homedir == NULL) - { - fprintf(stderr, "malloc failed"); - exit(EXIT_FAILURE); - } - filename = calloc(1, strlen(homefile) + strlen(homedir) + 1); - if (filename == NULL) + if (!(filename = calloc(1, strlen(homefile) + strlen(homedir) + 1))) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); } strcpy(filename, homedir); strcpy(filename + strlen(homedir), homefile); - if (homedir) - { - free(homedir); - } } if (access(filename, R_OK) == 0) @@ -322,10 +309,8 @@ static void parse_keystroke_file(void) } else if (access(etcfile, R_OK) == 0) { - if (filename) - free(filename); - filename = strdup(etcfile); - if (filename == NULL) + free(filename); + if (!(filename = strdup(etcfile))) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); @@ -333,8 +318,7 @@ static void parse_keystroke_file(void) } else { - if (filename) - free(filename); + free(filename); filename = NULL; } } @@ -342,20 +326,15 @@ static void parse_keystroke_file(void) /* now we know which file to read, if any */ if (filename) { - xmlDoc *doc = NULL; - xmlNode *root = NULL; LIBXML_TEST_VERSION - doc = xmlReadFile(filename, NULL, 0); - if (doc != NULL) + xmlDoc *doc = xmlReadFile(filename, NULL, 0); + if (doc) { - xmlNode *cur = NULL; - root = xmlDocGetRootElement(doc); - - for (cur = root; cur; cur = cur->next) + for (xmlNode *cur = xmlDocGetRootElement(doc); cur; cur = cur->next) { if (cur->type == XML_ELEMENT_NODE && strcmp((char *)cur->name, "keystrokes") == 0) { - xmlNode *bindings = NULL; + xmlNode *bindings; int num = 0; int idx = 0; @@ -369,8 +348,7 @@ static void parse_keystroke_file(void) #ifdef DEBUG fprintf(stderr, "%s: found %d keystrokes in %s\n", __func__, num, filename); #endif - map = calloc(num+1, sizeof(struct nxagentSpecialKeystrokeMap)); - if (map == NULL) + if (!(map = calloc(num+1, sizeof(struct nxagentSpecialKeystrokeMap)))) { fprintf(stderr, "calloc failed"); exit(EXIT_FAILURE); @@ -402,6 +380,7 @@ static void parse_keystroke_file(void) #endif } free(filename); + filename = NULL; } } -- cgit v1.2.3 From abf6242128394aa2374f3882252dfc84d4499c33 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 22:00:23 +0100 Subject: Keystroke.c: add new keystroke to reread keystroke config Default is ctrl-alt-k --- doc/nxagent/README.keystrokes | 4 +++ etc/keystrokes.cfg | 1 + nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 34 +++++++++++++++++++++++--- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 6 +++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index ad850f6df..7edd340d2 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -92,6 +92,10 @@ viewport_move_right Moves the image viewport to the right. viewport_move_down Moves the image viewport down. +reread_keystrokes + forces nxagent to re-read the keystroke + configuration. Useful to add/changes keystrokes for a running + session. Only in builds with certain debugging options enabled, ignored otherwise: force_synchronization diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg index 1716d6abe..22cc8c7a0 100644 --- a/etc/keystrokes.cfg +++ b/etc/keystrokes.cfg @@ -16,4 +16,5 @@ + diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index e0f8925fb..bb8d83f66 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -89,6 +89,8 @@ char * nxagentSpecialKeystrokeNames[] = { "viewport_move_up", "viewport_move_right", "viewport_move_down", + + "reread_keystrokes", NULL, }; @@ -134,6 +136,7 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_VIEWPORT_MOVE_RIGHT, ControlMask | ShiftMask, True, XK_KP_Right}, {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, True, XK_Down}, {KEYSTROKE_VIEWPORT_MOVE_DOWN, ControlMask | ShiftMask, True, XK_KP_Down}, + {KEYSTROKE_REREAD_KEYSTROKES, ControlMask, True, XK_k}, {KEYSTROKE_END_MARKER, 0, False, NoSymbol}, }; struct nxagentSpecialKeystrokeMap *map = default_map; @@ -247,7 +250,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr * - hardcoded traditional NX default settings * If run in x2go flavour different filenames and varnames are used. */ -static void parse_keystroke_file(void) +static void parse_keystroke_file(Bool force) { char *filename = NULL; @@ -258,8 +261,21 @@ static void parse_keystroke_file(void) /* used for tracking if the config file parsing has already been done (regardless of the result) */ static Bool done = False; - if (done) - return; + + if (force) { + if (map != default_map) + { + free(map); + map = default_map; + } + fprintf(stderr, "re-reading keystroke config\n"); + } + else + { + if (done) + return; + } + done = True; if (nxagentX2go) { @@ -392,7 +408,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) /* FIXME: we do late parsing here, this should be done at startup, not at first keypress! */ - parse_keystroke_file(); + parse_keystroke_file(False); cur = map; @@ -573,6 +589,16 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doViewportMoveDown; } break; + case KEYSTROKE_REREAD_KEYSTROKES: + /* two reasons to check on KeyRelease: + - this code is called for KeyPress and KeyRelease, so we + would read the keystroke file twice + - if the keystroke file changes settings for this key this + might lead to unexpected behaviour + */ + if (X->type == KeyRelease) + parse_keystroke_file(True); + break; case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */ case KEYSTROKE_END_MARKER: /* just to make gcc STFU */ case KEYSTROKE_MAX: diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 56c977418..48ed65b35 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -64,12 +64,14 @@ enum nxagentSpecialKeystroke { KEYSTROKE_VIEWPORT_MOVE_RIGHT = 19, KEYSTROKE_VIEWPORT_MOVE_DOWN = 20, - KEYSTROKE_NOTHING = 21, + KEYSTROKE_REREAD_KEYSTROKES = 21, + + KEYSTROKE_NOTHING = 22, /* insert more here, increment KEYSTROKE_MAX accordingly. * then update string translation below */ - KEYSTROKE_MAX = 22, + KEYSTROKE_MAX = 23, }; struct nxagentSpecialKeystrokeMap { -- cgit v1.2.3 From cb40cc44819ec6e6af3277d11554c671ea504355 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 22:07:58 +0100 Subject: Keystroke.c: remove unneeded capital keys for default keystrokes --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index bb8d83f66..d12b459fc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -97,15 +97,10 @@ char * nxagentSpecialKeystrokeNames[] = { struct nxagentSpecialKeystrokeMap default_map[] = { /* stroke, modifierMask, modifierAltMeta, keysym */ {KEYSTROKE_DEBUG_TREE, ControlMask, True, XK_q}, - {KEYSTROKE_DEBUG_TREE, ControlMask, True, XK_Q}, {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_t}, - {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_T}, {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_f}, - {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_F}, {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, - {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_F}, {KEYSTROKE_MINIMIZE, ControlMask, True, XK_m}, - {KEYSTROKE_MINIMIZE, ControlMask, True, XK_M}, {KEYSTROKE_LEFT, ControlMask, True, XK_Left}, {KEYSTROKE_LEFT, ControlMask, True, XK_KP_Left}, {KEYSTROKE_UP, ControlMask, True, XK_Up}, @@ -115,19 +110,13 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_DOWN, ControlMask, True, XK_Down}, {KEYSTROKE_DOWN, ControlMask, True, XK_KP_Down}, {KEYSTROKE_RESIZE, ControlMask, True, XK_r}, - {KEYSTROKE_RESIZE, ControlMask, True, XK_R}, {KEYSTROKE_DEFER, ControlMask, True, XK_e}, - {KEYSTROKE_DEFER, ControlMask, True, XK_E}, {KEYSTROKE_IGNORE, ControlMask, True, XK_BackSpace}, {KEYSTROKE_IGNORE, 0, False, XK_Terminate_Server}, {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, True, XK_j}, - {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, True, XK_J}, {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, True, XK_a}, - {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, True, XK_A}, {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_x}, - {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_X}, {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_y}, - {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_Y}, {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_Left}, {KEYSTROKE_VIEWPORT_MOVE_LEFT, ControlMask | ShiftMask, True, XK_KP_Left}, {KEYSTROKE_VIEWPORT_MOVE_UP, ControlMask | ShiftMask, True, XK_Up}, -- cgit v1.2.3 From 6f4eb15408c9b7f13ff9e2765a7a50bace0dfae1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 13 Mar 2017 22:19:17 +0100 Subject: Update keystroke readme --- doc/nxagent/README.keystrokes | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index 7edd340d2..96bc158d2 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -64,12 +64,17 @@ default keybindings, and only one file is read, no merging between different configuration files is done. This also means that an empty or invalid configuration file deactivates all keybindings. +If an attribute occurs more than once in a line the last one wins. + List of possible 'action' attributes: ------------------------------------- close_session This terminates the session. +fullscreen + Switches the client window into or out of fullscreen mode, using only the current head. switch_all_screens + Switches the client window into or out of fullscreen mode, using all available heads. minimize This will minimize the client window (even for fullscreen sessions.) left @@ -77,13 +82,15 @@ up right down resize - This action switches between the auto-resize and viewport mode (static size). The default is auto-resize. In viewport mode one can use the 'viewport_move_up', 'viewport_move_down', 'viewport_move_left' and 'viewport_move_right' actions to move within the image. + This action switches between the auto-resize and viewport mode + (static size). The default is auto-resize. In viewport mode one can + use the 'viewport_move_up', 'viewport_move_down', + 'viewport_move_left' and 'viewport_move_right' actions to move + within the image. defer - Works like 'ignore' to make some keys be ignored/defunct inside the session. + activate/deactivate deferred screen updates. ignore Makes it possible to add 'ignore', as in nothing happens when certain keys are pressed. -fullscreen - Switches the client window into or out of fullscreen mode. viewport_move_left Moves the image viewport to the left. viewport_move_up -- cgit v1.2.3