author | František Kučera <franta-hg@frantovo.cz> |
Fri, 08 Mar 2019 20:11:23 +0100 | |
branch | v_0 |
changeset 1 | ac5f3768ebb1 |
parent 0 | src/spacenav-demo-qt.cpp@37aa134ae57b |
child 2 | 3ba27504be0e |
permissions | -rw-r--r-- |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
2 |
* Spacenav lib hack |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
18 |
#define _GNU_SOURCE |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
20 |
#include <stdio.h> |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
21 |
#include <stdint.h> |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
22 |
#include <dlfcn.h> |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
23 |
#include <stdlib.h> |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
24 |
#include <pthread.h> |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
#include <X11/Xlib.h> |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
#include <spnav.h> |
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
29 |
static Display* spacenav_hack_dpy; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
30 |
static Window spacenav_hack_win; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
31 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
32 |
static pthread_t spacenav_hack_thread; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
33 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
34 |
// from proto_x11.c (spacenavd) |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
35 |
static Atom xa_event_motion, xa_event_bpress, xa_event_brelease, xa_event_cmd; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
36 |
static float x11_sens = 1.0; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
37 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
38 |
/** |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
39 |
* This function is based on proto_x11.c (spacenavd) written by: |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
* Copyright (C) 2007-2019 John Tsiombikas <nuclear@member.fsf.org> |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
41 |
* and published under GNU GPLv3+ |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
42 |
* |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
43 |
* @param ev |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
44 |
* @param dpy |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
45 |
* @param win |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
46 |
*/ |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
47 |
static void send_xevent(spnav_event *ev, Display* dpy, Window win) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
48 |
int i; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
49 |
XEvent xevent; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
50 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
51 |
if (!dpy) return; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
52 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
53 |
// if(setjmp(jbuf)) return; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
54 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
55 |
xevent.type = ClientMessage; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
56 |
xevent.xclient.send_event = False; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
57 |
xevent.xclient.display = dpy; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
58 |
xevent.xclient.window = win; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
59 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
60 |
switch (ev->type) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
61 |
case SPNAV_EVENT_MOTION: |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
62 |
xevent.xclient.message_type = xa_event_motion; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
63 |
xevent.xclient.format = 16; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
64 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
65 |
for (i = 0; i < 6; i++) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
66 |
float val = (float) ev->motion.data[i] * x11_sens; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
67 |
xevent.xclient.data.s[i + 2] = (short) val; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
68 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
69 |
xevent.xclient.data.s[0] = xevent.xclient.data.s[1] = 0; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
70 |
xevent.xclient.data.s[8] = ev->motion.period; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
71 |
break; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
72 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
73 |
case SPNAV_EVENT_BUTTON: |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
74 |
xevent.xclient.message_type = ev->button.press ? xa_event_bpress : xa_event_brelease; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
75 |
xevent.xclient.format = 16; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
76 |
xevent.xclient.data.s[2] = ev->button.bnum; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
77 |
break; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
78 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
79 |
default: |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
80 |
break; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
81 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
82 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
83 |
XSendEvent(dpy, win, False, 0, &xevent); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
84 |
XFlush(dpy); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
85 |
} |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
|
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
87 |
static void* spacenav_hack_translate_events(void* arg) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
88 |
pthread_setname_np(pthread_self(), "spacenav-hack"); // can be found with: ps H -o 'pid tid cmd comm' |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
89 |
spnav_event event; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
90 |
while (1) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
91 |
if (spnav_wait_event(&event)) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
92 |
//fprintf(stderr, "spnav-lib-hack: got event\n"); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
93 |
XLockDisplay(spacenav_hack_dpy); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
94 |
send_xevent(&event, spacenav_hack_dpy, spacenav_hack_win); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
95 |
XUnlockDisplay(spacenav_hack_dpy); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
96 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
97 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
98 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
99 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
100 |
int spnav_x11_open(Display* dpy, Window win) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
101 |
spacenav_hack_dpy = dpy; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
102 |
spacenav_hack_win = win; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
103 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
104 |
int result = spnav_open(); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
105 |
fprintf(stderr, "spnav-lib-hack: instead of spnav_x11_open(%p, 0x%lx) calling spnav_open() = %d\n", dpy, win, result); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
106 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
107 |
if (result == 0) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
108 |
xa_event_motion = XInternAtom(dpy, "MotionEvent", False); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
109 |
xa_event_bpress = XInternAtom(dpy, "ButtonPressEvent", False); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
110 |
xa_event_brelease = XInternAtom(dpy, "ButtonReleaseEvent", False); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
111 |
xa_event_cmd = XInternAtom(dpy, "CommandEvent", False); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
112 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
113 |
XInitThreads(); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
114 |
pthread_create(&spacenav_hack_thread, NULL, spacenav_hack_translate_events, NULL); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
115 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
116 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
117 |
return result; |
0
37aa134ae57b
empty QT project linked to spnav library
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
} |
1
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
119 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
120 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
121 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
122 |
/* |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
123 |
int spnav_x11_event(const XEvent* xev, spnav_event* event) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
124 |
xev. |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
125 |
static int (*real_spnav_x11_event)(const XEvent*, spnav_event*) = NULL; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
126 |
if (!real_spnav_x11_event) real_spnav_x11_event = dlsym(RTLD_NEXT, "spnav_x11_event"); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
127 |
int result = real_spnav_x11_event(xev, event); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
128 |
if (result == SPNAV_EVENT_MOTION || result == SPNAV_EVENT_BUTTON) fprintf(stderr, "spnav-lib-hack: spnav_x11_event() = %d\n", result); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
129 |
return result; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
130 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
131 |
*/ |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
132 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
133 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
134 |
/* |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
135 |
int spnav_x11_open(Display* dpy, Window win) { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
136 |
static int (*real_spnav_x11_open)(Display*, Window) = NULL; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
137 |
if (!real_spnav_x11_open) real_spnav_x11_open = dlsym(RTLD_NEXT, "spnav_x11_open"); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
138 |
int result = real_spnav_x11_open(dpy, win); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
139 |
fprintf(stderr, "spnav-lib-hack: spnav_x11_open() = %d\n", result); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
140 |
return result; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
141 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
142 |
*/ |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
143 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
144 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
145 |
/* |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
146 |
int spnav_open() { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
147 |
return -1; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
148 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
149 |
*/ |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
150 |
|
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
151 |
/* |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
152 |
int spnav_open() { |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
153 |
static int (*real_spnav_open)() = NULL; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
154 |
if (!real_spnav_open) real_spnav_open = dlsym(RTLD_NEXT, "spnav_open"); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
155 |
int result = real_spnav_open(); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
156 |
// fprintf(stderr, "spnav-lib-hack: spnav_open() = %d\n", result); |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
157 |
return result; |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
158 |
} |
ac5f3768ebb1
almost working, but there is an SIGABRT
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
159 |
*/ |