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.
This commit is contained in:
ManoloFLTK 2022-12-24 11:13:02 +01:00
parent e7eac09cf8
commit b26db74dd0

View File

@ -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 = {