diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-11-07 11:32:12 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-11-07 11:32:12 +0100 |
| commit | 8b31954d6698bded12d6252b1bbc46c6eece7f73 (patch) | |
| tree | 1658b22823dc36745ed9f882d01582e03fbae2d3 | |
| parent | c86ca1a9fc3bb8b09eb429458b2ecf68b62cd1de (diff) | |
"hitting esc to close fltk app blows out the window manager" (#821)
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 7dfbe0376..c56d74744 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -1262,6 +1262,13 @@ static const struct wl_callback_listener sync_listener = { }; +static void do_atexit() { + if (Fl_Wayland_Screen_Driver::wl_display) { + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); + } +} + + void Fl_Wayland_Screen_Driver::open_display_platform() { static bool beenHereDoneThat = false; if (beenHereDoneThat) @@ -1286,10 +1293,19 @@ void Fl_Wayland_Screen_Driver::open_display_platform() { Fl::add_fd(wl_display_get_fd(wl_display), FL_READ, (Fl_FD_Handler)wayland_socket_callback, wl_display); fl_create_print_window(); + /* This is useful to avoid crash of the Wayland compositor after + FLTK apps terminate in certain situations: + - gnome-shell version < 44 (e.g. version 42.9) + - focus set to "follow-mouse" + See issue #821 for details. + */ + atexit(do_atexit); } void Fl_Wayland_Screen_Driver::close_display() { + if (!Fl_Wayland_Screen_Driver::wl_display) return; + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); if (text_input_base) { disable_im(); zwp_text_input_manager_v3_destroy(text_input_base); |
