From d5eea426454adf6ecb9be41c33f8413f7c307d75 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:22:13 +0100 Subject: [PATCH] Wayland: fix computation of wld_scale parameter for GL subwindows - cont'd (#1382) --- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 11 ++++++++--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 9 ++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index d20b941b7..f782b744a 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -1,7 +1,7 @@ // // Class Fl_Wayland_Gl_Window_Driver for the Fast Light Tool Kit (FLTK). // -// Copyright 2021-2023 by Bill Spitzak and others. +// Copyright 2021-2026 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -271,6 +271,10 @@ void Fl_Wayland_Gl_Window_Driver::make_current_before() { if (!egl_window) { struct wld_window *win = fl_wl_xid(pWindow); struct wl_surface *surface = win->wl_surface; + if (pWindow->parent()) { // force toplevel win to enter its display before sizing GL subwin + win = fl_wl_xid(pWindow->top_window()); + while (wl_list_empty(&win->outputs)) wl_display_dispatch(fl_wl_display()); + } int W = pWindow->pixel_w(); int H = pWindow->pixel_h(); int scale = Fl_Wayland_Window_Driver::driver(pWindow)->wld_scale(); @@ -285,8 +289,9 @@ void Fl_Wayland_Gl_Window_Driver::make_current_before() { // Tested apps: shape, glpuzzle, cube, fractals, gl_overlay, fullscreen, unittests, // OpenGL3-glut-test, OpenGL3test. // Tested wayland compositors: mutter, kde-plasma, weston, sway on FreeBSD. - if (pWindow->parent()) win = fl_wl_xid(pWindow->top_window()); - while (wl_list_empty(&win->outputs)) wl_display_dispatch(fl_wl_display()); + if (!pWindow->parent()) { // force toplevel GL win to enter its display + while (wl_list_empty(&win->outputs)) wl_display_dispatch(fl_wl_display()); + } } } diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index feb13645a..b556a6729 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -736,9 +736,8 @@ static void surface_enter(void *data, struct wl_surface *wl_surface, struct wl_list *e = &window->outputs; while (e->next != &window->outputs) e = e->next; // move e to end of linked list wl_list_insert(e, &surface_output->link); -//printf("window %p enters screen id=%d length=%d\n", window->fl_win, output->id, wl_list_length(&window->outputs)); - if (list_was_empty && (!window->fl_win->parent() || window->fl_win->as_gl_window()) && - !window->fl_win->menu_window()) { +//printf("%swindow %p enters screen id=%d length=%d\n", window->fl_win->parent()?"(sub)":"", window->fl_win, output->id, wl_list_length(&window->outputs)); + if (list_was_empty && !window->fl_win->parent() && !window->fl_win->menu_window()) { change_scale(output, window, 0); } } @@ -2131,11 +2130,11 @@ int Fl_Wayland_Window_Driver::wld_scale() { struct wld_window *xid = (flx ? (struct wld_window *)flx->xid : NULL); if (!xid || wl_list_empty(&xid->outputs)) { int scale = 1; - /*Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); + Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); Fl_Wayland_Screen_Driver::output *output; wl_list_for_each(output, &(scr_driver->outputs), link) { scale = fl_max(scale, output->wld_scale); - }*/ + } return scale; } struct surface_output *s_output;