aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-12-14 00:09:35 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-12-14 00:09:35 +0100
commitabaebb5b1da233b1b5dcab5da9c24e49960a68d3 (patch)
treef4dbab796b4356e865ca573214757b173bb4f873
parent7610c0f19e01f2815966b1e333d65c8ab748bd1f (diff)
parenta02b645b23c912f064f40b7f06a4447dd0f83e97 (diff)
downloadnx-libs-abaebb5b1da233b1b5dcab5da9c24e49960a68d3.tar.gz
nx-libs-abaebb5b1da233b1b5dcab5da9c24e49960a68d3.tar.bz2
nx-libs-abaebb5b1da233b1b5dcab5da9c24e49960a68d3.zip
Merge branch 'uli42-pr/improve_keyboard_light' into 3.6.x
Attributes GH PR #591: https://github.com/ArcticaProject/nx-libs/pull/591
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c40
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.h4
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c209
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/man/nxagent.141
4 files changed, 181 insertions, 113 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index d1fdfd21e..61d39ee98 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -1168,7 +1168,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
nxagentXkbNumTrap = 1;
}
- nxagentInitKeyboardState();
+ nxagentInitXkbKeyboardState();
nxagentXkbCapsTrap = 0;
nxagentXkbNumTrap = 0;
@@ -2079,7 +2079,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
* state modification event.
*/
- if (nxagentHandleKeyboardEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0)
+ if (nxagentHandleXkbKeyboardStateEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0)
{
#ifdef TEST
fprintf(stderr, "nxagentDispatchEvents: WARNING! Unhandled event code [%d].\n",
@@ -2318,7 +2318,7 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result)
nxagentXkbNumTrap = 1;
}
- nxagentInitKeyboardState();
+ nxagentInitXkbKeyboardState();
nxagentXkbCapsTrap = 0;
nxagentXkbNumTrap = 0;
@@ -2785,22 +2785,22 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
return 1;
}
-int nxagentHandleKeyboardEvent(XEvent *X)
+int nxagentHandleXkbKeyboardStateEvent(XEvent *X)
{
XkbEvent *xkbev = (XkbEvent *) X;
- #ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Handling event with caps [%d] num [%d] locked [%d].\n",
- nxagentXkbState.Caps, nxagentXkbState.Num, nxagentXkbState.Locked);
- #endif
-
if (xkbev -> type == nxagentXkbInfo.EventBase + XkbEventCode &&
xkbev -> any.xkb_type == XkbStateNotify)
{
+ #ifdef TEST
+ fprintf(stderr, "%s: Handling event with caps [%d] num [%d] locked [%d].\n", __func__,
+ nxagentXkbState.Caps, nxagentXkbState.Num, nxagentXkbState.Locked);
+ #endif
+
nxagentXkbState.Locked = xkbev -> state.locked_mods;
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Updated XKB locked modifier bits to [%x].\n",
+ fprintf(stderr, "%s: Updated XKB locked modifier bits to [%x].\n", __func__,
nxagentXkbState.Locked);
#endif
@@ -2812,7 +2812,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentXkbState.Caps = 1;
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [66] to engage capslock.\n");
+ fprintf(stderr, "%s: Sending fake key [66] to engage capslock.\n", __func__);
#endif
if (!nxagentXkbCapsTrap)
@@ -2827,7 +2827,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentXkbState.Caps = 0;
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [66] to release capslock.\n");
+ fprintf(stderr, "%s: Sending fake key [66] to release capslock.\n", __func__);
#endif
nxagentSendFakeKey(66);
@@ -2839,7 +2839,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [66] to release capslock.\n");
+ fprintf(stderr, "%s: Sending fake key [66] to release capslock.\n", __func__);
#endif
nxagentSendFakeKey(66);
@@ -2851,7 +2851,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentXkbState.Num = 1;
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [77] to engage numlock.\n");
+ fprintf(stderr, "%s: Sending fake key [77] to engage numlock.\n", __func__);
#endif
if (!nxagentXkbNumTrap)
@@ -2866,7 +2866,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentXkbState.Num = 0;
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [77] to release numlock.\n");
+ fprintf(stderr, "%s: Sending fake key [77] to release numlock.\n", __func__);
#endif
nxagentSendFakeKey(77);
@@ -2878,7 +2878,7 @@ int nxagentHandleKeyboardEvent(XEvent *X)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [77] to release numlock.\n");
+ fprintf(stderr, "%s: Sending fake key [77] to release numlock.\n", __func__);
#endif
nxagentSendFakeKey(77);
@@ -3792,7 +3792,7 @@ void nxagentSendFakeKey(int key)
mieqEnqueue(&fake);
}
-int nxagentInitKeyboardState()
+int nxagentInitXkbKeyboardState()
{
XEvent X;
@@ -3801,7 +3801,7 @@ int nxagentInitKeyboardState()
XkbEvent *xkbev = (XkbEvent *) &X;
#ifdef TEST
- fprintf(stderr, "nxagentInitKeyboardState: Initializing XKB state.\n");
+ fprintf(stderr, "%s: Initializing XKB state.\n", __func__);
#endif
memset(&X, 0, sizeof(XEvent));
@@ -3821,14 +3821,14 @@ int nxagentInitKeyboardState()
}
#ifdef TEST
- fprintf(stderr, "nxagentInitKeyboardState: Assuming XKB locked modifier bits [%x].\n",
+ fprintf(stderr, "%s: Assuming XKB locked modifier bits [%x].\n", __func__,
xkbev -> state.locked_mods);
#endif
xkbev -> type = nxagentXkbInfo.EventBase + XkbEventCode;
xkbev -> any.xkb_type = XkbStateNotify;
- nxagentHandleKeyboardEvent(&X);
+ nxagentHandleXkbKeyboardStateEvent(&X);
return 1;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.h b/nx-X11/programs/Xserver/hw/nxagent/Events.h
index 7d313c331..bf9d10c74 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.h
@@ -99,7 +99,7 @@ extern void nxagentGetEventMask(WindowPtr pWin, Mask *mask_return);
* the internal state. This is unlikely to happen.
*/
-extern int nxagentInitKeyboardState(void);
+extern int nxagentInitXkbKeyboardState(void);
/*
* Update the keyboard state according
@@ -107,7 +107,7 @@ extern int nxagentInitKeyboardState(void);
* from the remote X server.
*/
-extern int nxagentHandleKeyboardEvent(XEvent *X);
+extern int nxagentHandleXkbKeyboardStateEvent(XEvent *X);
/*
* Handle sync and karma messages and
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 51f57a897..8ae64ee00 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -556,11 +556,17 @@ static char *nxagentXkbGetRules()
strcpy(path, XkbBaseDirectory);
strcat(path, "/rules/");
strcat(path, XKB_DFLT_RULES_FILE);
+ #ifdef TEST
+ fprintf(stderr, "nxagentXkbGetRules: checking rules file [%s]\n", path);
+ #endif
ret = stat(path, &buf);
if (ret == 0)
{
free(path);
+ #ifdef TEST
+ fprintf(stderr, "nxagentXkbGetRules: returning default rules file [%s]\n", XKB_DFLT_RULES_FILE);
+ #endif
return XKB_DFLT_RULES_FILE;
}
@@ -571,11 +577,17 @@ static char *nxagentXkbGetRules()
strcpy(path, XkbBaseDirectory);
strcat(path, "/rules/");
strcat(path, XKB_ALTS_RULES_FILE);
+ #ifdef TEST
+ fprintf(stderr, "nxagentXkbGetRules: checking rules file [%s]\n", path);
+ #endif
ret = stat(path, &buf);
if (ret == 0)
{
free(path);
+ #ifdef TEST
+ fprintf(stderr, "nxagentXkbGetRules: returning alternative rules file [%s]\n", XKB_ALTS_RULES_FILE);
+ #endif
return XKB_ALTS_RULES_FILE;
}
@@ -584,6 +596,9 @@ static char *nxagentXkbGetRules()
#endif
free(path);
+ #ifdef TEST
+ fprintf(stderr, "nxagentXkbGetRules: returning default rules file [%s]\n", XKB_DFLT_RULES_FILE);
+ #endif
return XKB_DFLT_RULES_FILE;
}
@@ -632,11 +647,10 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
* devices attached to the real X server.
*/
- if (nxagentOption(DeviceControl) == True)
+ if (nxagentOption(DeviceControl))
{
unsigned long value_mask;
XKeyboardControl values;
- int i;
#ifdef TEST
fprintf(stderr, "nxagentChangeKeyboardControl: WARNING! Propagating changes to keyboard settings.\n");
@@ -671,7 +685,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
value_mask = KBLed | KBLedMode;
- for (i = 1; i <= 32; i++)
+ for (int i = 1; i <= 32; i++)
{
values.led = i;
values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff;
@@ -740,7 +754,7 @@ N/A
XkbDfltRepeatInterval = ~ 0;
#ifdef TEST
- fprintf(stderr, "nxagentKeyboardProc: Set repeat delay to [%u] interval to [%u].\n",
+ fprintf(stderr, "nxagentKeyboardProc: Set repeat delay to [%d] interval to [%d].\n",
XkbDfltRepeatDelay, XkbDfltRepeatInterval);
#endif
@@ -855,31 +869,31 @@ XkbError:
free(layout);
}
#endif
- XGetKeyboardControl(nxagentDisplay, &values);
+ XGetKeyboardControl(nxagentDisplay, &values);
- memmove((char *) defaultKeyboardControl.autoRepeats,
- (char *) values.auto_repeats, sizeof(values.auto_repeats));
+ memmove((char *) defaultKeyboardControl.autoRepeats,
+ (char *) values.auto_repeats, sizeof(values.auto_repeats));
- #ifdef TEST
- {
- int ret =
- #endif
- InitKeyboardDeviceStruct((DevicePtr) pDev, &keySyms, modmap,
- nxagentBell, nxagentChangeKeyboardControl);
+ #ifdef TEST
+ {
+ int ret =
+ #endif
+ InitKeyboardDeviceStruct((DevicePtr) pDev, &keySyms, modmap,
+ nxagentBell, nxagentChangeKeyboardControl);
- #ifdef TEST
- fprintf(stderr, "nxagentKeyboardProc: InitKeyboardDeviceStruct returns [%d].\n", ret);
- }
- #endif
+ #ifdef TEST
+ fprintf(stderr, "nxagentKeyboardProc: InitKeyboardDeviceStruct returns [%d].\n", ret);
+ }
+ #endif
#ifdef XKB
- } else {
+ } else { /* if (noXkbExtension) */
FILE *file;
XkbConfigRtrnRec config;
char *nxagentXkbConfigFilePath;
- XkbComponentNamesRec names;
+ XkbComponentNamesRec names = {0};
char *rules, *variants, *options;
#ifdef TEST
@@ -890,11 +904,21 @@ XkbError:
fprintf(stderr, "nxagentKeyboardProc: nxagentKeyboard is [%s].\n", nxagentKeyboard ? nxagentKeyboard : "NULL");
#endif
- memset(&names, 0, sizeof(XkbComponentNamesRec));
rules = nxagentXkbGetRules();
- if ((nxagentKeyboard != NULL) && (strcmp(nxagentKeyboard, "query") != 0))
+ /*
+ from nxagent changelog:
+ 2.0.22:
+ - Implemented handling of value "query" for nxagentKbtype. This value
+ is passed by the NX client for MacOSX. If value of nxagentKbtype is
+ "query" or NULL we init keyboard by core protocol functions reading
+ the keyboard mapping of the X server. The property _XKB_RULES_NAMES
+ is always set on the root window with default values of model and
+ layout.
+ */
+
+ if (nxagentKeyboard && (strcmp(nxagentKeyboard, "query") != 0))
{
for (i = 0; nxagentKeyboard[i] != '/' && nxagentKeyboard[i] != 0; i++);
@@ -951,7 +975,7 @@ XkbError:
options = XKB_DFLT_KB_OPTIONS;
#ifdef TEST
- fprintf(stderr, "nxagentKeyboardProc: XkbInitialMap [%s]\n", XkbInitialMap ? XkbInitialMap : "NULL");
+ fprintf(stderr, "nxagentKeyboardProc: XkbInitialMap (option -xkbmap) is [%s]\n", XkbInitialMap ? XkbInitialMap : "NULL");
#endif
if (XkbInitialMap) {
@@ -1020,7 +1044,7 @@ XkbError:
else
nxagentXkbConfigFilePath = strdup(XKB_CONFIG_FILE_NX);
- if (nxagentXkbConfigFilePath == NULL)
+ if (!nxagentXkbConfigFilePath)
{
FatalError("nxagentKeyboardProc: malloc failed.");
}
@@ -1030,7 +1054,7 @@ XkbError:
nxagentXkbConfigFilePath);
#endif
- if ((file = fopen(nxagentXkbConfigFilePath, "r")) != NULL) {
+ if ((file = fopen(nxagentXkbConfigFilePath, "r"))) {
#ifdef TEST
fprintf(stderr, "nxagentKeyboardProc: Going to parse config file.\n");
@@ -1040,6 +1064,7 @@ XkbError:
ErrorF("Error parsing config file.\n");
free(nxagentXkbConfigFilePath);
+ nxagentXkbConfigFilePath = NULL;
fclose(file);
goto XkbError;
@@ -1070,6 +1095,7 @@ XkbError:
options = config.options;
free(nxagentXkbConfigFilePath);
+ nxagentXkbConfigFilePath = NULL;
fclose(file);
}
@@ -1089,6 +1115,7 @@ XkbError:
nxagentBell, nxagentChangeKeyboardControl);
free(nxagentXkbConfigFilePath);
+ nxagentXkbConfigFilePath = NULL;
if (!nxagentKeyboard || strcmp(nxagentKeyboard, "query") == 0)
{
@@ -1103,8 +1130,8 @@ XkbError:
#endif
#ifdef DEBUG
fprintf(stderr, "nxagentKeyboardProc: Going to set rules and init device: "
- "[rules='%s',model='%s',layout='%s',variants='%s',options='%s'].\n",
- rules, model, layout, variants, options);
+ "[rules='%s',model='%s',layout='%s',variants='%s',options='%s'].\n",
+ rules, model, layout, variants, options);
#endif
XkbSetRulesDflts(rules, model, layout, variants, options);
@@ -1229,11 +1256,10 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode)
if (!noXkbExtension)
{
DeviceIntPtr dev;
- xkbNewKeyboardNotify nkn;
+ xkbNewKeyboardNotify nkn = {0};
dev = inputInfo.keyboard;
- memset(&nkn, 0, sizeof(xkbNewKeyboardNotify));
nkn.deviceID = nkn.oldDeviceID = dev -> id;
nkn.minKeyCode = 8;
nkn.maxKeyCode = 255;
@@ -1251,9 +1277,8 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode)
#endif
int i;
- xEvent event;
+ xEvent event = {0};
- memset(&event, 0, sizeof(xEvent));
event.u.u.type = MappingNotify;
event.u.mappingNotify.request = MappingKeyboard;
event.u.mappingNotify.firstKeyCode = inputInfo.keyboard -> key -> curKeySyms.minKeyCode;
@@ -1312,18 +1337,12 @@ int nxagentResetKeyboard(void)
savedBellPercent, savedBellPitch, savedBellDuration);
#endif
- devBackup = malloc(sizeof(DeviceIntRec));
-
- if (devBackup == NULL)
+ if (!(devBackup = calloc(1, sizeof(DeviceIntRec))))
{
#ifdef PANIC
- fprintf(stderr, "nxagentSaveKeyboardDeviceData: PANIC! Can't allocate backup structure.\n");
+ fprintf(stderr, "nxagentResetKeyboard: PANIC! Can't allocate backup structure.\n");
#endif
}
- else
- {
- memset(devBackup, 0, sizeof(DeviceIntRec));
- }
nxagentSaveKeyboardDeviceData(dev, devBackup);
@@ -1423,7 +1442,6 @@ void nxagentCheckModifierMasks(CARD8 keycode, int j)
void nxagentCheckRemoteKeycodes()
{
nxagentCapsLockKeycode = XKeysymToKeycode(nxagentDisplay, XK_Caps_Lock);
-
nxagentNumLockKeycode = XKeysymToKeycode(nxagentDisplay, XK_Num_Lock);
#ifdef DEBUG
@@ -1435,7 +1453,7 @@ void nxagentCheckRemoteKeycodes()
static int nxagentSaveKeyboardDeviceData(DeviceIntPtr dev, DeviceIntPtr devBackup)
{
- if (devBackup == NULL)
+ if (!devBackup)
{
#ifdef PANIC
fprintf(stderr, "nxagentSaveKeyboardDeviceData: PANIC! Pointer to backup structure is null.\n");
@@ -1444,10 +1462,8 @@ static int nxagentSaveKeyboardDeviceData(DeviceIntPtr dev, DeviceIntPtr devBacku
return -1;
}
- devBackup -> key = dev -> key;
-
- devBackup -> focus = dev -> focus;
-
+ devBackup -> key = dev -> key;
+ devBackup -> focus = dev -> focus;
devBackup -> kbdfeed = dev -> kbdfeed;
#ifdef DEBUG
@@ -1459,7 +1475,7 @@ static int nxagentSaveKeyboardDeviceData(DeviceIntPtr dev, DeviceIntPtr devBacku
static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr dev)
{
- if (devBackup == NULL)
+ if (!devBackup)
{
#ifdef PANIC
fprintf(stderr, "nxagentRestoreKeyboardDeviceData: PANIC! Pointer to backup structure is null.\n");
@@ -1468,10 +1484,8 @@ static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr
return -1;
}
- dev -> key = devBackup -> key;
-
- dev -> focus = devBackup -> focus;
-
+ dev -> key = devBackup -> key;
+ dev -> focus = devBackup -> focus;
dev -> kbdfeed = devBackup -> kbdfeed;
#ifdef DEBUG
@@ -1486,7 +1500,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
{
KbdFeedbackPtr k, knext;
- if (dev == NULL)
+ if (!dev)
{
#ifdef PANIC
fprintf(stderr, "nxagentFreeKeyboardDeviceData: PANIC! Pointer to device structure is null.\n");
@@ -1509,14 +1523,14 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
free(dev->key->modifierKeyMap);
free(dev->key);
- dev->key=NULL;
+ dev->key = NULL;
}
if (dev->focus)
{
free(dev->focus->trace);
free(dev->focus);
- dev->focus=NULL;
+ dev->focus = NULL;
}
for (k = dev->kbdfeed; k; k = knext)
@@ -1582,11 +1596,31 @@ int ProcXkbInhibited(register ClientPtr client)
{
return BadAccess;
}
- default:
+ case X_kbBell:
+ case X_kbGetCompatMap:
+ case X_kbGetControls:
+ case X_kbGetDeviceInfo:
+ case X_kbGetGeometry:
+ case X_kbGetIndicatorMap:
+ case X_kbGetIndicatorState:
+ case X_kbGetMap:
+ case X_kbGetNamedIndicator:
+ case X_kbGetNames:
+ case X_kbGetState:
+ case X_kbListComponents:
+ case X_kbPerClientFlags:
+ case X_kbSelectEvents:
+ case X_kbSetDeviceInfo:
+ case X_kbUseExtension:
{
return (client->swapped ? nxagentXkbWrapper.SProcXkbDispatchBackup(client) :
nxagentXkbWrapper.ProcXkbDispatchBackup(client));
}
+ default:
+ {
+ /* Just make sure that it works in case xkb gets extended in future */
+ return BadImplementation;
+ }
}
}
@@ -1598,7 +1632,7 @@ void nxagentInitXkbWrapper(void)
fprintf(stderr, "nxagentInitXkbWrapper: Called.\n");
#endif
- if (nxagentOption(InhibitXkb) == 0)
+ if (!nxagentOption(InhibitXkb))
{
#ifdef TEST
fprintf(stderr, "nxagentInitXkbWrapper: Nothing to do.\n");
@@ -1609,9 +1643,7 @@ void nxagentInitXkbWrapper(void)
memset(&nxagentXkbWrapper, 0, sizeof(XkbWrapperRec));
- extension = CheckExtension("XKEYBOARD");
-
- if (extension != NULL)
+ if ((extension = CheckExtension("XKEYBOARD")))
{
nxagentXkbWrapper.base = extension -> base;
nxagentXkbWrapper.eventBase = extension -> eventBase;
@@ -1642,9 +1674,9 @@ void nxagentDisableXkbExtension(void)
if (nxagentXkbWrapper.base > 0)
{
- if (nxagentXkbWrapper.ProcXkbDispatchBackup == NULL)
+ if (!nxagentXkbWrapper.ProcXkbDispatchBackup)
{
- nxagentXkbWrapper.ProcXkbDispatchBackup = ProcVector[nxagentXkbWrapper.base];
+ nxagentXkbWrapper.ProcXkbDispatchBackup = ProcVector[nxagentXkbWrapper.base];
ProcVector[nxagentXkbWrapper.base] = ProcXkbInhibited;
}
@@ -1655,7 +1687,7 @@ void nxagentDisableXkbExtension(void)
}
#endif
- if (nxagentXkbWrapper.SProcXkbDispatchBackup == NULL)
+ if (!nxagentXkbWrapper.SProcXkbDispatchBackup)
{
nxagentXkbWrapper.SProcXkbDispatchBackup = SwappedProcVector[nxagentXkbWrapper.base];
@@ -1678,7 +1710,7 @@ void nxagentEnableXkbExtension(void)
if (nxagentXkbWrapper.base > 0)
{
- if (nxagentXkbWrapper.ProcXkbDispatchBackup != NULL)
+ if (nxagentXkbWrapper.ProcXkbDispatchBackup)
{
ProcVector[nxagentXkbWrapper.base] = nxagentXkbWrapper.ProcXkbDispatchBackup;
@@ -1691,7 +1723,7 @@ void nxagentEnableXkbExtension(void)
}
#endif
- if (nxagentXkbWrapper.SProcXkbDispatchBackup != NULL)
+ if (nxagentXkbWrapper.SProcXkbDispatchBackup)
{
SwappedProcVector[nxagentXkbWrapper.base] = nxagentXkbWrapper.SProcXkbDispatchBackup;
@@ -1706,9 +1738,19 @@ void nxagentEnableXkbExtension(void)
}
}
+/*
+ from nxagent-3.0.0-88 changelog:
+
+ - Fixed TR10D01539. Some XKEYBOARD requests are disabled if the option
+ 'keyboard' has value 'query'. This locks the initial keyboard map.
+ Enabling/disabling of XKEYBOARD requests is done at run time.
+
+ - Added -noxkblock command line option enabling the XKEYBOARD requests
+ even if the option 'keyboard' value is 'query'.
+*/
void nxagentTuneXkbWrapper(void)
{
- if (nxagentOption(InhibitXkb) == 0)
+ if (!nxagentOption(InhibitXkb))
{
#ifdef TEST
fprintf(stderr, "nxagentTuneXkbWrapper: Nothing to do.\n");
@@ -1717,8 +1759,7 @@ void nxagentTuneXkbWrapper(void)
return;
}
- if (nxagentKeyboard != NULL &&
- strcmp(nxagentKeyboard, "query") == 0)
+ if (nxagentKeyboard && strcmp(nxagentKeyboard, "query") == 0)
{
nxagentDisableXkbExtension();
}
@@ -1763,14 +1804,14 @@ static int nxagentXkbGetNames(char **rules, char **model, char **layout,
atom, 0, 256, 0, XA_STRING, &type, &format,
&n, &after, (unsigned char **)&data);
- if (result !=Success || data == NULL)
+ if (result != Success || !data)
{
return 0;
}
if ((after > 0) || (type != XA_STRING) || (format != 8))
{
- if (data != NULL)
+ if (data)
{
XFree(data);
return 0;
@@ -1781,7 +1822,7 @@ static int nxagentXkbGetNames(char **rules, char **model, char **layout,
if (name < data + n)
{
- *rules = name;
+ *rules = name;
name += strlen(name) + 1;
}
@@ -1840,7 +1881,7 @@ void nxagentKeycodeConversionSetup(void)
&dvariant, &doptions);
#ifdef DEBUG
- if (drulesLen != 0 && drules != NULL && dmodel != NULL)
+ if (drulesLen != 0 && drules && dmodel)
{
fprintf(stderr, "nxagentKeycodeConversionSetup: "
"Remote: [rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n",
@@ -1856,49 +1897,49 @@ void nxagentKeycodeConversionSetup(void)
if (drulesLen != 0)
{
char *sessionpath = nxagentGetSessionPath();
- if (sessionpath != NULL)
+ if (sessionpath)
{
int keyboard_file_path_size = strlen(sessionpath) + strlen("/keyboard");
char *keyboard_file_path = malloc((keyboard_file_path_size + 1) * sizeof(char));
FILE *keyboard_file;
- if (keyboard_file_path == NULL)
+ if (!keyboard_file_path)
{
FatalError("nxagentKeycodeConversionSetup: malloc failed.");
}
strcpy(keyboard_file_path, sessionpath);
strcat(keyboard_file_path, "/keyboard");
- if ((keyboard_file = fopen(keyboard_file_path, "w")) != NULL) {
- if (drules != NULL)
+ if ((keyboard_file = fopen(keyboard_file_path, "w"))) {
+ if (drules)
fprintf(keyboard_file, "rules=\"%s\"\n", drules[0] == '\0' ? "," : drules);
- if (dmodel != NULL)
+ if (dmodel)
fprintf(keyboard_file, "model=\"%s\"\n", dmodel[0] == '\0' ? "," : dmodel);
- if (dlayout != NULL)
+ if (dlayout)
fprintf(keyboard_file, "layout=\"%s\"\n", dlayout[0] == '\0' ? "," : dlayout);
- if (dvariant != NULL)
+ if (dvariant)
fprintf(keyboard_file, "variant=\"%s\"\n", dvariant[0] == '\0' ? "," : dvariant);
- if (doptions != NULL)
+ if (doptions)
fprintf(keyboard_file, "options=\"%s\"\n", doptions[0] == '\0' ? "," : doptions);
fclose(keyboard_file);
- fprintf(stderr, "keyboard file created\n");
+ fprintf(stderr, "Info: keyboard file created\n");
}
else
{
int save_err = errno;
- fprintf(stderr, "keyboard file not created: %s\n", strerror(save_err));
+ fprintf(stderr, "Error: keyboard file not created: %s\n", strerror(save_err));
}
free(keyboard_file_path);
}
else
{
- fprintf(stderr, "SessionPath not defined\n");
+ fprintf(stderr, "Warning: SessionPath not defined\n");
}
}
else
{
- fprintf(stderr, "Failed to create the keyboard file\n");
+ fprintf(stderr, "Warning: Failed to create the keyboard file\n");
}
- if (drules != NULL && dmodel != NULL &&
+ if (drules && dmodel &&
(strcmp(drules, "evdev") == 0 ||
strcmp(dmodel, "evdev") == 0))
{
@@ -1915,7 +1956,7 @@ void nxagentKeycodeConversionSetup(void)
fprintf(stderr, "Info: Keycode conversion auto-determined as off\n");
}
- if (drules != NULL)
+ if (drules)
{
XFree(drules);
}
@@ -1945,4 +1986,4 @@ void nxagentResetKeycodeConversion(void)
}
}
-#endif
+#endif /* XKB */
diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
index f28c1616f..a46974104 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
+++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
@@ -421,13 +421,19 @@ disable use of shared pixmaps
enable use of shared pixmaps
.TP 8
.B \-noignore
-don't ignore pointer and keyboard configuration changes mandated by clients
+don't ignore pointer and keyboard configuration changes mandated by
+clients. As a result, configuration commands like disabling the
+keyboard bell (xset -b) will also affect the real X server.
.TP 8
.B \-nokbreset
don't reset keyboard device if the session is resumed
.TP 8
.B \-noxkblock
-always allow applications to change layout through XKEYBOARD
+this is only relevant if you also specify \-keyboard=query. In that
+case \fBnxagent\fR will lock the keyboard settings and clients will
+get an error when trying to change keyboard settings via
+XKEYBOARD. With \-noxkblock the lock is not applied and clients can
+change the keyboard settings through XKEYBOARD.
.TP 8
.B \-tile WxH
size of image tiles (minimum allowed: 32x32)
@@ -494,8 +500,32 @@ set resizing support (default: true)
.B fullscreen=<bool>
start or resume a session in fullscreen mode (default: off)
.TP 8
-.B keyboard=<string>
-set remote keyboard layout
+.B keyboard=<string> or kbtype=<string>
+
+.BR query | <model>/<layout>
+
+.RS 8
+.TP 8
+.I query
+use the default XKB keyboard layout (see below) and only allow clients
+to query the settings but prevent any changes. \fIquery\fR is
+especially helpful for setups where you need to set/modify the actual
+keyboard layout using core X protocol functions (e.g. via \fBxmodmap\fR). It is used for
+MacOS X clients to handle some keyboard problems that are special for
+this platform. Note that in this case XKEYBOARD will always report
+the default layout which will most likely not match the experienced
+settings.
+.TP 8
+.I <model>/<layout>
+use the given model and layout. You can not modify keyboard rules,
+variant or options. Instead preset values are used. These are
+\fIxfree86\fR for rules and empty strings for variant and options.
+.RE
+.TP 8
+
+.PP
+If \fIkeyboard\fR is omitted the internal defaults of \fBnxagent\fR will be used (rules: \fIxfree86\fR, layout: \fIus\fR, model: \fIpc102\fR, empty variant and options).
+
.TP 8
.B keyconv=<string>
set keycode conversion mode
@@ -536,9 +566,6 @@ enable using shared memory
.B shpix=<bool>
enable shared pixmaps support
.TP 8
-.B kbtype=<string>
-set remote keyboard type
-.TP 8
.B client=<string>
type of connecting operating system (supported: \fIlinux\fR,
\fIwindows\fR, \fIsolaris\fR and \fImacosx\fR)