From 51782cb25433a9518754338369b2f374b3070b4a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 21 Mar 2017 21:52:05 +0100 Subject: Args.c: add two missing options to help message --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 2bc12a3b4..6896d7212 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -2103,6 +2103,8 @@ void ddxUseMsg() ErrorF("-nokbreset don't reset keyboard device if the session is resumed\n"); ErrorF("-noxkblock always allow applications to change layout through XKEYBOARD\n"); ErrorF("-tile WxH size of image tiles (minimum allowed: 32x32)\n"); + ErrorF("-keystrokefile file file with keyboard shortcut definitions\n"); + ErrorF("-verbose print more warning and error messages\n"); ErrorF("-D enable desktop mode\n"); ErrorF("-R enable rootless mode\n"); ErrorF("-S enable shadow mode\n"); -- cgit v1.2.3 From 40f03399c706bbf00f2055a10c4b1bb3b49063a8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 21 Mar 2017 22:32:00 +0100 Subject: Keystroke.c: use KEYSTROKE_NOTHING instead of KEYSTROKE_END_MARKER. This is cleaner since KEYSTROKE_END_MARKER really marks the end of the list. --- 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 69b07dfe5..136f53542 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -171,7 +171,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr { /* init the struct to have proper values in case not all attributes are found */ struct nxagentSpecialKeystrokeMap newkm = { - .stroke = KEYSTROKE_END_MARKER, + .stroke = KEYSTROKE_NOTHING, .modifierMask = 0, .modifierAltMeta = False, .keysym = NoSymbol @@ -192,7 +192,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr if (strcmp((char *)attr->name, "action") == 0) { - newkm.stroke = KEYSTROKE_END_MARKER; + newkm.stroke = KEYSTROKE_NOTHING; for (int i = 0; nxagentSpecialKeystrokeNames[i] != NULL; i++) { if (strcmp(nxagentSpecialKeystrokeNames[i], (char *)attr->children->content) == 0) @@ -228,7 +228,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr } } - if (newkm.stroke != KEYSTROKE_END_MARKER && newkm.keysym != NoSymbol) + if (newkm.stroke != KEYSTROKE_NOTHING && newkm.keysym != NoSymbol) { /* keysym and stroke are required, everything else is optional */ memcpy(ret, &newkm, sizeof(struct nxagentSpecialKeystrokeMap)); -- cgit v1.2.3 From c693df127f0bd8911b7621ccb75ecdd458aad3d3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 21 Mar 2017 22:33:29 +0100 Subject: Keystroke.c: detect duplicate keystroke definitions We cannot check if an action is defined twice because the viewport stuff is controlled by multiple keystrokes (arrow keys and keypad) in the default configuration. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 136f53542..402f10b91 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -341,6 +341,7 @@ static void parse_keystroke_file(Bool force) /* now we know which file to read, if any */ if (filename) { + fprintf(stderr, "Info: using keystrokes file %s\n", filename); LIBXML_TEST_VERSION xmlDoc *doc = xmlReadFile(filename, NULL, 0); if (doc) @@ -375,7 +376,29 @@ static void parse_keystroke_file(Bool force) if (bindings->type == XML_ELEMENT_NODE && strcmp((char *)bindings->name, "keystroke") == 0 && read_binding_from_xmlnode(bindings, &(map[idx]))) + { + Bool store = True; + for (int j = 0; j < idx; j++) + { + if (map[j].stroke != KEYSTROKE_NOTHING && + map[idx].keysym != NoSymbol && + map[j].keysym == map[idx].keysym && + map[j].modifierMask == map[idx].modifierMask && + map[j].modifierAltMeta == map[idx].modifierAltMeta) + { + fprintf(stderr, "Warning: ignoring keystroke '%s' (already in use by '%s')\n", + nxagentSpecialKeystrokeNames[map[idx].stroke], + nxagentSpecialKeystrokeNames[map[j].stroke]); + store = False; + break; + } + } + + if (store) idx++; + else + map[idx].stroke = KEYSTROKE_NOTHING; + } } #ifdef DEBUG fprintf(stderr, "%s: read %d keystrokes", __func__, idx); -- cgit v1.2.3 From 4adb1911ff60abfb8c61b1677c2c225c54f156f1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:18:16 +0100 Subject: Keystroke.h/Keyboard.h: cleanup mask variables --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.h | 3 +++ nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h index d4f30fa6c..ba95a3a22 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h @@ -126,6 +126,9 @@ CARD8 nxagentConvertKeycode(CARD8 k); extern CARD8 nxagentCapsLockKeycode; extern CARD8 nxagentNumLockKeycode; +extern unsigned int nxagentAltMetaMask; +extern unsigned int nxagentAltMask; +extern unsigned int nxagentMetaMask; extern unsigned int nxagentCapsMask; extern unsigned int nxagentNumlockMask; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 48ed65b35..f8b4feb2f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -30,8 +30,6 @@ extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); -unsigned int nxagentAltMetaMask; - /* keep this sorted, do not rely on any numerical value in this enum, and be aware * that KEYSTROKE_MAX may be used in a malloc */ -- cgit v1.2.3 From 811ce4902ca7c3ab4b848d01695081d2def11763 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:21:00 +0100 Subject: Keystroke.h: auto-enum keystrokes there's no need to define the values ourselves --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 51 +++++++++++++------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index f8b4feb2f..f8602fc37 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -37,39 +37,38 @@ extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); * Keystroke.c nxagentSpecialKeystrokeNames */ enum nxagentSpecialKeystroke { /* 0 is used as end marker */ - KEYSTROKE_END_MARKER = 0, - KEYSTROKE_CLOSE_SESSION = 1, - KEYSTROKE_SWITCH_ALL_SCREENS = 2, - 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, + KEYSTROKE_END_MARKER, + KEYSTROKE_CLOSE_SESSION, + KEYSTROKE_SWITCH_ALL_SCREENS, + KEYSTROKE_FULLSCREEN, + KEYSTROKE_MINIMIZE, + KEYSTROKE_LEFT, + KEYSTROKE_UP, + KEYSTROKE_RIGHT, + KEYSTROKE_DOWN, + KEYSTROKE_RESIZE, + KEYSTROKE_DEFER, + KEYSTROKE_IGNORE, + KEYSTROKE_FORCE_SYNCHRONIZATION, /* stuff used for debugging, probably not useful for most people */ - KEYSTROKE_DEBUG_TREE = 13, - KEYSTROKE_REGIONS_ON_SCREEN = 14, - KEYSTROKE_TEST_INPUT = 15, - KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB = 16, + KEYSTROKE_DEBUG_TREE, + KEYSTROKE_REGIONS_ON_SCREEN, + KEYSTROKE_TEST_INPUT, + KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, - KEYSTROKE_VIEWPORT_MOVE_LEFT = 17, - KEYSTROKE_VIEWPORT_MOVE_UP = 18, - KEYSTROKE_VIEWPORT_MOVE_RIGHT = 19, - KEYSTROKE_VIEWPORT_MOVE_DOWN = 20, + KEYSTROKE_VIEWPORT_MOVE_LEFT, + KEYSTROKE_VIEWPORT_MOVE_UP, + KEYSTROKE_VIEWPORT_MOVE_RIGHT, + KEYSTROKE_VIEWPORT_MOVE_DOWN, - KEYSTROKE_REREAD_KEYSTROKES = 21, + KEYSTROKE_REREAD_KEYSTROKES, - KEYSTROKE_NOTHING = 22, + KEYSTROKE_NOTHING, - /* insert more here, increment KEYSTROKE_MAX accordingly. - * then update string translation below */ + /* insert more here and in the string translation */ - KEYSTROKE_MAX = 23, + KEYSTROKE_MAX, }; struct nxagentSpecialKeystrokeMap { -- cgit v1.2.3 From 3c921ccb42601ad78d0e6a67318ad12ed7118889 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:22:05 +0100 Subject: Keystroke.c/h: completely disable keystrokes that are not active at compile time --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 31 +++++++++++++++++--------- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 6 +++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 402f10b91..f6b3e420c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -33,7 +33,6 @@ #include "Display.h" #include "Events.h" #include "Options.h" -#include "Keystroke.h" #include "Keyboard.h" #include "Drawable.h" #include "Init.h" /* extern int nxagentX2go */ @@ -63,6 +62,9 @@ extern void nxagentDeactivateInputDevicesGrabs(); #undef DEBUG #undef DUMP +/* must be included _after_ DUMP */ +#include "Keystroke.h" + /* this table is used to parse actions given on the command line or in the * config file, therefore indices have to match the enum in Keystroke.h */ @@ -81,11 +83,16 @@ char * nxagentSpecialKeystrokeNames[] = { "ignore", "force_synchronization", +#ifdef DEBUG_TREE "debug_tree", +#endif +#ifdef DUMP "regions_on_screen", +#endif +#ifdef NX_DEBUG_INPUT "test_input", "deactivate_input_devices_grab", - +#endif "viewport_move_left", "viewport_move_up", "viewport_move_right", @@ -97,7 +104,9 @@ char * nxagentSpecialKeystrokeNames[] = { struct nxagentSpecialKeystrokeMap default_map[] = { /* stroke, modifierMask, modifierAltMeta, keysym */ +#ifdef DEBUG_TREE {KEYSTROKE_DEBUG_TREE, ControlMask, True, XK_q}, +#endif {KEYSTROKE_CLOSE_SESSION, ControlMask, True, XK_t}, {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_f}, {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, @@ -115,9 +124,13 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_IGNORE, ControlMask, True, XK_BackSpace}, {KEYSTROKE_IGNORE, 0, False, XK_Terminate_Server}, {KEYSTROKE_FORCE_SYNCHRONIZATION, ControlMask, True, XK_j}, +#ifdef DUMP {KEYSTROKE_REGIONS_ON_SCREEN, ControlMask, True, XK_a}, +#endif +#ifdef NX_DEBUG_INPUT {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_x}, {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_y}, +#endif {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}, @@ -494,11 +507,11 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) } switch (stroke) { +#ifdef DEBUG_TREE case KEYSTROKE_DEBUG_TREE: - #ifdef DEBUG_TREE *result = doDebugTree; - #endif break; +#endif case KEYSTROKE_CLOSE_SESSION: *result = doCloseSession; break; @@ -551,16 +564,16 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) case KEYSTROKE_FORCE_SYNCHRONIZATION: nxagentForceSynchronization = 1; break; +#ifdef DUMP case KEYSTROKE_REGIONS_ON_SCREEN: - #ifdef DUMP nxagentRegionsOnScreen(); - #endif break; +#endif +#ifdef NX_DEBUG_INPUT case KEYSTROKE_TEST_INPUT: /* * Used to test the input devices state. */ - #ifdef NX_DEBUG_INPUT if (X -> type == KeyPress) { if (nxagentDebugInputDevices == 0) { fprintf(stderr, "Info: Turning input devices debug ON.\n"); @@ -572,16 +585,14 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) } } return True; - #endif break; case KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB: - #ifdef NX_DEBUG_INPUT if (X->type == KeyPress) { nxagentDeactivateInputDevicesGrab(); } return True; - #endif break; +#endif case KEYSTROKE_FULLSCREEN: if (nxagentOption(Rootless) == 0) { *result = doSwitchFullscreen; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index f8602fc37..caf72f78c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -52,10 +52,16 @@ enum nxagentSpecialKeystroke { KEYSTROKE_FORCE_SYNCHRONIZATION, /* stuff used for debugging, probably not useful for most people */ +#ifdef DEBUG_TREE KEYSTROKE_DEBUG_TREE, +#endif +#ifdef DUMP KEYSTROKE_REGIONS_ON_SCREEN, +#endif +#ifdef NX_DEBUG_INPUT KEYSTROKE_TEST_INPUT, KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, +#endif KEYSTROKE_VIEWPORT_MOVE_LEFT, KEYSTROKE_VIEWPORT_MOVE_UP, -- cgit v1.2.3 From a45a348c44d5c39e8b8de3289f764f4ab397dff7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:42:26 +0100 Subject: keystrokes.cfg: add missing keystrokes --- etc/keystrokes.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg index 22cc8c7a0..2821034b6 100644 --- a/etc/keystrokes.cfg +++ b/etc/keystrokes.cfg @@ -13,8 +13,20 @@ + + + + + + + + + + + + -- cgit v1.2.3 From 79520f9c614d40f0e7d92a43241b1043ef240f5d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:46:35 +0100 Subject: Keystroke.c: introduce nxagentDumpKeystrokes() --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 34 ++++++++++++++++++++++++++ nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 1 + 2 files changed, 35 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index f6b3e420c..c66d6cc91 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -36,6 +36,7 @@ #include "Keyboard.h" #include "Drawable.h" #include "Init.h" /* extern int nxagentX2go */ +#include "Utils.h" #include @@ -433,6 +434,39 @@ static void parse_keystroke_file(Bool force) free(filename); filename = NULL; } + + nxagentDumpKeystrokes(); +} + +void nxagentDumpKeystrokes(void) +{ + int maxlen = 0; + for (int i = 0; nxagentSpecialKeystrokeNames[i]; i++) + maxlen = MAX(maxlen, strlen(nxagentSpecialKeystrokeNames[i])); + + fprintf(stderr, "Current known keystrokes:\n"); + + for (struct nxagentSpecialKeystrokeMap *cur = map; cur->stroke != KEYSTROKE_END_MARKER; cur++) { + unsigned int mask = cur->modifierMask; + fprintf(stderr, " %-*s ", maxlen, nxagentSpecialKeystrokeNames[cur->stroke]); + if (mask & ControlMask) {fprintf(stderr, "Ctrl+"); mask &= ~ControlMask;} + if (mask & ShiftMask) {fprintf(stderr, "Shift+"); mask &= ~ShiftMask;} + + /* these are only here for better readable modifier + names. Normally they are covered by the Mod and Lock lines + below */ + if (cur->modifierAltMeta) {fprintf(stderr, "Alt+"); mask &= ~(cur->modifierAltMeta);} + if (mask & nxagentCapsMask) {fprintf(stderr, "CapsLock+"); mask &= ~nxagentCapsMask;} + if (mask & nxagentNumlockMask) {fprintf(stderr, "NumLock+"); mask &= ~nxagentNumlockMask;} + + if (mask & Mod1Mask) {fprintf(stderr, "Mod1+"); mask &= ~Mod1Mask;} + if (mask & Mod2Mask) {fprintf(stderr, "Mod2+"); mask &= ~Mod2Mask;} + if (mask & Mod3Mask) {fprintf(stderr, "Mod3+"); mask &= ~Mod3Mask;} + if (mask & Mod4Mask) {fprintf(stderr, "Mod4+"); mask &= ~Mod4Mask;} + if (mask & Mod5Mask) {fprintf(stderr, "Mod5+"); mask &= ~Mod5Mask;} + if (mask & LockMask) {fprintf(stderr, "Lock+"); mask &= ~LockMask;} + fprintf(stderr, "%s\n", XKeysymToString(cur->keysym)); + } } static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index caf72f78c..777540aa0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -29,6 +29,7 @@ #include "Events.h" extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); +extern void nxagentDumpKeystrokes(void); /* keep this sorted, do not rely on any numerical value in this enum, and be aware * that KEYSTROKE_MAX may be used in a malloc */ -- cgit v1.2.3 From 076d458e739cb1e1b89dc5d3022a8b5d3ad35338 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:48:09 +0100 Subject: Keystroke.h: improve parse_keystroke_file() Print out more/better messages. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 79 ++++++++++++++------------ 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index c66d6cc91..92d20cf65 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -217,6 +217,8 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr break; } } + if (newkm.stroke == KEYSTROKE_NOTHING) + fprintf(stderr, "Info: ignoring unknown keystroke action '%s'.\n", (char *)attr->children->content); continue; } else if (strcmp((char *)attr->name, "key") == 0) @@ -281,7 +283,7 @@ static void parse_keystroke_file(Bool force) free(map); map = default_map; } - fprintf(stderr, "re-reading keystroke config\n"); + fprintf(stderr, "Info: re-reading keystrokes configuration\n"); } else { @@ -309,37 +311,12 @@ static void parse_keystroke_file(Bool force) exit(EXIT_FAILURE); } } - else if ((filename = getenv(envvar)) && access(filename, R_OK) == 0) + else if (nxagentKeystrokeFile) { - if (!(filename = strdup(filename))) + fprintf(stderr, "Warning: Cannot read keystroke file '%s'.\n", nxagentKeystrokeFile); + if ((filename = getenv(envvar)) && access(filename, R_OK) == 0) { - fprintf(stderr, "malloc failed"); - exit(EXIT_FAILURE); - } - } - else - { - char *homedir = getenv("HOME"); - filename = NULL; - if (homedir) - { - 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 (access(filename, R_OK) == 0) - { - /* empty */ - } - else if (access(etcfile, R_OK) == 0) - { - free(filename); - if (!(filename = strdup(etcfile))) + if (!(filename = strdup(filename))) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); @@ -347,19 +324,48 @@ static void parse_keystroke_file(Bool force) } else { - free(filename); + char *homedir = getenv("HOME"); filename = NULL; + if (homedir) + { + 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 (access(filename, R_OK) == 0) + { + /* empty */ + } + else if (access(etcfile, R_OK) == 0) + { + free(filename); + if (!(filename = strdup(etcfile))) + { + fprintf(stderr, "malloc failed"); + exit(EXIT_FAILURE); + } + } + else + { + free(filename); + filename = NULL; + } } } /* now we know which file to read, if any */ if (filename) { - fprintf(stderr, "Info: using keystrokes file %s\n", filename); LIBXML_TEST_VERSION xmlDoc *doc = xmlReadFile(filename, NULL, 0); if (doc) { + fprintf(stderr, "Info: using keystrokes file '%s'\n", filename); for (xmlNode *cur = xmlDocGetRootElement(doc); cur; cur = cur->next) { if (cur->type == XML_ELEMENT_NODE && strcmp((char *)cur->name, "keystrokes") == 0) @@ -427,14 +433,17 @@ static void parse_keystroke_file(Bool force) } else { - #ifdef DEBUG - fprintf(stderr, "XML parsing for %s failed\n", filename); - #endif + fprintf(stderr, "Warning: could not read/parse keystrokes file '%s'\n", filename); } free(filename); filename = NULL; } + if (map == default_map) + { + fprintf(stderr, "Info: Using builtin keystrokes.\n"); + } + nxagentDumpKeystrokes(); } -- cgit v1.2.3 From 2b9d7d27494a8b795e67cb1ae5ae2ebff37e08a6 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 22:54:34 +0100 Subject: Keystroke.c: use Booleans where appropriate Some of the keystroke checks have used them before. This commit unifies those checks. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 92d20cf65..5f4b70b43 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -48,7 +48,7 @@ extern Bool nxagentIpaq; extern char *nxagentKeystrokeFile; #ifdef NX_DEBUG_INPUT -int nxagentDebugInputDevices = 0; +int nxagentDebugInputDevices = False; unsigned long nxagentLastInputDevicesDumpTime = 0; extern void nxagentDeactivateInputDevicesGrabs(); #endif @@ -618,12 +618,12 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) * Used to test the input devices state. */ if (X -> type == KeyPress) { - if (nxagentDebugInputDevices == 0) { + if (nxagentDebugInputDevices == False) { fprintf(stderr, "Info: Turning input devices debug ON.\n"); - nxagentDebugInputDevices = 1; + nxagentDebugInputDevices = True; } else { fprintf(stderr, "Info: Turning input devices debug OFF.\n"); - nxagentDebugInputDevices = 0; + nxagentDebugInputDevices = False; nxagentLastInputDevicesDumpTime = 0; } } @@ -637,31 +637,31 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) break; #endif case KEYSTROKE_FULLSCREEN: - if (nxagentOption(Rootless) == 0) { + if (nxagentOption(Rootless) == False) { *result = doSwitchFullscreen; } break; case KEYSTROKE_VIEWPORT_MOVE_LEFT: - if (nxagentOption(Rootless) == 0 && - nxagentOption(DesktopResize) == 0) { + if (nxagentOption(Rootless) == False && + nxagentOption(DesktopResize) == False) { *result = doViewportMoveLeft; } break; case KEYSTROKE_VIEWPORT_MOVE_UP: - if (nxagentOption(Rootless) == 0 && - nxagentOption(DesktopResize) == 0) { + if (nxagentOption(Rootless) == False && + nxagentOption(DesktopResize) == False) { *result = doViewportMoveUp; } break; case KEYSTROKE_VIEWPORT_MOVE_RIGHT: - if (nxagentOption(Rootless) == 0 && - nxagentOption(DesktopResize) == 0) { + if (nxagentOption(Rootless) == False && + nxagentOption(DesktopResize) == False) { *result = doViewportMoveRight; } break; case KEYSTROKE_VIEWPORT_MOVE_DOWN: - if (nxagentOption(Rootless) == 0 && - nxagentOption(DesktopResize) == 0) { + if (nxagentOption(Rootless) == False && + nxagentOption(DesktopResize) == False) { *result = doViewportMoveDown; } break; -- cgit v1.2.3 From f12012b15b2c761172ca863bb4b76383ec0b3ee5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 23:01:09 +0100 Subject: Keystroke.c: avoid use of comparisons on "False" --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 34 ++++++++++---------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 5f4b70b43..8fac89658 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -559,41 +559,37 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doCloseSession; break; case KEYSTROKE_SWITCH_ALL_SCREENS: - if (nxagentOption(Rootless) == False) { + if (!nxagentOption(Rootless)) { *result = doSwitchAllScreens; } break; case KEYSTROKE_MINIMIZE: - if (nxagentOption(Rootless) == False) { + if (!nxagentOption(Rootless)) { *result = doMinimize; } break; case KEYSTROKE_LEFT: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportLeft; } break; case KEYSTROKE_UP: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportUp; } break; case KEYSTROKE_RIGHT: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportRight; } break; case KEYSTROKE_DOWN: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportDown; } break; case KEYSTROKE_RESIZE: - if (nxagentOption(Rootless) == False) { + if (!nxagentOption(Rootless)) { *result = doSwitchResizeMode; } break; @@ -618,7 +614,7 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) * Used to test the input devices state. */ if (X -> type == KeyPress) { - if (nxagentDebugInputDevices == False) { + if (!nxagentDebugInputDevices) { fprintf(stderr, "Info: Turning input devices debug ON.\n"); nxagentDebugInputDevices = True; } else { @@ -637,31 +633,27 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) break; #endif case KEYSTROKE_FULLSCREEN: - if (nxagentOption(Rootless) == False) { + if (!nxagentOption(Rootless)) { *result = doSwitchFullscreen; } break; case KEYSTROKE_VIEWPORT_MOVE_LEFT: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportMoveLeft; } break; case KEYSTROKE_VIEWPORT_MOVE_UP: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportMoveUp; } break; case KEYSTROKE_VIEWPORT_MOVE_RIGHT: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportMoveRight; } break; case KEYSTROKE_VIEWPORT_MOVE_DOWN: - if (nxagentOption(Rootless) == False && - nxagentOption(DesktopResize) == False) { + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportMoveDown; } break; -- cgit v1.2.3 From ba5183f80836042ce90be7dde29cc2c5f13baf9d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 23:11:32 +0100 Subject: Init keystrokes at startup and reconnect no more late initialization --- nx-X11/programs/Xserver/hw/nxagent/Init.c | 3 +++ nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 12 +++--------- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 1 + nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 5 +++++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index f15f2cb0a..014ab17f9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -69,6 +69,7 @@ is" without express or implied warranty. #include "Font.h" #include "Millis.h" #include "Error.h" +#include "Keystroke.h" #include #include "compext/Compext.h" @@ -406,6 +407,8 @@ FIXME: These variables, if not removed at all because have probably */ blackRoot = TRUE; + + nxagentInitKeystrokes(False); } void diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 8fac89658..8a5347a53 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -265,7 +265,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(Bool force) +void nxagentInitKeystrokes(Bool force) { char *filename = NULL; @@ -482,13 +482,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) { enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; int keysyms_per_keycode_return; - struct nxagentSpecialKeystrokeMap *cur; - - /* FIXME: we do late parsing here, this should be done at startup, - not at first keypress! */ - parse_keystroke_file(False); - - cur = map; + struct nxagentSpecialKeystrokeMap *cur = map; XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, X->keycode, @@ -665,7 +659,7 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) might lead to unexpected behaviour */ if (X->type == KeyRelease) - parse_keystroke_file(True); + nxagentInitKeystrokes(True); break; case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */ case KEYSTROKE_END_MARKER: /* just to make gcc STFU */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 777540aa0..7eb71bb6f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -30,6 +30,7 @@ extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); extern void nxagentDumpKeystrokes(void); +extern void nxagentInitKeystrokes(Bool force); /* keep this sorted, do not rely on any numerical value in this enum, and be aware * that KEYSTROKE_MAX may be used in a malloc */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index ee21bff69..fb2303549 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -52,6 +52,7 @@ #include "Millis.h" #include "Splash.h" #include "Error.h" +#include "Keystroke.h" #ifdef XKB #include "XKBsrv.h" @@ -646,6 +647,10 @@ Bool nxagentReconnectSession(void) goto nxagentReconnectError; } + /* Re-read keystrokes definitions in case the keystrokes file has + changed while being supended */ + nxagentInitKeystrokes(True); + #ifdef NX_DEBUG_INPUT fprintf(stderr, "Session: Session resumed at '%s' timestamp [%lu].\n", GetTimeAsString(), GetTimeInMillis()); #else -- cgit v1.2.3 From bf27d58b7e65d30d84704e7efd2d29002903030d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 23:32:24 +0100 Subject: Keystroke.c: move some vars to inner scope --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 8a5347a53..ff6a2939e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -190,9 +190,8 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr .modifierAltMeta = False, .keysym = NoSymbol }; - xmlAttr *attr; - for (attr = node->properties; attr; attr = attr->next) + for (xmlAttr *attr = node->properties; attr; attr = attr->next) { /* ignore attributes without data (which should never happen anyways) */ if (attr->children->content == NULL) @@ -482,7 +481,6 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) { enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; int keysyms_per_keycode_return; - struct nxagentSpecialKeystrokeMap *cur = map; XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, X->keycode, @@ -492,7 +490,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) #ifdef DEBUG fprintf(stderr, "%s: got keysym '%c' (%d)\n", __func__, keysym[0], keysym[0]); #endif - while (cur->stroke != KEYSTROKE_END_MARKER) { + for (struct nxagentSpecialKeystrokeMap *cur = map; cur->stroke != KEYSTROKE_END_MARKER; cur++) { #ifdef DEBUG fprintf(stderr, "%s: checking keysym '%c' (%d)\n", __func__, cur->keysym, cur->keysym); #endif @@ -503,7 +501,6 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) free(keysym); return cur->stroke; } - cur++; } free(keysym); -- cgit v1.2.3 From e3240d6b3f9f5dc9ddcd41c24a3c2fbc394c3735 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Mar 2017 23:48:46 +0100 Subject: keystrokes.cfg: remove debug keystrokes Normal builds will not contain support for some keystrokes but warn about unknown keystroke actions: Info: ignoring unknown keystroke action 'debug_tree'. Info: ignoring unknown keystroke action 'regions_on_screen'. Info: ignoring unknown keystroke action 'test_input'. Info: ignoring unknown keystroke action 'deactivate_input_devices_grab'. So we remove those from the default keystrokes config. --- etc/keystrokes.cfg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg index 2821034b6..1620e04d0 100644 --- a/etc/keystrokes.cfg +++ b/etc/keystrokes.cfg @@ -8,10 +8,6 @@ - - - - -- cgit v1.2.3 From 9f0713c0433ab7b95b301b1cc3118ef4dbc3d8a7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 27 Mar 2017 22:07:51 +0200 Subject: doc: document debugging keystrokes --- doc/nxagent/README.keystrokes | 6 ------ doc/nxagent/README.keystrokes.debug | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 doc/nxagent/README.keystrokes.debug diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index 96bc158d2..f9b4bf3a1 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -103,11 +103,5 @@ 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 Forces the drawing of elements to be synchronized which can fix some visual bugs. -debug_tree -regions_on_screen -test_input -deactivate_input_devices_grab diff --git a/doc/nxagent/README.keystrokes.debug b/doc/nxagent/README.keystrokes.debug new file mode 100644 index 000000000..85ec2613a --- /dev/null +++ b/doc/nxagent/README.keystrokes.debug @@ -0,0 +1,27 @@ +Configurable keybindings for debugging nxagent + +Some keystrokes are only available in special debug builds of nxagent +and will be ignored otherwise. These are + +debug_tree + Show the window trees of both internal and external + windows. Included if DEBUG_TREE is defined. + +regions_on_screen + Make corrupted regions visible. Included if DUMP is defined. + +test_input + Activate/deactive input device debugging. Included if NX_DEBUG_INPUT + is defined. + +deactivate_input_devices_grab + Release grab of input devices. Included if NX_DEBUG_INPUT is + defined. + +They can be configured by adding these lines to keystrokes.cfg, below +keystrokes represent the default: + + + + + -- cgit v1.2.3 From d28cf55743a5acadd0fa650a5559083c210449b8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 27 Mar 2017 22:46:47 +0200 Subject: doc: rework keystroke documentation --- doc/nxagent/README.keystrokes | 93 +++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index f9b4bf3a1..612e710cc 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -1,6 +1,6 @@ Configurable keybindings in nxagent -Keybindings in the redistributed x2go version of nxagent can now be configured +Keybindings in the redistributed x2go version of nxagent can be configured by the user. This is done via a configuration file. File location @@ -40,29 +40,31 @@ The configuration file is XML with the following format: -Each 'action' defines an action to be executed when receiving that keystroke. A -list of possible actions is given below. Some of those actions are only -available with debug builds of nxagent. +Each 'action' defines an action to be executed when receiving that +keystroke. A list of possible actions is given below. Some of those +actions are only available with debug builds of nxagent. Keys are given as a combination of 'key' and (optionally) a number of modifiers. The key attribute is evaluated into a X11 key via the usual XStringToKeysym function. A list of possible keys can be found in -/usr/include/X11/keysymdef.h, the names are specified without the leading -'XK_'. Evaluation is case-sensitive, so, 'space' and 'Escape' will work while -'Space' and 'escape' won't. +/usr/include/X11/keysymdef.h, the names are specified without the +leading 'XK_'. Evaluation is case-sensitive, so, 'space' and 'Escape' +will work while 'Space' and 'escape' won't. -Modifiers are given as boolean attributes, possible modifiers are Mod1, Mod2, -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. +Modifiers are given as boolean attributes, possible modifiers are +Mod1, Mod2, 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. Everything in this file is case-sensitive. Unknown lines are ignored. -Keybindings are evaluated from top to bottom, so if a keybinding matches, other -keybindings further down will be ignored. The contents of the file replaces the -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. +Keybindings are evaluated from top to bottom, so if a keybinding +matches, other keybindings further down will be ignored. The contents +of the file replaces the 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. @@ -71,37 +73,42 @@ 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. + 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. + 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 -up -right -down + This will minimize the client window (even for fullscreen sessions). + 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 (default) and viewport + mode. In viewport mode the xserver screen size stays static even + if the nxagent window is resized. You will possibly only see a part of + the screen and can scroll around using the following actions: +viewport_move_up/down + Moves the viewport up/down by the height of the visiable area. +viewport_move_left/right + Moves the viewport left/right by the width of the visible area. +up/down/left/right + Smoothly moves the viewport up/down/left/right with increasing step + size (maximum step size is 200px). + defer - activate/deactivate deferred screen updates. + Activates/deactivates deferred screen updates. + ignore - Makes it possible to add 'ignore', as in nothing happens when certain keys are pressed. -viewport_move_left - Moves the image viewport to the left. -viewport_move_up - Moves the image viewport up. -viewport_move_right - Moves the image viewport to the right. -viewport_move_down - Moves the image viewport down. + Ignores the following keystroke, nothing will happen when this + keystroke is pressed. + reread_keystrokes - forces nxagent to re-read the keystroke - configuration. Useful to add/changes keystrokes for a running - session. + Forces nxagent to re-read the keystroke configuration. Useful to + add/change keystrokes to a running session. + force_synchronization - Forces the drawing of elements to be synchronized which can fix some visual bugs. + Forces immediate drawing of elements to be synchronized which can + fix some visual bugs. -- cgit v1.2.3 From ee18cd43d873bc814ca40faabd29cc486061969f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 27 Mar 2017 22:58:38 +0200 Subject: Keystrokes: rename left/up/right/down keystrokes to descriptive names The are now called reflecting their purpose: viewport_scroll_left/up/right/down. This also regroups all the keystrokes referring to viewport stuff. --- doc/nxagent/README.keystrokes | 13 ++--- etc/keystrokes.cfg | 18 +++--- nx-X11/programs/Xserver/hw/nxagent/Events.c | 8 +-- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 78 +++++++++++++------------- nx-X11/programs/Xserver/hw/nxagent/Keystroke.h | 11 ++-- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes index 612e710cc..3d55f5096 100644 --- a/doc/nxagent/README.keystrokes +++ b/doc/nxagent/README.keystrokes @@ -90,13 +90,12 @@ resize mode. In viewport mode the xserver screen size stays static even if the nxagent window is resized. You will possibly only see a part of the screen and can scroll around using the following actions: -viewport_move_up/down - Moves the viewport up/down by the height of the visiable area. -viewport_move_left/right - Moves the viewport left/right by the width of the visible area. -up/down/left/right - Smoothly moves the viewport up/down/left/right with increasing step - size (maximum step size is 200px). +viewport_move_left/up/right/down + Moves the viewport left/up/right/down by the width resp. height of + the visible area. +viewport_scroll_left/up/right/down + Scrolls the viewport left/up/right/down with increasing speed + (maximum step size is 200px). defer Activates/deactivates deferred screen updates. diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg index 1620e04d0..b482119ad 100644 --- a/etc/keystrokes.cfg +++ b/etc/keystrokes.cfg @@ -4,10 +4,10 @@ - + @@ -16,13 +16,13 @@ - - - - - - - - + + + + + + + + diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index d8512b548..e4d031e06 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -180,6 +180,10 @@ static int viewportLastX; static int viewportLastY; static Cursor viewportCursor; +#define MAX_INC 200 +#define INC_STEP 5 +#define nextinc(x) ((x) < MAX_INC ? (x) += INC_STEP : (x)) + /* * Keyboard and pointer are handled as they were real devices by * Xnest and we inherit this behaviour. The following mask will @@ -193,10 +197,6 @@ static Mask defaultEventMask; static int lastEventSerial = 0; -#define MAX_INC 200 -#define INC_STEP 5 -#define nextinc(x) ((x) < MAX_INC ? (x) += INC_STEP : (x)) - /* * Used to mask the appropriate bits in * the state reported by XkbStateNotify diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index ff6a2939e..ef7b0b27f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -75,11 +75,6 @@ char * nxagentSpecialKeystrokeNames[] = { "switch_all_screens", "fullscreen", "minimize", - "left", - "up", - "right", - "down", - "resize", "defer", "ignore", "force_synchronization", @@ -94,10 +89,15 @@ char * nxagentSpecialKeystrokeNames[] = { "test_input", "deactivate_input_devices_grab", #endif + "resize", "viewport_move_left", "viewport_move_up", "viewport_move_right", "viewport_move_down", + "viewport_scroll_left", + "viewport_scroll_up", + "viewport_scroll_right", + "viewport_scroll_down", "reread_keystrokes", NULL, @@ -112,15 +112,6 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_SWITCH_ALL_SCREENS, ControlMask, True, XK_f}, {KEYSTROKE_FULLSCREEN, ControlMask | ShiftMask, True, XK_f}, {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_DEFER, ControlMask, True, XK_e}, {KEYSTROKE_IGNORE, ControlMask, True, XK_BackSpace}, {KEYSTROKE_IGNORE, 0, False, XK_Terminate_Server}, @@ -132,6 +123,7 @@ struct nxagentSpecialKeystrokeMap default_map[] = { {KEYSTROKE_TEST_INPUT, ControlMask, True, XK_x}, {KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, ControlMask, True, XK_y}, #endif + {KEYSTROKE_RESIZE, ControlMask, True, XK_r}, {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}, @@ -140,6 +132,14 @@ 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_VIEWPORT_SCROLL_LEFT, ControlMask, True, XK_Left}, + {KEYSTROKE_VIEWPORT_SCROLL_LEFT, ControlMask, True, XK_KP_Left}, + {KEYSTROKE_VIEWPORT_SCROLL_UP, ControlMask, True, XK_Up}, + {KEYSTROKE_VIEWPORT_SCROLL_UP, ControlMask, True, XK_KP_Up}, + {KEYSTROKE_VIEWPORT_SCROLL_RIGHT, ControlMask, True, XK_Right}, + {KEYSTROKE_VIEWPORT_SCROLL_RIGHT, ControlMask, True, XK_KP_Right}, + {KEYSTROKE_VIEWPORT_SCROLL_DOWN, ControlMask, True, XK_Down}, + {KEYSTROKE_VIEWPORT_SCROLL_DOWN, ControlMask, True, XK_KP_Down}, {KEYSTROKE_REREAD_KEYSTROKES, ControlMask, True, XK_k}, {KEYSTROKE_END_MARKER, 0, False, NoSymbol}, }; @@ -559,31 +559,6 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doMinimize; } break; - case KEYSTROKE_LEFT: - if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { - *result = doViewportLeft; - } - break; - case KEYSTROKE_UP: - if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { - *result = doViewportUp; - } - break; - case KEYSTROKE_RIGHT: - if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { - *result = doViewportRight; - } - break; - case KEYSTROKE_DOWN: - if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { - *result = doViewportDown; - } - break; - case KEYSTROKE_RESIZE: - if (!nxagentOption(Rootless)) { - *result = doSwitchResizeMode; - } - break; case KEYSTROKE_DEFER: *result = doSwitchDeferMode; break; @@ -628,6 +603,11 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doSwitchFullscreen; } break; + case KEYSTROKE_RESIZE: + if (!nxagentOption(Rootless)) { + *result = doSwitchResizeMode; + } + break; case KEYSTROKE_VIEWPORT_MOVE_LEFT: if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { *result = doViewportMoveLeft; @@ -648,6 +628,26 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) *result = doViewportMoveDown; } break; + case KEYSTROKE_VIEWPORT_SCROLL_LEFT: + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { + *result = doViewportLeft; + } + break; + case KEYSTROKE_VIEWPORT_SCROLL_UP: + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { + *result = doViewportUp; + } + break; + case KEYSTROKE_VIEWPORT_SCROLL_RIGHT: + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { + *result = doViewportRight; + } + break; + case KEYSTROKE_VIEWPORT_SCROLL_DOWN: + if (!nxagentOption(Rootless) && !nxagentOption(DesktopResize)) { + *result = doViewportDown; + } + break; case KEYSTROKE_REREAD_KEYSTROKES: /* two reasons to check on KeyRelease: - this code is called for KeyPress and KeyRelease, so we diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h index 7eb71bb6f..13a83d0fe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h @@ -44,11 +44,6 @@ enum nxagentSpecialKeystroke { KEYSTROKE_SWITCH_ALL_SCREENS, KEYSTROKE_FULLSCREEN, KEYSTROKE_MINIMIZE, - KEYSTROKE_LEFT, - KEYSTROKE_UP, - KEYSTROKE_RIGHT, - KEYSTROKE_DOWN, - KEYSTROKE_RESIZE, KEYSTROKE_DEFER, KEYSTROKE_IGNORE, KEYSTROKE_FORCE_SYNCHRONIZATION, @@ -65,10 +60,16 @@ enum nxagentSpecialKeystroke { KEYSTROKE_DEACTIVATE_INPUT_DEVICES_GRAB, #endif + /* all the viewport stuff */ + KEYSTROKE_RESIZE, KEYSTROKE_VIEWPORT_MOVE_LEFT, KEYSTROKE_VIEWPORT_MOVE_UP, KEYSTROKE_VIEWPORT_MOVE_RIGHT, KEYSTROKE_VIEWPORT_MOVE_DOWN, + KEYSTROKE_VIEWPORT_SCROLL_LEFT, + KEYSTROKE_VIEWPORT_SCROLL_UP, + KEYSTROKE_VIEWPORT_SCROLL_RIGHT, + KEYSTROKE_VIEWPORT_SCROLL_DOWN, KEYSTROKE_REREAD_KEYSTROKES, -- cgit v1.2.3