From f9acdb6edb7bc0c0b4d1a814283c7d908b0d4bba Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:08:12 +0200 Subject: [PATCH] Repair commit e0c3fe9 to fix #521 which destroyed DnD from Wayland It turns out it's necessary to memorize 2 event serial numbers : - serial changed at each pointer and key event; - pointer_enter_serial changed when pointer enters a surface because this one and not any other is needed for exact cursor changes by wl_pointer_set_cursor() in do_set_cursor(). --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index e55531509..f08f9cd86 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H @@ -42,6 +42,7 @@ struct seat { struct wl_surface *pointer_focus; int pointer_scale; uint32_t serial; + uint32_t pointer_enter_serial; struct wl_data_device_manager *data_device_manager; struct wl_data_device *data_device; struct wl_data_source *data_source; diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 68cbe50cc..0f76454a8 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -188,7 +188,7 @@ static void do_set_cursor(struct seat *seat, struct wl_cursor *wl_cursor = NULL) if (!wl_cursor) wl_cursor = seat->default_cursor; image = wl_cursor->images[0]; buffer = wl_cursor_image_get_buffer(image); - wl_pointer_set_cursor(seat->wl_pointer, seat->serial, + wl_pointer_set_cursor(seat->wl_pointer, seat->pointer_enter_serial, seat->cursor_surface, image->hotspot_x / scale, image->hotspot_y / scale); @@ -278,6 +278,7 @@ static void pointer_enter(void *data, struct seat *seat = (struct seat*)data; do_set_cursor(seat, cursor); seat->serial = serial; + seat->pointer_enter_serial = serial; set_event_xy(win); Fl::handle(FL_ENTER, win); //fprintf(stderr, "pointer_enter window=%p\n", win); @@ -332,6 +333,7 @@ static void pointer_button(void *data, uint32_t state) { struct seat *seat = (struct seat*)data; + seat->serial = serial; int event = 0; Fl_Window *win = Fl_Wayland_Screen_Driver::surface_to_window(seat->pointer_focus); if (!win) return; @@ -655,6 +657,7 @@ static void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { struct seat *seat = (struct seat*)data; + seat->serial = serial; static char buf[128]; uint32_t keycode = key + 8; xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->xkb_state, keycode);