51
51
#include <linux/types.h>
52
52
53
53
#include <xf86_OSproc.h>
54
+ #include <xserver-properties.h>
54
55
55
56
#include <unistd.h>
56
57
63
64
64
65
#include <windowstr.h>
65
66
66
- #ifdef HAVE_PROPERTIES
67
- #include <xserver-properties.h>
68
- /* 1.6 has properties, but no labels */
69
- #ifdef AXIS_LABEL_PROP
70
- #define HAVE_LABELS
71
- #else
72
- #undef HAVE_LABELS
73
- #endif
74
-
75
- #endif
76
67
77
68
#if GET_ABI_MAJOR (ABI_XINPUT_VERSION ) >= 23
78
69
#define HAVE_THREADED_INPUT 1
100
91
#include <qubes-gui-protocol.h>
101
92
#include "xdriver-shm-cmd.h"
102
93
#include "qubes.h"
94
+ #include "labels.h"
103
95
104
96
#include "../../xf86-qubes-common/include/xf86-qubes-common.h"
105
97
@@ -125,7 +117,7 @@ static void QubesBlockHandler(void *arg, void *timeout);
125
117
static void QubesWakeupHandler (void * arg , int result );
126
118
#endif
127
119
128
-
120
+ #define ArrayLength ( x ) (sizeof(x)/sizeof((x)[0]))
129
121
130
122
_X_EXPORT InputDriverRec QUBES = {
131
123
1 ,
@@ -275,6 +267,29 @@ static int _qubes_init_kbd(DeviceIntPtr device)
275
267
return Success ;
276
268
}
277
269
270
+ static void QubesInitButtonLabels (QubesDevicePtr pQubes , int natoms ,
271
+ Atom * atoms )
272
+ {
273
+ Atom atom ;
274
+ int btn ;
275
+ const char * * labels ;
276
+ int labels_len = 0 ;
277
+
278
+ labels = btn_labels ;
279
+ labels_len = ArrayLength (btn_labels );
280
+
281
+ memset (atoms , 0 , natoms * sizeof (Atom ));
282
+
283
+ /* Now fill the ones we know */
284
+ for (btn = 0 ; btn < labels_len && btn < natoms ; btn ++ ) {
285
+ atom = XIGetKnownProperty (labels [btn ]);
286
+ if (!atom ) /* Should not happen */
287
+ continue ;
288
+
289
+ atoms [btn ] = atom ;
290
+ }
291
+ }
292
+
278
293
static int _qubes_init_buttons (DeviceIntPtr device )
279
294
{
280
295
InputInfoPtr pInfo = device -> public .devicePrivate ;
@@ -293,6 +308,7 @@ static int _qubes_init_buttons(DeviceIntPtr device)
293
308
294
309
pQubes -> labels = calloc (num_buttons , sizeof (Atom ));
295
310
311
+ QubesInitButtonLabels (pQubes , num_buttons , pQubes -> labels );
296
312
if (!InitButtonClassDeviceStruct (device , num_buttons ,
297
313
pQubes -> labels , map )) {
298
314
xf86Msg (X_ERROR , "%s: Failed to register buttons.\n" ,
@@ -307,31 +323,24 @@ static int _qubes_init_buttons(DeviceIntPtr device)
307
323
static void QubesInitAxesLabels (QubesDevicePtr pQubes , int natoms ,
308
324
Atom * atoms )
309
325
{
310
- #ifdef HAVE_LABELS
311
326
Atom atom ;
312
327
int axis ;
313
- char * * labels ;
328
+ const char * * labels ;
314
329
int labels_len = 0 ;
315
- char * misc_label ;
316
330
317
331
labels = rel_labels ;
318
332
labels_len = ArrayLength (rel_labels );
319
- misc_label = AXIS_LABEL_PROP_REL_MISC ;
320
333
321
334
memset (atoms , 0 , natoms * sizeof (Atom ));
322
335
323
336
/* Now fill the ones we know */
324
- for (axis = 0 ; axis < labels_len ; axis ++ ) {
325
- if (pQubes -> axis_map [axis ] == -1 )
326
- continue ;
327
-
337
+ for (axis = 0 ; axis < labels_len && axis < natoms ; axis ++ ) {
328
338
atom = XIGetKnownProperty (labels [axis ]);
329
339
if (!atom ) /* Should not happen */
330
340
continue ;
331
341
332
- atoms [pQubes -> axis_map [ axis ] ] = atom ;
342
+ atoms [axis ] = atom ;
333
343
}
334
- #endif
335
344
}
336
345
337
346
0 commit comments