[master] c7d2c0b - Waayland: improve use of frame callbacks by GL windows.
"ManoloFLTK"
15:32 Oct 05
commit c7d2c0b80fb7676c812438f212c315bebbae8d31
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Oct 5 17:28:25 2026 +0200
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Oct 5 17:28:25 2026 +0200
Waayland: improve use of frame callbacks by GL windows.
documentation/src/wayland.dox | 25 +++++++++------------
.../Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 26 ++++++----------------
src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 5 -----
3 files changed, 18 insertions(+), 38 deletions(-)
diff --git documentation/src/wayland.dox documentation/src/wayland.dox
index 2e71e33..44557d1 100644
--- documentation/src/wayland.dox
+++ documentation/src/wayland.dox
@@ -1353,20 +1353,17 @@ For example, \c Fl_Wayland_Window_Driver::flush() needs to call
<h3>Throttling GL window redraws</h3>
Although no documentation covering this subject was found, the EGL library internally
-uses \c wl_callback objects to throttle GL window redraws, and FLTK needs not interfere with
-these operations. Nevertheless FLTK creates and uses \c wl_callback objects for GL windows in 2 cases:
-- when a decorated GL window is being interactively resized.
-Function \c Fl_Wayland_Gl_Window_Driver::resize() creates a \c wl_callback object,
-assigns it to xid->frame_cb and calls \c wl_callback_add_listener() before calling
-\c wl_egl_window_resize(). This allows the mechanism described above that prevents surfaces from
-being resized too frequently to operate with decorated \c Fl_GL_Window's too.
-- when a GL subwindow is being refreshed by \c Fl_Wayland_Gl_Window_Driver::swap_buffers().
-FLTK checks that \c xid->frame_cb is NULL and if so creates a \c wl_callback calling
-\c wl_surface_frame() before calling \c eglSwapBuffers(). This is useful if the GL subwindow
-becomes entirely out from the screen area. In that case, the Mutter compositor stops signaling
-that the subwindow is ready for new commits which FLTK detects because \c xid->frame_cb remains
-non-NULL. If the subwindow eventually re-appears partially on-screen, \c xid->frame_cb
-becomes NULL and FLTK calls \c eglSwapBuffers() to redraw the GL scene.
+uses \c wl_callback objects to throttle GL window redraws, and FLTK has no access to
+these operations.
+
+Nevertheless FLTK creates and uses \c wl_callback objects for GL windows
+in function \c Fl_Wayland_Gl_Window_Driver::swap_buffers(), the unique
+function in FLTK to trigger the redraw of a GL scene via a call to \c eglSwapBuffers().
+FLTK checks the window's \c xid->frame_cb is NULL before
+calling \c eglSwapBuffers(). This prevents FLTK from blocking in \c eglSwapBuffers()
+when \c Fl_Wayland_Gl_Window_Driver::swap_buffers() calls arrive more rapidly
+than the system can update its display, or when a GL subwindow disappears entirely
+from the display or becomes hidden behind another window.
\section wayland-type FLTK-defined, Wayland-specific types
diff --git src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
index 2781010..6e33b03 100644
--- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
@@ -360,19 +360,13 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
}
if (egl_surface) {
- Fl_Window *parent = pWindow->parent() ? pWindow->window() : NULL;
- struct wld_window *parent_xid = parent ? fl_wl_xid(parent) : NULL;
- if (parent_xid) { // issue #967
- struct wld_window *xid = fl_wl_xid(pWindow);
- if (xid->frame_cb) {
- need_swap = true;
- return;
- }
- if (!parent_xid->frame_cb) {
- xid->frame_cb = wl_surface_frame(xid->wl_surface);
- wl_callback_add_listener(xid->frame_cb, &surface_frame_listener, this);
- }
+ struct wld_window *xid = fl_wl_xid(pWindow);
+ if (xid->frame_cb) {
+ need_swap = true;
+ return;
}
+ xid->frame_cb = wl_surface_frame(xid->wl_surface);
+ wl_callback_add_listener(xid->frame_cb, &surface_frame_listener, this);
eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface);
need_swap = false;
}
@@ -424,14 +418,8 @@ void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
int W2, H2;
wl_egl_window_get_attached_size(egl_window, &W2, &H2);
if (W2 != W || H2 != H) {
- struct wld_window *xid = fl_wl_xid(pWindow);
- if (xid->kind == Fl_Wayland_Window_Driver::DECORATED && !xid->frame_cb) {
- xid->frame_cb = wl_surface_frame(xid->wl_surface);
- wl_callback_add_listener(xid->frame_cb,
- Fl_Wayland_Graphics_Driver::p_surface_frame_listener, xid);
- }
wl_egl_window_resize(egl_window, W, H, 0, 0);
- wl_surface_set_buffer_scale(xid->wl_surface, s);
+ wl_surface_set_buffer_scale(fl_wl_xid(pWindow)->wl_surface, s);
}
/* CONTROL_LEAKING_SUB_GL_WINDOWS
if (Fl_Wayland_Window_Driver::driver(pWindow)->subRect()) {
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index b892e7d..788721a 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -956,11 +956,6 @@ static void handle_configure(struct libdecor_frame *frame,
}
if (!libdecor_configuration_get_window_state(configuration, &window_state))
window_state = LIBDECOR_WINDOW_STATE_NONE;
- if ((window->state & LIBDECOR_WINDOW_STATE_FULLSCREEN) &&
- !(window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) && !window->fl_win->border()) {
- // necessary so Mutter correctly positions borderless window back from fullscreen
- window->fl_win->redraw();
- }
window->state = window_state;
// Weston, KWin, and some old versions of Mutter, on purpose, don't set the
Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.