Wayland: fix window closing with Sway's kill command or app menu

This commit is contained in:
ManoloFLTK 2023-08-02 10:04:45 +02:00
parent e12eb99b5d
commit b440c26e65

View File

@ -444,7 +444,7 @@ void Fl_Wayland_Window_Driver::hide() {
wld_win->subsurface = NULL;
}
if (wld_win->kind == DECORATED) {
if (wld_win->frame) libdecor_frame_unref(wld_win->frame);
libdecor_frame_unref(wld_win->frame);
wld_win->frame = NULL;
wld_win->xdg_surface = NULL;
} else {
@ -886,20 +886,18 @@ void Fl_Wayland_Window_Driver::wait_for_expose()
}
static void delayed_close(void *data) {
if (data) {
Fl::remove_check(delayed_close, data);
Fl::handle(FL_CLOSE, (Fl_Window*)data);
Fl::add_timeout(0.01, delayed_close, NULL); // necessary for closing with app menu
}
Fl::remove_check(delayed_close, data);
Fl::handle(FL_CLOSE, (Fl_Window*)data);
}
static void handle_close(struct libdecor_frame *frame, void *user_data)
{ // runs when the close button of a window titlebar is pushed
// or after "Quit" of the application menu
libdecor_frame_unref(frame); // may or may not release frame
// or after the Kill command of Sway
struct wld_window* wl_win = (struct wld_window*)user_data;
// the close window attempt is delayed because libdecor
// uses the frame after return from this function
Fl::add_check(delayed_close, wl_win->fl_win);
wl_win->frame = NULL;
}