FLTK logo

[master] 1f53b9e - Wayland platform: improve Fl_Gl_Window resize operations.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 1f53b9e - Wayland platform: improve Fl_Gl_Window resize operations. "ManoloFLTK" Aug 17, 2022  
 
commit 1f53b9e203b41ca0614c51534df9bac4177a451c
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Aug 17 09:26:40 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Aug 17 09:26:40 2022 +0200

    Wayland platform: improve Fl_Gl_Window resize operations.

 src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H  |  2 +-
 .../Wayland/Fl_Wayland_Gl_Window_Driver.cxx        | 28 ++++++++++++----------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
index 2241c5e..2dcc0c2 100644
--- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
+++ src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
@@ -36,7 +36,7 @@ Consequently, FL_DOUBLE is enforced in all Fl_Gl_Window::mode_ values under Wayl
 class Fl_Wayland_Gl_Window_Driver : public Fl_Gl_Window_Driver {
   friend Fl_Gl_Window_Driver* Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *);
   friend class Fl_Wayland_Gl_Plugin;
-  bool egl_resize_in_progress;
+  bool egl_swap_in_progress;
   Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win);
   virtual float pixels_per_unit();
   virtual void make_current_before();
diff --git src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
index 10b6d61..ce969b3 100644
--- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
@@ -64,7 +64,7 @@ Fl_Wayland_Gl_Window_Driver::Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win) : Fl
   if (egl_display == EGL_NO_DISPLAY) init();
   egl_window = NULL;
   egl_surface = NULL;
-  egl_resize_in_progress = false;
+  egl_swap_in_progress = false;
 }
 
 
@@ -322,19 +322,16 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
     if (!overlay_buffer) return; // don't call eglSwapBuffers until overlay has been drawn
   }
 
-  if (egl_surface) {
+  if (egl_surface && !egl_swap_in_progress) {
+    egl_swap_in_progress = true;
     //eglSwapInterval(egl_display, 0); // doesn't seem to have any effect in this context
-    if (!egl_resize_in_progress) {
-      while (wl_display_prepare_read(Fl_Wayland_Screen_Driver::wl_display) != 0) {
-        wl_display_dispatch_pending(Fl_Wayland_Screen_Driver::wl_display);
-      }
-      wl_display_read_events(Fl_Wayland_Screen_Driver::wl_display);
-      wl_display_dispatch_queue_pending(Fl_Wayland_Screen_Driver::wl_display,  gl_event_queue);
+    while (wl_display_prepare_read(Fl_Wayland_Screen_Driver::wl_display) != 0) {
+      wl_display_dispatch_pending(Fl_Wayland_Screen_Driver::wl_display);
     }
-    if (!egl_resize_in_progress || pWindow->parent()) {
-       eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface);
-    }
-    egl_resize_in_progress = false;
+    wl_display_read_events(Fl_Wayland_Screen_Driver::wl_display);
+    wl_display_dispatch_queue_pending(Fl_Wayland_Screen_Driver::wl_display,  gl_event_queue);
+    eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface);
+    egl_swap_in_progress = false;
   }
 }
 
@@ -366,6 +363,9 @@ public:
 
 static Fl_Wayland_Gl_Plugin Gl_Overlay_Plugin;
 
+static void delayed_flush(Fl_Gl_Window *win) {
+  win->flush();
+}
 
 void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
   if (!egl_window) return;
@@ -378,7 +378,9 @@ void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
   if (W2 != W || H2 != H) {
     wl_egl_window_resize(egl_window, W, H, 0, 0);
     //fprintf(stderr, "Fl_Wayland_Gl_Window_Driver::resize to %dx%d\n", W, H);
-    if (!Fl_Window::is_a_rescale()) egl_resize_in_progress = true;
+    if (!pWindow->parent()) {
+        Fl::add_timeout(0.01, (Fl_Timeout_Handler)delayed_flush, pWindow);
+    }
   }
 }
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.