Skip to content

Commit

Permalink
Wayland: fix interactive moving and resizing of a subwindow - cont'd (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
ManoloFLTK committed Jul 3, 2024
1 parent 944ae5b commit fc910ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 15 additions & 23 deletions src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit fc910ae

Please sign in to comment.