backend/{wayland,x11}: fix pointer coords for transformed outputs

master
emersion 7 years ago
parent 62d7337d00
commit 178ac8bffe
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -63,7 +63,6 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
} }
backend->current_pointer = NULL; backend->current_pointer = NULL;
wlr_log(L_DEBUG, "leave %p", surface);
} }
static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, 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; 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; int output_width, output_height;
wlr_output_effective_resolution(&pointer->output->wlr_output, wlr_output_effective_resolution(&pointer->output->wlr_output,
&output_width, &output_height); &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 = { struct wlr_event_pointer_motion_absolute event = {
.device = &pointer->input_device->wlr_input_device, .device = &pointer->input_device->wlr_input_device,
.time_msec = time, .time_msec = time,
.x = (double)wl_fixed_to_int(sx) / output_width, .x = (double)box.x / output_width,
.y = (double)wl_fixed_to_int(sy) / output_height, .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); 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_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 };
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; int output_width, output_height;
wlr_output_effective_resolution(wlr_output, &output_width, &output_height); wlr_output_effective_resolution(wlr_output, &output_width, &output_height);
struct wlr_event_pointer_motion_absolute event = { struct wlr_event_pointer_motion_absolute event = {
.device = &output->pointer_dev, .device = &output->pointer_dev,
.time_msec = time, .time_msec = time,
.x = (double)x / output_width, .x = (double)box.x / output_width,
.y = (double)y / output_height, .y = (double)box.y / output_height,
}; };
wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &event); wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &event);

Loading…
Cancel
Save