From fc910ae892b58afaac5a1d1181757fac28ccfb20 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:57:55 +0200 Subject: [PATCH] Wayland: fix interactive moving and resizing of a subwindow - cont'd (#1003) --- .../Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 2 +- .../Wayland/Fl_Wayland_Window_Driver.cxx | 38 ++++++++----------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index d25738ab3..56fc55535 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -328,7 +328,7 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() { } if (egl_surface) { - if (pWindow->parent()) { + if (pWindow->parent()) { // issue #976 struct wld_window *xid = fl_wl_xid(pWindow); if (xid->frame_cb) return; xid->frame_cb = wl_surface_frame(xid->wl_surface); diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 8f8eb12b8..ffc97ceae 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1792,22 +1792,17 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) { if (shown() && !(parent() || popup_window())) { X = Y = 0; } - struct wld_window *parent_xid = parent() ? fl_wl_xid(pWindow->window()) : NULL; - // This condition delays application of new X,Y,W,H values if - // a non-GL subwindow is being committed. - if (!parent_xid || !parent_xid->frame_cb || pWindow->as_gl_window()) { - if (is_a_resize) { - if (pWindow->parent()) { - if (W < 1) W = 1; - if (H < 1) H = 1; - } - pWindow->Fl_Group::resize(X,Y,W,H); - //fprintf(stderr, "resize: win=%p to %dx%d\n", pWindow, W, H); - if (shown()) {pWindow->redraw();} - } else { - x(X); y(Y); - //fprintf(stderr, "move win=%p to %dx%d\n", pWindow, X, Y); + if (is_a_resize) { + if (pWindow->parent()) { + if (W < 1) W = 1; + if (H < 1) H = 1; } + pWindow->Fl_Group::resize(X,Y,W,H); + //fprintf(stderr, "resize: win=%p to %dx%d\n", pWindow, W, H); + if (shown()) {pWindow->redraw();} + } else { + x(X); y(Y); + //fprintf(stderr, "move win=%p to %dx%d\n", pWindow, X, Y); } if (shown()) { @@ -1865,15 +1860,12 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) { } } + struct wld_window *parent_xid = parent() ? fl_wl_xid(pWindow->window()) : NULL; if (fl_win && parent_xid) { - if (!parent_xid->frame_cb && !pWindow->as_gl_window()) { - // Interactive move or resize of a subwindow requires to commit the parent surface - // and requires to make sure the parent surface is ready to accept a new commit (#987). - parent_xid->frame_cb = wl_surface_frame(parent_xid->wl_surface); - wl_callback_add_listener(parent_xid->frame_cb, - Fl_Wayland_Graphics_Driver::p_surface_frame_listener, parent_xid); - wl_surface_commit(parent_xid->wl_surface); - } + if (pWindow->as_gl_window() && fl_win->frame_cb) { + wl_callback_destroy(fl_win->frame_cb); + fl_win->frame_cb = NULL; + } else wl_surface_commit(parent_xid->wl_surface); checkSubwindowFrame(); // make sure subwindow doesn't leak outside parent } }