Commit ba5183f8 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Init keystrokes at startup and reconnect

no more late initialization
parent f12012b1
...@@ -69,6 +69,7 @@ is" without express or implied warranty. ...@@ -69,6 +69,7 @@ is" without express or implied warranty.
#include "Font.h" #include "Font.h"
#include "Millis.h" #include "Millis.h"
#include "Error.h" #include "Error.h"
#include "Keystroke.h"
#include <nx/NX.h> #include <nx/NX.h>
#include "compext/Compext.h" #include "compext/Compext.h"
...@@ -406,6 +407,8 @@ FIXME: These variables, if not removed at all because have probably ...@@ -406,6 +407,8 @@ FIXME: These variables, if not removed at all because have probably
*/ */
blackRoot = TRUE; blackRoot = TRUE;
nxagentInitKeystrokes(False);
} }
void void
......
...@@ -265,7 +265,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr ...@@ -265,7 +265,7 @@ static Bool read_binding_from_xmlnode(xmlNode *node, struct nxagentSpecialKeystr
* - hardcoded traditional NX default settings * - hardcoded traditional NX default settings
* If run in x2go flavour different filenames and varnames are used. * 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; char *filename = NULL;
...@@ -482,13 +482,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) ...@@ -482,13 +482,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X)
{ {
enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING; enum nxagentSpecialKeystroke ret = KEYSTROKE_NOTHING;
int keysyms_per_keycode_return; int keysyms_per_keycode_return;
struct nxagentSpecialKeystrokeMap *cur; struct nxagentSpecialKeystrokeMap *cur = map;
/* FIXME: we do late parsing here, this should be done at startup,
not at first keypress! */
parse_keystroke_file(False);
cur = map;
XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay, XlibKeySym *keysym = XGetKeyboardMapping(nxagentDisplay,
X->keycode, X->keycode,
...@@ -665,7 +659,7 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) ...@@ -665,7 +659,7 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result)
might lead to unexpected behaviour might lead to unexpected behaviour
*/ */
if (X->type == KeyRelease) if (X->type == KeyRelease)
parse_keystroke_file(True); nxagentInitKeystrokes(True);
break; break;
case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */ case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */
case KEYSTROKE_END_MARKER: /* just to make gcc STFU */ case KEYSTROKE_END_MARKER: /* just to make gcc STFU */
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*); extern Bool nxagentCheckSpecialKeystroke(XKeyEvent*, enum HandleEventResult*);
extern void nxagentDumpKeystrokes(void); 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 /* 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 */ * that KEYSTROKE_MAX may be used in a malloc */
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "Millis.h" #include "Millis.h"
#include "Splash.h" #include "Splash.h"
#include "Error.h" #include "Error.h"
#include "Keystroke.h"
#ifdef XKB #ifdef XKB
#include "XKBsrv.h" #include "XKBsrv.h"
...@@ -646,6 +647,10 @@ Bool nxagentReconnectSession(void) ...@@ -646,6 +647,10 @@ Bool nxagentReconnectSession(void)
goto nxagentReconnectError; goto nxagentReconnectError;
} }
/* Re-read keystrokes definitions in case the keystrokes file has
changed while being supended */
nxagentInitKeystrokes(True);
#ifdef NX_DEBUG_INPUT #ifdef NX_DEBUG_INPUT
fprintf(stderr, "Session: Session resumed at '%s' timestamp [%lu].\n", GetTimeAsString(), GetTimeInMillis()); fprintf(stderr, "Session: Session resumed at '%s' timestamp [%lu].\n", GetTimeAsString(), GetTimeInMillis());
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment