[mutter/wip/texture-purge-on-nvidia: 6/66] virtual-input/evdev: Translate from button codes internal to evdev
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/texture-purge-on-nvidia: 6/66] virtual-input/evdev: Translate from button codes internal to evdev
- Date: Tue, 8 Jan 2019 21:58:53 +0000 (UTC)
commit e7f7c5c72f9d4235705269dac5cac26f2507b865
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Aug 6 21:00:23 2018 +0200
virtual-input/evdev: Translate from button codes internal to evdev
Sending button events to a ClutterVirtualInputDevice, the API expects
button codes to be of the internal clutter type. The evdev
implementation incorrectly assumed it was already prepared evdev event
codes, which was not the case. Fix the evdev implementation to translate
from the internal representation to evdev before passing it along to
ClutterSeatEvdev.
.../evdev/clutter-virtual-input-device-evdev.c | 31 +++++++++++++++++-----
1 file changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c
b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c
index fe628da85..e491416c4 100644
--- a/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c
+++ b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c
@@ -185,6 +185,22 @@ clutter_virtual_input_device_evdev_notify_absolute_motion (ClutterVirtualInputDe
NULL);
}
+static int
+translate_to_evdev_button (int button)
+{
+ switch (button)
+ {
+ case CLUTTER_BUTTON_PRIMARY:
+ return BTN_LEFT;
+ case CLUTTER_BUTTON_SECONDARY:
+ return BTN_RIGHT;
+ case CLUTTER_BUTTON_MIDDLE:
+ return BTN_MIDDLE;
+ default:
+ return button + (BTN_LEFT - 1) - 4;
+ }
+}
+
static void
clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
@@ -194,30 +210,33 @@ clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *vir
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
int button_count;
+ int evdev_button;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
- if (get_button_type (button) != EVDEV_BUTTON_TYPE_BUTTON)
+ evdev_button = translate_to_evdev_button (button);
+
+ if (get_button_type (evdev_button) != EVDEV_BUTTON_TYPE_BUTTON)
{
g_warning ("Unknown/invalid virtual device button 0x%x pressed",
- button);
+ evdev_button);
return;
}
- button_count = update_button_count (virtual_evdev, button, button_state);
+ button_count = update_button_count (virtual_evdev, evdev_button, button_state);
if (button_count < 0 || button_count > 1)
{
- g_warning ("Received multiple virtual 0x%x button %s (ignoring)", button,
+ g_warning ("Received multiple virtual 0x%x button %s (ignoring)", evdev_button,
button_state == CLUTTER_BUTTON_STATE_PRESSED ? "presses" : "releases");
- update_button_count (virtual_evdev, button, 1 - button_state);
+ update_button_count (virtual_evdev, evdev_button, 1 - button_state);
return;
}
clutter_seat_evdev_notify_button (virtual_evdev->seat,
virtual_evdev->device,
time_us,
- button,
+ evdev_button,
button_state);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]