From 72396f7ecd385cf514a229e1b44191cdf590d0c1 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:36:52 +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 | 12 +++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index 0dd315002..0a1e79d9d 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 @@ -266,6 +266,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(); @@ -280,8 +284,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()) { + 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 cb28755f7..ad7284b1f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1,7 +1,7 @@ // // Implementation of the Wayland window driver. // -// Copyright 1998-2024 by Bill Spitzak and others. +// Copyright 1998-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 @@ -723,7 +723,7 @@ static void surface_enter(void *data, struct wl_surface *wl_surface, 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()) { + if (list_was_empty && !window->fl_win->parent() && !window->fl_win->menu_window()) { change_scale(output, window, pre_scale); } } @@ -2122,7 +2122,13 @@ int Fl_Wayland_Window_Driver::wld_scale() { Fl_X *flx = Fl_X::flx(pWindow->top_window()); struct wld_window *xid = (flx ? (struct wld_window *)flx->xid : NULL); if (!xid || wl_list_empty(&xid->outputs)) { - return 1; + int scale = 1; + 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; s_output = wl_container_of(xid->outputs.next, s_output, link);