summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2016-09-13 15:17:01 +0800
committerAdam Jackson <ajax@redhat.com>2016-10-05 13:46:29 -0400
commit011ada724afdba8955f1d4844b306e61390eead8 (patch)
treee73aec5d8189c2e1526c20a665a9cdb4c02f043b /hw
parenta77d0715c6272cc1778a54dccd8cb68dc28cd761 (diff)
xwayland: Move pointer button initialization into helper
We'll later use this for initializing buttons for the relative pointer since they need to be the same. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/xwayland/xwayland-input.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index b8acc879b..525142965 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -52,31 +52,44 @@ xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
/* Nothing to do, dix handles all settings */
}
-static int
-xwl_pointer_proc(DeviceIntPtr device, int what)
+static Bool
+init_pointer_buttons(DeviceIntPtr device)
{
#define NBUTTONS 10
-#define NAXES 4
BYTE map[NBUTTONS + 1];
int i = 0;
Atom btn_labels[NBUTTONS] = { 0 };
+
+ for (i = 1; i <= NBUTTONS; i++)
+ map[i] = i;
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ /* don't know about the rest */
+
+ if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
+ return FALSE;
+
+ return TRUE;
+}
+
+static int
+xwl_pointer_proc(DeviceIntPtr device, int what)
+{
+#define NAXES 4
Atom axes_labels[NAXES] = { 0 };
switch (what) {
case DEVICE_INIT:
device->public.on = FALSE;
- for (i = 1; i <= NBUTTONS; i++)
- map[i] = i;
-
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- /* don't know about the rest */
+ if (!init_pointer_buttons(device))
+ return BadValue;
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
@@ -103,9 +116,6 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
return BadValue;
- if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
- return BadValue;
-
return Success;
case DEVICE_ON: