summaryrefslogtreecommitdiff
path: root/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-08-30 17:37:55 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-08-30 17:37:55 +0200
commit07fd2628febb512192239cc252087deb62da4866 (patch)
tree895f2bd612078f0babcf2b5a09228806b92e6fb9 /src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
parentfcdc2f0e102497313232cc7c0a570cc4c524a02b (diff)
Hybrid Wayland/X11 platform: improve control of chosen backend.
Diffstat (limited to 'src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index cdfc88e80..cc6d1b4ce 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -230,8 +230,6 @@ struct wl_display *Fl_Wayland_Screen_Driver::wl_display = NULL;
struct wl_registry *Fl_Wayland_Screen_Driver::wl_registry = NULL;
-bool Fl_Wayland_Screen_Driver::wld_disabled = false;
-
Fl_Window *Fl_Wayland_Screen_Driver::surface_to_window(struct wl_surface *surface) {
if (surface) {
Fl_X *xp = Fl_X::first;
@@ -1089,12 +1087,31 @@ Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Screen_Driver() {
reset_cursor();
}
+
+bool Fl_Wayland_Screen_Driver::undo_wayland_backend_if_needed() {
+ const char *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;
+ return true;
+ }
+ return false;
+}
+
+
void Fl_Wayland_Screen_Driver::open_display_platform() {
static bool beenHereDoneThat = false;
if (beenHereDoneThat)
return;
beenHereDoneThat = true;
+ if (undo_wayland_backend_if_needed()) {
+ Fl::screen_driver()->open_display();
+ return;
+ }
+
if (!wl_display) {
wl_display = wl_display_connect(NULL);
if (!wl_display) {
@@ -1116,6 +1133,8 @@ void Fl_Wayland_Screen_Driver::open_display_platform() {
}*/
Fl::add_fd(wl_display_get_fd(wl_display), FL_READ, (Fl_FD_Handler)fd_callback, wl_display);
fl_create_print_window();
+ Fl_Wayland_System_Driver::too_late_to_disable = true;
+puts("Using Wayland backend");
}
void Fl_Wayland_Screen_Driver::close_display() {