backend/x11: add one pointer per output

This commit is contained in:
emersion 2018-04-29 14:46:29 +01:00
parent ddac792b61
commit 62d7337d00
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 40 additions and 68 deletions

View file

@ -33,25 +33,16 @@ static void x11_handle_pointer_position(struct wlr_x11_output *output,
struct wlr_x11_backend *x11 = output->x11;
struct wlr_output *wlr_output = &output->wlr_output;
struct wlr_box box = { .x = x, .y = y };
wlr_box_transform(&box, wlr_output->transform, wlr_output->width,
wlr_output->height, &box);
box.x /= wlr_output->scale;
box.y /= wlr_output->scale;
int output_width, output_height;
wlr_output_effective_resolution(wlr_output, &output_width, &output_height);
struct wlr_box layout_box;
get_x11_output_layout_box(x11, &layout_box);
double ox = wlr_output->lx / (double)layout_box.width;
double oy = wlr_output->ly / (double)layout_box.height;
struct wlr_event_pointer_motion_absolute wlr_event = {
.device = &x11->pointer_dev,
struct wlr_event_pointer_motion_absolute event = {
.device = &output->pointer_dev,
.time_msec = time,
.x = box.x / (double)layout_box.width + ox,
.y = box.y / (double)layout_box.height + oy,
.x = (double)x / output_width,
.y = (double)y / output_height,
};
wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &wlr_event);
wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &event);
x11->time = time;
}
@ -78,17 +69,23 @@ void handle_x11_input_event(struct wlr_x11_backend *x11,
case XCB_BUTTON_PRESS: {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
struct wlr_x11_output *output =
get_x11_output_from_window_id(x11, ev->event);
if (output == NULL) {
break;
}
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,
.device = &output->pointer_dev,
.time_msec = ev->time,
.source = WLR_AXIS_SOURCE_WHEEL,
.orientation = WLR_AXIS_ORIENTATION_VERTICAL,
.delta = delta,
};
wlr_signal_emit_safe(&x11->pointer.events.axis, &axis);
wlr_signal_emit_safe(&output->pointer.events.axis, &axis);
x11->time = ev->time;
break;
}
@ -97,17 +94,23 @@ void handle_x11_input_event(struct wlr_x11_backend *x11,
case XCB_BUTTON_RELEASE: {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
struct wlr_x11_output *output =
get_x11_output_from_window_id(x11, ev->event);
if (output == NULL) {
break;
}
if (ev->detail != XCB_BUTTON_INDEX_4 &&
ev->detail != XCB_BUTTON_INDEX_5) {
struct wlr_event_pointer_button button = {
.device = &x11->pointer_dev,
.device = &output->pointer_dev,
.time_msec = ev->time,
.button = xcb_button_to_wl(ev->detail),
.state = event->response_type == XCB_BUTTON_PRESS ?
WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
};
wlr_signal_emit_safe(&x11->pointer.events.button, &button);
wlr_signal_emit_safe(&output->pointer.events.button, &button);
}
x11->time = ev->time;
return;