From 9c8977eff13c0a181a71b72287163478e6084f79 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 28 May 2024 15:33:33 +0200 Subject: [PATCH] Fix: Wayland sends wrong events after an FL_DRAG of a top window (#983) --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 6 ++++++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 1 + 3 files changed, 8 insertions(+) diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index e2535cfb4..97bcccfa6 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H @@ -87,6 +87,7 @@ public: // next length of marked text after current marked text will have been replaced static int next_marked_length; static compositor_name compositor; // identifies the used Wayland compositor + static bool in_xdg_toplevel_move; // true when performing interactive window move // static member functions static void insertion_point_location(int x, int y, int height); diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 647a1b461..d332fb3e7 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -96,6 +96,7 @@ static struct wl_surface *gtk_shell_surface = NULL; Fl_Wayland_Screen_Driver::compositor_name Fl_Wayland_Screen_Driver::compositor = Fl_Wayland_Screen_Driver::unspecified; +bool Fl_Wayland_Screen_Driver::in_xdg_toplevel_move = false; extern "C" { bool fl_libdecor_using_weston(void) { @@ -230,6 +231,11 @@ static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t se set_event_xy(win); Fl::handle(FL_ENTER, win); //fprintf(stderr, "pointer_enter window=%p\n", win); + if (Fl_Wayland_Screen_Driver::in_xdg_toplevel_move) { + Fl::pushed(NULL); + Fl::e_state = 0; + Fl_Wayland_Screen_Driver::in_xdg_toplevel_move = false; + } seat->pointer_focus = surface; } diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index fbe5dc9ab..cb3cf5b39 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1856,6 +1856,7 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) { Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); if (Fl::e_state == FL_BUTTON1) { xdg_toplevel_move(xdg_toplevel(), scr_driver->seat->wl_seat, scr_driver->seat->serial); + Fl_Wayland_Screen_Driver::in_xdg_toplevel_move = true; } } else if (fl_win->kind == SUBWINDOW && fl_win->subsurface) { wl_subsurface_set_position(fl_win->subsurface, pWindow->x() * f, pWindow->y() * f);