backend/wayland: Set cursor indivdualy per output

master
Mykola Orliuk 4 years ago committed by Simon Ser
parent 44531e16e0
commit 2eae9ec7c8

@ -419,8 +419,10 @@ static void output_destroy(struct wlr_output *wlr_output) {
} }
void update_wl_output_cursor(struct wlr_wl_output *output) { void update_wl_output_cursor(struct wlr_wl_output *output) {
struct wlr_wl_pointer *pointer = output->backend->current_pointer; struct wlr_wl_pointer *pointer = output->cursor.pointer;
if (pointer && pointer->output == output && output->enter_serial) { if (pointer) {
assert(pointer->output == output);
assert(output->enter_serial);
wl_pointer_set_cursor(pointer->wl_pointer, output->enter_serial, wl_pointer_set_cursor(pointer->wl_pointer, output->enter_serial,
output->cursor.surface, output->cursor.hotspot_x, output->cursor.surface, output->cursor.hotspot_x,
output->cursor.hotspot_y); output->cursor.hotspot_y);

@ -43,7 +43,6 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx,
wl_fixed_t sy) { wl_fixed_t sy) {
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_wl_backend *backend = seat->backend;
if (surface == NULL) { if (surface == NULL) {
return; return;
} }
@ -54,7 +53,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
seat->active_pointer = pointer; seat->active_pointer = pointer;
// Manage cursor icon/rendering on output // Manage cursor icon/rendering on output
struct wlr_wl_pointer *current_pointer = backend->current_pointer; struct wlr_wl_pointer *current_pointer = output->cursor.pointer;
if (current_pointer && current_pointer != pointer) { if (current_pointer && current_pointer != pointer) {
wlr_log(WLR_INFO, "Ignoring seat %s pointer cursor in favor of seat %s", wlr_log(WLR_INFO, "Ignoring seat %s pointer cursor in favor of seat %s",
seat->name, current_pointer->input_device->seat->name); seat->name, current_pointer->input_device->seat->name);
@ -62,14 +61,13 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
} }
output->enter_serial = serial; output->enter_serial = serial;
backend->current_pointer = pointer; output->cursor.pointer = pointer;
update_wl_output_cursor(output); update_wl_output_cursor(output);
} }
static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface) { uint32_t serial, struct wl_surface *surface) {
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_wl_backend *backend = seat->backend;
if (surface == NULL) { if (surface == NULL) {
return; return;
} }
@ -82,14 +80,10 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
seat->active_pointer = NULL; seat->active_pointer = NULL;
} }
if (output->cursor.pointer == seat->active_pointer) {
output->enter_serial = 0; output->enter_serial = 0;
output->cursor.pointer = NULL;
if (backend->current_pointer == NULL ||
backend->current_pointer->output != output) {
return;
} }
backend->current_pointer = NULL;
} }
static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
@ -489,8 +483,8 @@ struct wlr_wl_pointer *pointer_get_wl(struct wlr_pointer *wlr_pointer) {
static void pointer_destroy(struct wlr_pointer *wlr_pointer) { static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
struct wlr_wl_pointer *pointer = pointer_get_wl(wlr_pointer); struct wlr_wl_pointer *pointer = pointer_get_wl(wlr_pointer);
if (pointer->output->backend->current_pointer == pointer) { if (pointer->output->cursor.pointer == pointer) {
pointer->output->backend->current_pointer = NULL; pointer->output->cursor.pointer = NULL;
} }
struct wlr_wl_seat *seat = pointer->input_device->seat; struct wlr_wl_seat *seat = pointer->input_device->seat;
@ -782,9 +776,10 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
} }
wlr_log(WLR_DEBUG, "dropping pointer %s", wlr_log(WLR_DEBUG, "dropping pointer %s",
pointer->input_device->wlr_input_device.name); pointer->input_device->wlr_input_device.name);
struct wlr_wl_output *output = pointer->output;
wlr_input_device_destroy(device); wlr_input_device_destroy(device);
assert(seat->active_pointer != pointer); assert(seat->active_pointer != pointer);
assert(backend->current_pointer != pointer); assert(output->cursor.pointer != pointer);
} }
wl_pointer_release(seat->pointer); wl_pointer_release(seat->pointer);

@ -40,7 +40,6 @@ struct wlr_wl_backend {
struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1; struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1;
struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1; struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1;
struct wl_list seats; // wlr_wl_seat.link struct wl_list seats; // wlr_wl_seat.link
struct wlr_wl_pointer *current_pointer;
struct zwp_tablet_manager_v2 *tablet_manager; struct zwp_tablet_manager_v2 *tablet_manager;
struct wlr_drm_format_set linux_dmabuf_v1_formats; struct wlr_drm_format_set linux_dmabuf_v1_formats;
}; };
@ -75,6 +74,7 @@ struct wlr_wl_output {
uint32_t enter_serial; uint32_t enter_serial;
struct { struct {
struct wlr_wl_pointer *pointer;
struct wl_surface *surface; struct wl_surface *surface;
struct wl_egl_window *egl_window; struct wl_egl_window *egl_window;
int32_t hotspot_x, hotspot_y; int32_t hotspot_x, hotspot_y;

Loading…
Cancel
Save