aboutsummaryrefslogtreecommitdiff
path: root/backend/x11
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2017-09-28 21:47:12 +1300
committerScott Anderson <ascent12@hotmail.com>2017-09-29 16:15:09 +1300
commitfc0e45f2ee01c9402698c96399000ed492fdf534 (patch)
treeae83c7876492036a40dda823b2b16aa8c1d434d6 /backend/x11
parent8027232ae56f0d02c6c1ce1033a5e1b9a2b54b7f (diff)
Add mouse button presses
Diffstat (limited to 'backend/x11')
-rw-r--r--backend/x11/backend.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index aa8ce5a5..c7724e3f 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -7,6 +7,7 @@
#include <wayland-server.h>
#include <xcb/xcb.h>
#include <X11/Xlib-xcb.h>
+#include <linux/input-event-codes.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/x11.h>
#include <wlr/egl.h>
@@ -64,6 +65,54 @@ int x11_event(int fd, uint32_t mask, void *data) {
wl_signal_emit(&x11->keyboard.events.key, &key);
break;
}
+ case XCB_BUTTON_PRESS: {
+ xcb_button_press_event_t *press = (xcb_button_press_event_t *)event;
+ struct wlr_event_pointer_button button = {
+ .device = &x11->pointer_dev,
+ .time_sec = ts.tv_sec,
+ .time_usec = ts.tv_nsec / 1000,
+ .state = WLR_BUTTON_PRESSED,
+ };
+
+ switch (press->detail) {
+ case XCB_BUTTON_INDEX_1:
+ button.button = BTN_LEFT;
+ break;
+ case XCB_BUTTON_INDEX_2:
+ button.button = BTN_MIDDLE;
+ break;
+ case XCB_BUTTON_INDEX_3:
+ button.button = BTN_RIGHT;
+ break;
+ }
+
+ wl_signal_emit(&x11->pointer.events.button, &button);
+ break;
+ }
+ case XCB_BUTTON_RELEASE: {
+ xcb_button_release_event_t *press = (xcb_button_release_event_t *)event;
+ struct wlr_event_pointer_button button = {
+ .device = &x11->pointer_dev,
+ .time_sec = ts.tv_sec,
+ .time_usec = ts.tv_nsec / 1000,
+ .state = WLR_BUTTON_RELEASED,
+ };
+
+ switch (press->detail) {
+ case XCB_BUTTON_INDEX_1:
+ button.button = BTN_LEFT;
+ break;
+ case XCB_BUTTON_INDEX_2:
+ button.button = BTN_MIDDLE;
+ break;
+ case XCB_BUTTON_INDEX_3:
+ button.button = BTN_RIGHT;
+ break;
+ }
+
+ wl_signal_emit(&x11->pointer.events.button, &button);
+ break;
+ }
default:
wlr_log(L_INFO, "Unknown event");
break;
@@ -150,7 +199,9 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
uint32_t values[2] = {
x11->screen->white_pixel,
- XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE
+ XCB_EVENT_MASK_EXPOSURE |
+ XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
};
output->x11 = x11;