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().
This commit is contained in:
ManoloFLTK 2022-10-25 19:08:12 +02:00
parent 84cdc1ba12
commit f9acdb6edb
2 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -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);