From b26db74dd0be8e4f4728e976144cb15e64b677a5 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 24 Dec 2022 11:13:02 +0100 Subject: Fix for "Fatal error while communicating with the Wayland server" (#610) This commit should fix: once the mouse leaves the app window area and returns back to it (app loses focus and gets it again) the crash happens. --- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 560756870..09a0feb1a 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -450,7 +450,7 @@ void Fl_Wayland_Window_Driver::hide() { wld_win->frame = NULL; wld_win->xdg_surface = NULL; } else { - if (wld_win->kind == POPUP) { + if (wld_win->kind == POPUP && wld_win->xdg_popup) { popup_done(wld_win, wld_win->xdg_popup); wld_win->xdg_popup = NULL; } @@ -904,6 +904,12 @@ static void popup_done(void *data, struct xdg_popup *xdg_popup) { } #endif xdg_popup_destroy(xdg_popup); + // The sway compositor calls popup_done directly and hides the menu + // when the app looses focus. + // Thus, we hide the window so FLTK and Wayland are in matching states. + struct wld_window *window = (struct wld_window*)data; + window->xdg_popup = NULL; + window->fl_win->hide(); } static const struct xdg_popup_listener popup_listener = { -- cgit v1.2.3