summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-08-04 19:14:13 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-08-04 19:14:13 +0200
commitc427f037ceae283d2ac0c15e50d6162eb82de62c (patch)
tree737463c331cded6ceb881783e59156026c7e6d97
parentee4ab86c3cbf8d03ea3bf0441943fc6928d91f09 (diff)
Improve procedure to close decorated Wayland window
Libdecor complicates what should be simple, to close a decorated window, because it uses the titlebar after return from the closing callback function. Thus, FLTK delays the sending of the FL_CLOSE event to the window, only when libdecor runs in CSD mode.
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index e6fa514ce..28001ff4f 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -885,19 +885,28 @@ void Fl_Wayland_Window_Driver::wait_for_expose()
}
}
+
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
// or after "Quit" of the application menu
// 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);
+ int X, Y = 0;
+ if (wl_win->kind == Fl_Wayland_Window_Driver::DECORATED) {
+ libdecor_frame_translate_coordinate(wl_win->frame, 0, 0, &X, &Y);
+ }
+ if (Y == 0) Fl::handle(FL_CLOSE, wl_win->fl_win);
+ else {
+ // 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);
+ }
}