From 57013133406c1d263078d75c06565eebb8e9445e Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:56:56 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index d5196b557..f0f01ca1f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/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 a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index cc6d1b4ce..29a037171 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/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 #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 a/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx index 158c5619a..c47ff56cf 100644 --- a/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx +++ b/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"); } -- cgit v1.2.3