Menu

#14 XKeycodeToKeysym is deprecated

v1.0 (example)
closed-fixed
nobody
None
5
2016-06-30
2016-06-30
Mikhail T.
No

Xorg has deprecated the XKeycodeToKeysym-function a few years back. It sill compiles, but compiler issues a deprecation warning. Some day, the function may be removed. The alternative is to use XkbKeycodeToKeysym found inside the new header <X11/XKBlib.h>.

If you still wish to support really old X11-installations, don't do anything or protect the change by #ifdef. Otherwise, the patch is simple:
```diff
--- JXGrabKey/C++/src/JXGrabKey.cpp 2010-02-28 10:11:49.000000000 -0500
+++ JXGrabKey/C++/src/JXGrabKey.cpp 2016-06-30 03:15:41.718599000 -0400
@@ -24,4 +24,5 @@
#include <x11 xlib.h="">
#include <x11 keysym.h="">
+#include <x11 xkblib.h=""></x11></x11></x11>

#include <pthread.h>
@@ -347,6 +348,6 @@
<< keys.at(i).id
<< "; type = KeyPress; x11Keycode = '"</pthread.h>

  • << XKeysymToString(XKeycodeToKeysym(dpy,
  • ev.xkey.keycode, 0)) << "' (0x"
  • << XKeysymToString(XkbKeycodeToKeysym(dpy,
  • ev.xkey.keycode, 0, 0)) << "' (0x"
    << std::hex << ev.xkey.keycode
    << "); x11Mask = 0x" << std::hex

Discussion

  • Mikhail T.

    Mikhail T. - 2016-06-30

    Argh... Sorry about formatting:

    --- JXGrabKey/C++/src/JXGrabKey.cpp 2010-02-28 10:11:49.000000000 -0500
    +++ JXGrabKey/C++/src/JXGrabKey.cpp 2016-06-30 03:15:41.718599000 -0400
    @@ -24,4 +24,5 @@
     #include <X11/Xlib.h>
     #include <X11/keysym.h>
    +#include <X11/XKBlib.h>
    
     #include <pthread.h>
    @@ -347,6 +348,6 @@
                                        << keys.at(i).id
                                        << "; type = KeyPress; x11Keycode = '"
    
    -                                   << XKeysymToString(XKeycodeToKeysym(dpy,
    -                                           ev.xkey.keycode, 0)) << "' (0x"
    +                                   << XKeysymToString(XkbKeycodeToKeysym(dpy,
    +                                       ev.xkey.keycode, 0, 0)) << "' (0x"
                                        << std::hex << ev.xkey.keycode
                                        << "); x11Mask = 0x" << std::hex
    
     
  • Edwin Stang

    Edwin Stang - 2016-06-30

    Thanks for the fix, committed in trunk.

     
  • Edwin Stang

    Edwin Stang - 2016-06-30
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB