FLTK logo

[master] 5701313 - Hybrid Wayland/X11: remove setenv() call from Fl_Wayland_System_Driver::disable_wayland().

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] 5701313 - Hybrid Wayland/X11: remove setenv() call from Fl_Wayland_System_Driver::disable_wayland(). "ManoloFLTK" Aug 31, 2022  
 
commit 57013133406c1d263078d75c06565eebb8e9445e
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Aug 31 08:56:56 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Aug 31 08:56:56 2022 +0200

    Hybrid Wayland/X11: remove setenv() call from Fl_Wayland_System_Driver::disable_wayland().

 src/drivers/Wayland/Fl_Wayland_Screen_Driver.H   | 2 +-
 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 9 +++++----
 src/drivers/Wayland/Fl_Wayland_System_Driver.cxx | 3 +--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.H src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
index d5196b5..f0f01ca 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
@@ -174,7 +174,7 @@ public:
   static compositor_name compositor; // identifies the used Wayland compositor
   void set_spot(int font, int height, int x, int y, int w, int h, Fl_Window *win);
   void reset_spot();
-  static bool undo_wayland_backend_if_needed();
+  static bool undo_wayland_backend_if_needed(const char *backend = NULL);
 };
 
 
diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index cc6d1b4..29a0371 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -18,6 +18,7 @@
 #include "Fl_Wayland_Screen_Driver.H"
 #include "Fl_Wayland_Window_Driver.H"
 #include "Fl_Wayland_System_Driver.H"
+#include "../X11/Fl_X11_System_Driver.H"
 #include "Fl_Wayland_Graphics_Driver.H"
 #include <wayland-cursor.h>
 #include "../../../libdecor/src/libdecor.h"
@@ -1088,13 +1089,13 @@ Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Screen_Driver() {
 }
 
 
-bool Fl_Wayland_Screen_Driver::undo_wayland_backend_if_needed() {
-  const char *backend = getenv("FLTK_BACKEND");
+bool Fl_Wayland_Screen_Driver::undo_wayland_backend_if_needed(const char *backend) {
+  if (!backend) backend = getenv("FLTK_BACKEND");
   if (wl_display && backend && strcmp(backend, "x11") == 0) {
     wl_display_disconnect(wl_display);
     wl_display = NULL;
-    delete Fl_Screen_Driver::system_driver;
-    Fl_Screen_Driver::system_driver = NULL;
+    if (Fl_Screen_Driver::system_driver) delete Fl_Screen_Driver::system_driver;
+    Fl_Screen_Driver::system_driver = new Fl_X11_System_Driver();
     return true;
   }
   return false;
diff --git src/drivers/Wayland/Fl_Wayland_System_Driver.cxx src/drivers/Wayland/Fl_Wayland_System_Driver.cxx
index 158c561..c47ff56 100644
--- src/drivers/Wayland/Fl_Wayland_System_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_System_Driver.cxx
@@ -101,6 +101,5 @@ void Fl_Wayland_System_Driver::disable_wayland() {
             "or a Wayland window was created or the Wayland screen was accessed\n");
     exit(1);
   }
-  setenv("FLTK_BACKEND", "x11", 1);
-  Fl_Wayland_Screen_Driver::undo_wayland_backend_if_needed();
+  Fl_Wayland_Screen_Driver::undo_wayland_backend_if_needed("x11");
 }
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'.