mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 10:29:49 +01:00
backend/{wayland,x11}: fix pointer coords for transformed outputs
This commit is contained in:
parent
62d7337d00
commit
178ac8bffe
2 changed files with 21 additions and 6 deletions
|
@ -63,7 +63,6 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
|||
}
|
||||
|
||||
backend->current_pointer = NULL;
|
||||
wlr_log(L_DEBUG, "leave %p", surface);
|
||||
}
|
||||
|
||||
static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
||||
|
@ -74,6 +73,17 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
|||
return;
|
||||
}
|
||||
|
||||
struct wlr_output *wlr_output = &pointer->output->wlr_output;
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = wl_fixed_to_int(sx),
|
||||
.y = wl_fixed_to_int(sy),
|
||||
};
|
||||
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(&pointer->output->wlr_output,
|
||||
&output_width, &output_height);
|
||||
|
@ -81,10 +91,9 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
|||
struct wlr_event_pointer_motion_absolute event = {
|
||||
.device = &pointer->input_device->wlr_input_device,
|
||||
.time_msec = time,
|
||||
.x = (double)wl_fixed_to_int(sx) / output_width,
|
||||
.y = (double)wl_fixed_to_int(sy) / output_height,
|
||||
.x = (double)box.x / output_width,
|
||||
.y = (double)box.y / output_height,
|
||||
};
|
||||
wlr_log(L_DEBUG, "motion: %f,%f", event.x, event.y);
|
||||
wlr_signal_emit_safe(&pointer->wlr_pointer.events.motion_absolute, &event);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,14 +33,20 @@ 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_event_pointer_motion_absolute event = {
|
||||
.device = &output->pointer_dev,
|
||||
.time_msec = time,
|
||||
.x = (double)x / output_width,
|
||||
.y = (double)y / output_height,
|
||||
.x = (double)box.x / output_width,
|
||||
.y = (double)box.y / output_height,
|
||||
};
|
||||
wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &event);
|
||||
|
||||
|
|
Loading…
Reference in a new issue