summaryrefslogtreecommitdiff
path: root/src/drivers/Wayland
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-11-07 06:49:40 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-11-07 06:49:40 +0100
commit37bf3835b0b3ce7f4c80924f40735698f057ef6f (patch)
tree5862a10eef97cf3575bfe55b2f29fc5a79ae3270 /src/drivers/Wayland
parentb663e272e7f39063a5c1bf744038ded0a7566990 (diff)
Create class Fl_Unix_Screen_Driver used by X11 and Wayland platforms
Diffstat (limited to 'src/drivers/Wayland')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.H7
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx74
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx2
-rw-r--r--src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx2
-rw-r--r--src/drivers/Wayland/fl_wayland_platform_init.cxx10
5 files changed, 79 insertions, 16 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
index aebc651ff..95c50fa0e 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
@@ -23,7 +23,7 @@
#ifndef FL_WAYLAND_SCREEN_DRIVER_H
#define FL_WAYLAND_SCREEN_DRIVER_H
-#include "../../Fl_Screen_Driver.H"
+#include "../Unix/Fl_Unix_Screen_Driver.H"
#include <wayland-client.h>
class Fl_Window;
@@ -54,7 +54,7 @@ struct seat {
struct zwp_text_input_v3 *text_input;
};
-class Fl_Wayland_Screen_Driver : public Fl_Screen_Driver
+class Fl_Wayland_Screen_Driver : public Fl_Unix_Screen_Driver
{
friend class Fl_Screen_Driver;
friend class Fl_Wayland_Graphics_Driver;
@@ -176,6 +176,9 @@ 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();
+ virtual void *control_maximize_button(void *data);
+ int event_key(int k);
+ int get_key(int k);
};
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 0ea7bad37..d0198c646 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -17,10 +17,7 @@
#include <config.h>
#include "Fl_Wayland_Screen_Driver.H"
#include "Fl_Wayland_Window_Driver.H"
-#include "Fl_Wayland_System_Driver.H"
-#if FLTK_USE_X11
-# include "../X11/Fl_X11_System_Driver.H"
-#endif
+#include "../Unix/Fl_Unix_System_Driver.H"
#include "Fl_Wayland_Graphics_Driver.H"
#include <wayland-cursor.h>
#include "../../../libdecor/src/libdecor.h"
@@ -1086,7 +1083,7 @@ static void fd_callback(int fd, struct wl_display *display) {
}
-Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Screen_Driver() {
+Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Unix_Screen_Driver() {
libdecor_context = NULL;
seat = NULL;
text_input_base = NULL;
@@ -1478,6 +1475,73 @@ void Fl_Wayland_Screen_Driver::display(const char *d)
}
+void *Fl_Wayland_Screen_Driver::control_maximize_button(void *data) {
+ // The code below aims at removing the calling window's fullscreen button
+ // while dialog runs. Unfortunately, it doesn't work with some X11 window managers
+ // (e.g., KDE, xfce) because the button goes away but doesn't come back,
+ // so we move this code to a virtual member function.
+ // Noticeably, this code works OK under Wayland.
+ struct win_dims {
+ Fl_Widget_Tracker *tracker;
+ int minw, minh, maxw, maxh;
+ struct win_dims *next;
+ };
+
+ if (!data) { // this call turns each decorated window's maximize button off
+ struct win_dims *first_dim = NULL;
+ // consider all bordered, top-level FLTK windows
+ Fl_Window *win = Fl::first_window();
+ while (win) {
+ if (!win->parent() && win->border() &&
+ !( ((struct wld_window*)Fl_X::i(win)->xid)->state & LIBDECOR_WINDOW_STATE_MAXIMIZED) ) {
+ win_dims *dim = new win_dims;
+ dim->tracker = new Fl_Widget_Tracker(win);
+ Fl_Window_Driver *dr = Fl_Window_Driver::driver(win);
+ dim->minw = dr->minw();
+ dim->minh = dr->minh();
+ dim->maxw = dr->maxw();
+ dim->maxh = dr->maxh();
+ //make win un-resizable
+ win->size_range(win->w(), win->h(), win->w(), win->h());
+ dim->next = first_dim;
+ first_dim = dim;
+ }
+ win = Fl::next_window(win);
+ }
+ return first_dim;
+ } else { // this call returns each decorated window's maximize button to its previous state
+ win_dims *first_dim = (win_dims *)data;
+ while (first_dim) {
+ win_dims *dim = first_dim;
+ //give back win its resizing parameters
+ if (dim->tracker->exists()) {
+ Fl_Window *win = (Fl_Window*)dim->tracker->widget();
+ win->size_range(dim->minw, dim->minh, dim->maxw, dim->maxh);
+ }
+ first_dim = dim->next;
+ delete dim->tracker;
+ delete dim;
+ }
+ return NULL;
+ }
+}
+
+
+int Fl_Wayland_Screen_Driver::event_key(int k) {
+ if (k > FL_Button && k <= FL_Button+8)
+ return Fl::event_state(8<<(k-FL_Button));
+ int sym = Fl::event_key();
+ if (sym >= 'a' && sym <= 'z' ) sym -= 32;
+ if (k >= 'a' && k <= 'z' ) k -= 32;
+ return (Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) && sym == k;
+}
+
+
+int Fl_Wayland_Screen_Driver::get_key(int k) {
+ return event_key(k);
+}
+
+
struct wl_display *fl_wl_display() {
if (!Fl_Wayland_Screen_Driver::wl_display || !Fl_Wayland_Screen_Driver::wl_registry) return NULL;
return Fl_Wayland_Screen_Driver::wl_display;
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 3b1e7bbf8..98ee9dcfe 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -19,7 +19,7 @@
#include "Fl_Wayland_Window_Driver.H"
#include "Fl_Wayland_Screen_Driver.H"
#include "Fl_Wayland_Graphics_Driver.H"
-#include "Fl_Wayland_System_Driver.H"
+#include "../Unix/Fl_Unix_System_Driver.H"
#include <wayland-cursor.h>
#include "../../../libdecor/src/libdecor.h"
#include "xdg-shell-client-protocol.h"
diff --git a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
index 38b7a1bb7..12ec62c51 100644
--- a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
+++ b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
@@ -27,7 +27,7 @@
# include "../../flstring.h"
# include "Fl_Wayland_Screen_Driver.H"
# include "Fl_Wayland_Window_Driver.H"
-# include "Fl_Wayland_System_Driver.H"
+# include "../Unix/Fl_Unix_System_Driver.H"
# include "Fl_Wayland_Graphics_Driver.H"
# include <errno.h>
diff --git a/src/drivers/Wayland/fl_wayland_platform_init.cxx b/src/drivers/Wayland/fl_wayland_platform_init.cxx
index 88b863b20..01d49ccb5 100644
--- a/src/drivers/Wayland/fl_wayland_platform_init.cxx
+++ b/src/drivers/Wayland/fl_wayland_platform_init.cxx
@@ -14,11 +14,11 @@
// https://www.fltk.org/bugs.php
//
-
+#include <config.h>
#include "Fl_Wayland_Copy_Surface_Driver.H"
#include "Fl_Wayland_Graphics_Driver.H"
#include "Fl_Wayland_Screen_Driver.H"
-#include "Fl_Wayland_System_Driver.H"
+#include "../Unix/Fl_Unix_System_Driver.H"
#include "Fl_Wayland_Window_Driver.H"
#include "Fl_Wayland_Image_Surface_Driver.H"
#if FLTK_USE_X11
@@ -26,7 +26,6 @@
# include <cairo-xlib.h>
# include "../Cairo/Fl_Display_Cairo_Graphics_Driver.H"
# include "../X11/Fl_X11_Screen_Driver.H"
-# include "../X11/Fl_X11_System_Driver.H"
# include "../X11/Fl_X11_Window_Driver.H"
# include "../Xlib/Fl_Xlib_Image_Surface_Driver.H"
#endif
@@ -114,10 +113,7 @@ static bool attempt_wayland() {
Fl_System_Driver *Fl_System_Driver::newSystemDriver() {
-#if FLTK_USE_X11
- if (!attempt_wayland()) return new Fl_X11_System_Driver();
-#endif
- return new Fl_Wayland_System_Driver();
+ return new Fl_Unix_System_Driver();
}