aboutsummaryrefslogtreecommitdiff
path: root/backend/x11/backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/x11/backend.c')
-rw-r--r--backend/x11/backend.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 88c022d1..1eb5a952 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -47,29 +47,46 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
xcb_key_press_event_t *ev = (xcb_key_press_event_t *)event;
struct wlr_event_keyboard_key key = {
.time_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
+ .time_usec = ev->time * 1000,
.keycode = ev->detail - 8,
.state = event->response_type == XCB_KEY_PRESS ?
WLR_KEY_PRESSED : WLR_KEY_RELEASED,
+ .update_state = true,
};
- wl_signal_emit(&x11->keyboard.events.key, &key);
+ // TODO use xcb-xkb for more precise modifiers state?
+ wlr_keyboard_notify_key(&x11->keyboard, &key);
x11->time = ev->time;
break;
}
case XCB_BUTTON_PRESS:
case XCB_BUTTON_RELEASE: {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
- struct wlr_event_pointer_button button = {
- .device = &x11->pointer_dev,
- .time_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
- .button = xcb_button_to_wl(ev->detail),
- .state = event->response_type == XCB_BUTTON_PRESS ?
- WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
- };
- wl_signal_emit(&x11->pointer.events.button, &button);
+ if (ev->detail == XCB_BUTTON_INDEX_4 ||
+ ev->detail == XCB_BUTTON_INDEX_5) {
+ double delta = (ev->detail == XCB_BUTTON_INDEX_4 ? -15 : 15);
+ struct wlr_event_pointer_axis axis = {
+ .device = &x11->pointer_dev,
+ .time_sec = ev->time / 1000,
+ .time_usec = ev->time * 1000,
+ .source = WLR_AXIS_SOURCE_WHEEL,
+ .orientation = WLR_AXIS_ORIENTATION_VERTICAL,
+ .delta = delta,
+ };
+ wl_signal_emit(&x11->pointer.events.axis, &axis);
+ } else {
+ struct wlr_event_pointer_button button = {
+ .device = &x11->pointer_dev,
+ .time_sec = ev->time / 1000,
+ .time_usec = ev->time * 1000,
+ .button = xcb_button_to_wl(ev->detail),
+ .state = event->response_type == XCB_BUTTON_PRESS ?
+ WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
+ };
+
+ wl_signal_emit(&x11->pointer.events.button, &button);
+ }
x11->time = ev->time;
break;
}
@@ -78,7 +95,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev,
.time_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
+ .time_usec = ev->time * 1000,
.x_mm = ev->event_x,
.y_mm = ev->event_y,
.width_mm = output->wlr_output.width,
@@ -109,7 +126,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev,
.time_sec = x11->time / 1000,
- .time_usec = (x11->time % 1000) * 1000,
+ .time_usec = x11->time * 1000,
.x_mm = pointer->root_x,
.y_mm = pointer->root_y,
.width_mm = output->wlr_output.width,
@@ -258,6 +275,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
+ wlr_output_create_global(&output->wlr_output, x11->wl_display);
wl_signal_emit(&x11->backend.events.output_add, output);
wl_signal_emit(&x11->backend.events.input_add, &x11->keyboard_dev);