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