summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-12-05 22:53:26 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-12-05 22:53:26 +0100
commit18ccbb4a4f68a5e974757701ce2553ebe9688ac4 (patch)
tree174736b31e014f8e975eb3a4f8b61adb2da54ecf /src
parent68594ec7fae90111e0b9270f0610bac3c6edfa7c (diff)
Wayland: much lighter but partial implementation of the "GTK Shell" protocol
Only the middle-button click gesture is implemented which avoids interference with what libdecor does with right-click and double-click.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx18
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx2
3 files changed, 20 insertions, 10 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb90aec75..be2634d62 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -709,17 +709,15 @@ if (UNIX AND OPTION_USE_WAYLAND)
list (APPEND STATIC_FILES "xdg-decoration-protocol.c")
list (APPEND SHARED_FILES "xdg-decoration-protocol.c")
endif (NOT OPTION_USE_SYSTEM_LIBDECOR)
- if (GTK_FOUND AND (OPTION_USE_SYSTEM_LIBDECOR OR OPTION_ALLOW_GTK_PLUGIN))
- add_custom_command(
+ add_custom_command(
OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h
COMMAND wayland-scanner private-code ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-protocol.c
COMMAND wayland-scanner client-header ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-client-protocol.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml
VERBATIM
- )
- list (APPEND STATIC_FILES "gtk-shell-protocol.c")
- list (APPEND SHARED_FILES "gtk-shell-protocol.c")
- endif (GTK_FOUND AND (OPTION_USE_SYSTEM_LIBDECOR OR OPTION_ALLOW_GTK_PLUGIN))
+ )
+ list (APPEND STATIC_FILES "gtk-shell-protocol.c")
+ list (APPEND SHARED_FILES "gtk-shell-protocol.c")
add_custom_command(
OUTPUT text-input-protocol.c text-input-client-protocol.h
COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-protocol.c
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 5b4d97cf2..1cf52a5cd 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -39,6 +39,7 @@
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
#include "text-input-client-protocol.h"
+#include "gtk-shell-client-protocol.h"
#include <assert.h>
#include <sys/mman.h>
#include <poll.h>
@@ -46,7 +47,6 @@
#include <string.h> // for strerror()
extern "C" {
bool libdecor_get_cursor_settings(char **theme, int *size);
- void bind_to_gtk_shell(struct wl_registry *, uint32_t);
}
@@ -87,6 +87,8 @@ struct pointer_output {
static Fl_Int_Vector key_vector; // used by Fl_Wayland_Screen_Driver::event_key()
+static struct gtk_shell1 *gtk_shell = NULL;
+static struct wl_surface *gtk_shell_surface = NULL;
Fl_Wayland_Screen_Driver::compositor_name Fl_Wayland_Screen_Driver::compositor =
Fl_Wayland_Screen_Driver::unspecified;
@@ -199,6 +201,7 @@ static Fl_Window *event_coords_from_surface(struct wl_surface *surface,
static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
Fl_Window *win = event_coords_from_surface(surface, surface_x, surface_y);
+ if (!win && gtk_shell) gtk_shell_surface = surface;
if (!win) return;
// use custom cursor if present
struct wl_cursor *cursor =
@@ -220,6 +223,7 @@ static void pointer_leave(void *data, struct wl_pointer *wl_pointer,
struct Fl_Wayland_Screen_Driver::seat *seat = (struct Fl_Wayland_Screen_Driver::seat*)data;
if (seat->pointer_focus == surface) seat->pointer_focus = NULL;
Fl_Window *win = Fl_Wayland_Window_Driver::surface_to_window(surface);
+ gtk_shell_surface = NULL;
if (win) {
Fl::belowmouse(0);
set_event_xy(win);
@@ -257,6 +261,15 @@ static void pointer_button(void *data,
{
struct Fl_Wayland_Screen_Driver::seat *seat =
(struct Fl_Wayland_Screen_Driver::seat*)data;
+ if (gtk_shell_surface && state == WL_POINTER_BUTTON_STATE_PRESSED &&
+ button == BTN_MIDDLE) {
+ struct gtk_surface1 *gtk_surface = gtk_shell1_get_gtk_surface(gtk_shell,
+ gtk_shell_surface);
+ gtk_surface1_titlebar_gesture(gtk_surface, serial, seat->wl_seat,
+ GTK_SURFACE1_GESTURE_MIDDLE_CLICK);
+ gtk_surface1_release(gtk_surface);
+ return;
+ }
seat->serial = serial;
int event = 0;
Fl_Window *win = Fl_Wayland_Window_Driver::surface_to_window(seat->pointer_focus);
@@ -1148,7 +1161,8 @@ static void registry_handle_global(void *user_data, struct wl_registry *wl_regis
Fl_Wayland_Screen_Driver::compositor = Fl_Wayland_Screen_Driver::MUTTER;
//fprintf(stderr, "Running the Mutter compositor\n");
if ( version >= 5) {
- bind_to_gtk_shell(wl_registry, id);
+ gtk_shell = (struct gtk_shell1*)wl_registry_bind(wl_registry, id,
+ &gtk_shell1_interface, 5);
}
} else if (strcmp(interface, "weston_desktop_shell") == 0) {
Fl_Wayland_Screen_Driver::compositor = Fl_Wayland_Screen_Driver::WESTON;
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 9082acf51..1345c17a2 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -44,7 +44,6 @@ struct cursor_image { // as in wayland-cursor.c of the Wayland project source co
extern "C" {
# include "../../../libdecor/src/libdecor-plugin.h"
uchar *fl_libdecor_titlebar_buffer(struct libdecor_frame *frame, int *w, int *h, int *stride);
- void use_FLTK_pointer_button(struct libdecor_frame *);
}
#define fl_max(a,b) ((a) > (b) ? (a) : (b))
@@ -854,7 +853,6 @@ static void handle_configure(struct libdecor_frame *frame,
#ifdef LIBDECOR_MR131
if (is_1st_run) use_FLTK_toplevel_configure_cb(frame);
#endif
- use_FLTK_pointer_button(frame);
struct wl_output *wl_output = NULL;
if (window->fl_win->fullscreen_active()) {
if (!(window->state & LIBDECOR_WINDOW_STATE_FULLSCREEN)) {