VirtualBox

Ticket #373: keymod2.c

File keymod2.c, 704 bytes (added by Adis Hamzic, 13 years ago)

A workaround for the issue using LD_PRELOAD filtering.

Line 
1#define _GNU_SOURCE
2#include <dlfcn.h>
3#include <X11/Xlib.h>
4
5#define LIBRARY "libX11.so"
6#define FROM 0x84
7#define TO 0x80
8
9int (*real_function)(Display* display, XEvent* event);
10
11void modify_event(XEvent* event)
12{
13 if(event == 0)
14 return;
15 switch(event->type)
16 {
17 case KeyPress:
18 case KeyRelease:
19 if((event->xkey.state & FROM) == FROM)
20 event->xkey.state = (event->xkey.state & ~FROM) | TO;
21 break;
22 }
23}
24
25int XNextEvent(Display* display, XEvent* event)
26{
27 if(real_function == NULL)
28 {
29 void* handle = dlopen(LIBRARY, RTLD_LAZY);
30 real_function = dlsym(handle, "XNextEvent");
31 }
32
33 int ret = real_function(display, event);
34 modify_event(event);
35 return ret;
36}
37

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy