summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-06-28 08:47:21 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-06-28 08:47:21 +0200
commit8bb29e823cb6371091360cc718ebbf64995d12a3 (patch)
treeb69ae45011b2bd3de105584fe148e4af04eec701
parentf5879ae2283404e48aeca218f896b746eb973468 (diff)
Have Fl_Wayland_Window_Driver use Fl::add_check() when adequate
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index e5f861062..9c144aec4 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -427,8 +427,9 @@ static void destroy_surface_caution_pointer_focus(struct wl_surface *surface,
}
-static void delayed_delete_Fl_X(Fl_X *i) {
- delete i;
+static void delayed_delete_Fl_X(void *data) {
+ Fl::remove_check(delayed_delete_Fl_X, data);
+ delete (Fl_X*)data;
}
@@ -483,17 +484,18 @@ void Fl_Wayland_Window_Driver::hide() {
free(wld_win);
}
if (pWindow->as_gl_window() && in_flush_) {
- // Under Wayland and for a GL window, this scenario can occur (e.g. test/cube):
+ // Under Wayland and for a GL window, this summarized scenario can occur
+ // when closing a window with "escape" (e.g. test/cube):
// Fl::flush() calls Fl_Wayland_Window_Driver::flush()
// calls Fl_Wayland_Gl_Window_Driver::swap_buffers()
- // calls wl_display_dispatch_pending() calls Fl_Window::hide().
+ // calls wl_display_dispatch_pending() calls Fl_Wayland_Window_Driver::hide().
// We make sure here to force exit from the loop over all damaged windows
- // in Fl::flush() and delay deletion of the Fl_X record after return from
- // Fl::flush().
+ // in Fl::flush(), and postpone deletion of the Fl_X record until after return
+ // from Fl::flush().
ip->xid = 0;
ip->next = NULL;
Fl::damage(1); // make sure potential remaining damaged windows get drawn
- Fl::add_timeout(.01, (Fl_Timeout_Handler)delayed_delete_Fl_X, ip);
+ Fl::add_check(delayed_delete_Fl_X, ip);
} else {
delete ip;
}
@@ -880,14 +882,15 @@ void Fl_Wayland_Window_Driver::wait_for_expose()
}
}
-static void delayed_close(Fl_Window *win) {
- Fl::handle(FL_CLOSE, win);
+static void delayed_close(void *data) {
+ 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
struct wld_window* wl_win = (struct wld_window*)user_data;
- Fl::add_timeout(0.01, (Fl_Timeout_Handler)delayed_close, wl_win->fl_win);
+ Fl::add_check(delayed_close, wl_win->fl_win);
}