compositor-x11: convert (some) of X11 buttons to linux input
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
01e7b006db
commit
a3a7162b11
+36
-10
@@ -453,6 +453,40 @@ x11_compositor_find_output(struct x11_compositor *c, xcb_window_t window)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
x11_compositor_deliver_button_event(struct x11_compositor *c,
|
||||||
|
xcb_generic_event_t *event, int state)
|
||||||
|
{
|
||||||
|
xcb_button_press_event_t *button_event =
|
||||||
|
(xcb_button_press_event_t *) event;
|
||||||
|
int button;
|
||||||
|
|
||||||
|
switch (button_event->detail) {
|
||||||
|
default:
|
||||||
|
button = button_event->detail + BTN_LEFT - 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
button = BTN_MIDDLE;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
button = BTN_RIGHT;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
/* X11 sends wheel events as buttons events. But
|
||||||
|
* linux input treats as REL_WHEEL, therefore not
|
||||||
|
* button type at all. When we update the input
|
||||||
|
* protocol and get the 'axis' event, we'll send
|
||||||
|
* scroll events as axis events. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_button(c->base.input_device,
|
||||||
|
wlsc_compositor_get_time(), button, state);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x11_compositor_next_event(struct x11_compositor *c,
|
x11_compositor_next_event(struct x11_compositor *c,
|
||||||
xcb_generic_event_t **event, uint32_t mask)
|
xcb_generic_event_t **event, uint32_t mask)
|
||||||
@@ -480,7 +514,6 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
|||||||
xcb_motion_notify_event_t *motion_notify;
|
xcb_motion_notify_event_t *motion_notify;
|
||||||
xcb_enter_notify_event_t *enter_notify;
|
xcb_enter_notify_event_t *enter_notify;
|
||||||
xcb_key_press_event_t *key_press, *key_release;
|
xcb_key_press_event_t *key_press, *key_release;
|
||||||
xcb_button_press_event_t *button_press;
|
|
||||||
xcb_keymap_notify_event_t *keymap_notify;
|
xcb_keymap_notify_event_t *keymap_notify;
|
||||||
xcb_focus_in_event_t *focus_in;
|
xcb_focus_in_event_t *focus_in;
|
||||||
xcb_atom_t atom;
|
xcb_atom_t atom;
|
||||||
@@ -553,18 +586,11 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
|||||||
prev = event;
|
prev = event;
|
||||||
break;
|
break;
|
||||||
case XCB_BUTTON_PRESS:
|
case XCB_BUTTON_PRESS:
|
||||||
button_press = (xcb_button_press_event_t *) event;
|
x11_compositor_deliver_button_event(c, event, 1);
|
||||||
notify_button(c->base.input_device,
|
|
||||||
wlsc_compositor_get_time(),
|
|
||||||
button_press->detail + BTN_LEFT - 1, 1);
|
|
||||||
break;
|
break;
|
||||||
case XCB_BUTTON_RELEASE:
|
case XCB_BUTTON_RELEASE:
|
||||||
button_press = (xcb_button_press_event_t *) event;
|
x11_compositor_deliver_button_event(c, event, 0);
|
||||||
notify_button(c->base.input_device,
|
|
||||||
wlsc_compositor_get_time(),
|
|
||||||
button_press->detail + BTN_LEFT - 1, 0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XCB_MOTION_NOTIFY:
|
case XCB_MOTION_NOTIFY:
|
||||||
motion_notify = (xcb_motion_notify_event_t *) event;
|
motion_notify = (xcb_motion_notify_event_t *) event;
|
||||||
output = x11_compositor_find_output(c, motion_notify->event);
|
output = x11_compositor_find_output(c, motion_notify->event);
|
||||||
|
|||||||
Reference in New Issue
Block a user