1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

WINGs: Add W_KeycodeToKeysym to replace XKeycodeToKeysym/XkbKeycodeToKeysym calls

XKeycodeToKeysym was deprecated some time ago and we replaced
those function calls to XkbKeycodeToKeysym.
Usage of XkbKeycodeToKeysym is not the best as it appears
the XKEYBOARD can be disabled via xorg.conf (at least on Linux).
So just replacing XKeycodeToKeysym() with XkbKeycodeToKeysym()
could cause run-time errors on top of the compilation warning
we may have.
Better fix is to address the problem without introducing a
dependency on XKEYBOARD. W_KeycodeToKeysym is the equivalent
code for XKeycodeToKeysym/XkbKeycodeToKeysym using
XGetKeyboardMapping instead.

As a new function is added to the library WINGs library version
is bumped.
This commit is contained in:
David Maciejak
2023-02-26 08:40:14 +08:00
committed by Carlos R. Mafra
parent 2dd98666f1
commit 15d06ff064
6 changed files with 46 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
Changes since wmaker 0.95.10:
............................
- added W_KeycodeToKeysym to replace XKeycodeToKeysym/XkbKeycodeToKeysym calls
Changes since wmaker 0.92.0:
............................

View File

@@ -1,7 +1,9 @@
** API and ABI modifications since wmaker 0.92.0
** API and ABI modifications since wmaker 0.95.10
----------------------------------------------------
** libWINGs **
<WINGsP.h>
W_KeycodeToKeysym ADDED
struct W_DragDestinationInfo: new members added SIZE CHANGE
<WINGs.h>

View File

@@ -26,7 +26,7 @@
#include <WINGs/WUtil.h>
#include <X11/Xlib.h>
#define WINGS_H_VERSION 20210726
#define WINGS_H_VERSION 20230226
#ifdef __cplusplus

View File

@@ -494,6 +494,8 @@ void W_SetPreeditPositon(W_View *view, int x, int y);
int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer,
int buflen, KeySym *keysym, Status *status);
KeySym W_KeycodeToKeysym(Display *display, KeyCode keycode, int index);
/* ---[ wmisc.c ]--------------------------------------------------------- */

View File

@@ -213,3 +213,35 @@ int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer, int bufl
#endif
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *) status);
}
/*
* Map a keycode to the corresponding keysym
* To replace the deprecated X11 function XKeycodeToKeysym
*/
KeySym W_KeycodeToKeysym(Display *display, KeyCode keycode, int index)
{
static int min_kc = -1;
static int max_kc;
int num_syms;
KeySym *key_syms;
KeySym ks;
if (min_kc == -1) {
(void) XDisplayKeycodes(display, &min_kc, &max_kc);
}
if (keycode < min_kc || keycode > max_kc || index < 0) {
return NoSymbol;
}
key_syms = XGetKeyboardMapping(display, keycode, 1, &num_syms);
if (index >= num_syms) {
XFree(key_syms);
return NoSymbol;
}
ks = key_syms[index];
XFree(key_syms);
return ks;
}

View File

@@ -78,9 +78,9 @@ WRASTER_VERSION=$WRASTER_CURRENT:$WRASTER_REVISION:$WRASTER_AGE
AC_SUBST(WRASTER_VERSION)
dnl
dnl libWINGs
WINGS_CURRENT=4
WINGS_CURRENT=5
WINGS_REVISION=0
WINGS_AGE=1
WINGS_AGE=2
WINGS_VERSION=$WINGS_CURRENT:$WINGS_REVISION:$WINGS_AGE
AC_SUBST(WINGS_VERSION)
dnl