mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
backend/wayland: cleanup input transform code
This commit is contained in:
parent
aa6ae710f7
commit
f37e8c5b6e
1 changed files with 10 additions and 19 deletions
|
@ -60,37 +60,28 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
struct wlr_output *wlr_output = &wlr_wl_pointer->current_output->wlr_output;
|
struct wlr_output *wlr_output = &wlr_wl_pointer->current_output->wlr_output;
|
||||||
|
|
||||||
int width, height;
|
|
||||||
wl_egl_window_get_attached_size(wlr_wl_pointer->current_output->egl_window,
|
|
||||||
&width, &height);
|
|
||||||
|
|
||||||
int owidth, oheight;
|
|
||||||
wlr_output_effective_resolution(wlr_output, &owidth, &oheight);
|
|
||||||
|
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = wl_fixed_to_int(surface_x),
|
.x = wl_fixed_to_int(surface_x),
|
||||||
.y = wl_fixed_to_int(surface_y),
|
.y = wl_fixed_to_int(surface_y),
|
||||||
};
|
};
|
||||||
struct wlr_box transformed;
|
wlr_box_transform(&box, wlr_output->transform, wlr_output->width,
|
||||||
wlr_box_transform(&box, wlr_output->transform, width, height, &transformed);
|
wlr_output->height, &box);
|
||||||
transformed.x /= wlr_output->scale;
|
box.x /= wlr_output->scale;
|
||||||
transformed.y /= wlr_output->scale;
|
box.y /= wlr_output->scale;
|
||||||
|
|
||||||
struct wlr_box layout_box;
|
struct wlr_box layout_box;
|
||||||
wlr_wl_output_layout_get_box(wlr_wl_pointer->current_output->backend,
|
wlr_wl_output_layout_get_box(wlr_wl_pointer->current_output->backend,
|
||||||
&layout_box);
|
&layout_box);
|
||||||
|
|
||||||
struct wlr_event_pointer_motion_absolute wlr_event;
|
|
||||||
wlr_event.device = dev;
|
|
||||||
wlr_event.time_msec = time;
|
|
||||||
|
|
||||||
double tx = transformed.x / (double)owidth;
|
|
||||||
double ty = transformed.y / (double)oheight;
|
|
||||||
double ox = wlr_output->lx / (double)layout_box.width;
|
double ox = wlr_output->lx / (double)layout_box.width;
|
||||||
double oy = wlr_output->ly / (double)layout_box.height;
|
double oy = wlr_output->ly / (double)layout_box.height;
|
||||||
|
|
||||||
wlr_event.x = tx * ((double)owidth / layout_box.width) + ox;
|
struct wlr_event_pointer_motion_absolute wlr_event = {
|
||||||
wlr_event.y = ty * ((double)oheight / layout_box.height) + oy;
|
.device = dev,
|
||||||
|
.time_msec = time,
|
||||||
|
.x = box.x / (double)layout_box.width + ox,
|
||||||
|
.y = box.y / (double)layout_box.height + oy,
|
||||||
|
};
|
||||||
|
|
||||||
wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
|
wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue