FLTK logo

[master] d5a1e7f - Add static Fl_Wayland_Window_Driver::gl_plugin() member function.

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] d5a1e7f - Add static Fl_Wayland_Window_Driver::gl_plugin() member function. "ManoloFLTK" Aug 20, 2022  
 
commit d5a1e7feb98f0d3efc17ea755a5f94d008cd4f80
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sat Aug 20 17:26:02 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sat Aug 20 17:26:02 2022 +0200

    Add static Fl_Wayland_Window_Driver::gl_plugin() member function.

 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx |  3 +--
 src/drivers/Wayland/Fl_Wayland_Window_Driver.H   |  3 +++
 src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 30 ++++++++++--------------
 3 files changed, 17 insertions(+), 19 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 57d43c6..6a185ed 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -1115,8 +1115,7 @@ void Fl_Wayland_Screen_Driver::open_display_platform() {
 }
 
 void Fl_Wayland_Screen_Driver::close_display() {
-  Fl_Plugin_Manager pm("wayland.fltk.org");
-  Fl_Wayland_Plugin *plugin = (Fl_Wayland_Plugin*)pm.plugin("gl.wayland.fltk.org");
+  Fl_Wayland_Plugin *plugin = Fl_Wayland_Window_Driver::gl_plugin();
   if (plugin) plugin->terminate();
 
   Fl::remove_fd(wl_display_get_fd(Fl_Wayland_Screen_Driver::wl_display));
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.H src/drivers/Wayland/Fl_Wayland_Window_Driver.H
index 2a76b86..a419fa5 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.H
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.H
@@ -41,12 +41,14 @@
  */
 
 typedef struct _cairo_pattern cairo_pattern_t;
+class Fl_Wayland_Plugin;
 
 
 class Fl_Wayland_Window_Driver : public Fl_Window_Driver
 {
   friend class Fl_X;
   friend class Fl_Wayland_Gl_Window_Driver;
+  friend class Fl_Wayland_Screen_Driver;
 private:
   struct shape_data_type {
     int lw_; ///<  width of shape image
@@ -55,6 +57,7 @@ private:
     cairo_pattern_t *mask_pattern_;
   } *shape_data_;
   static bool in_flush; // useful for progressive window drawing
+  static Fl_Wayland_Plugin *gl_plugin();
   struct wl_cursor *cursor_;
   void delete_cursor_();
   struct gl_start_support *gl_start_support_; // for support of gl_start/gl_finish
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index d9b6d14..b935fe6 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -98,14 +98,7 @@ Fl_Wayland_Window_Driver::~Fl_Wayland_Window_Driver()
   }
   delete_cursor_();
   if (gl_start_support_) { // occurs only if gl_start/gl_finish was used
-    static Fl_Wayland_Plugin *plugin = NULL;
-    if (!plugin) {
-      Fl_Plugin_Manager pm("wayland.fltk.org");
-      plugin = (Fl_Wayland_Plugin*)pm.plugin("gl.wayland.fltk.org");
-    }
-    if (plugin) {
-      plugin->destroy(gl_start_support_);
-    }
+    gl_plugin()->destroy(gl_start_support_);
   }
 }
 
@@ -388,15 +381,8 @@ void Fl_Wayland_Window_Driver::flush() {
     Fl_Wayland_Window_Driver::in_flush = true;
     Fl_Window_Driver::flush();
     Fl_Wayland_Window_Driver::in_flush = false;
-    static Fl_Wayland_Plugin *plugin = NULL;
-    if (!plugin) {
-      Fl_Plugin_Manager pm("wayland.fltk.org");
-      plugin = (Fl_Wayland_Plugin*)pm.plugin("gl.wayland.fltk.org");
-    }
-    if (plugin) {
-      plugin->do_swap(pWindow); // useful only for GL win with overlay
-      if (scale != fl_graphics_driver->scale() || W != pWindow->w() || H != pWindow->h()) plugin->invalidate(pWindow);
-    }
+    gl_plugin()->do_swap(pWindow); // useful only for GL win with overlay
+    if (scale != fl_graphics_driver->scale() || W != pWindow->w() || H != pWindow->h()) gl_plugin()->invalidate(pWindow);
     return;
   }
   struct wld_window *window = fl_xid(pWindow);
@@ -1531,3 +1517,13 @@ cairo_t *fl_wl_cairo() {
 struct wl_display *fl_wl_display() {
   return Fl_Wayland_Screen_Driver::wl_display;
 }
+
+
+Fl_Wayland_Plugin *Fl_Wayland_Window_Driver::gl_plugin() {
+  static Fl_Wayland_Plugin *plugin = NULL;
+  if (!plugin) {
+    Fl_Plugin_Manager pm("wayland.fltk.org");
+    plugin = (Fl_Wayland_Plugin*)pm.plugin("gl.wayland.fltk.org");
+  }
+  return plugin;
+}
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'.