mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 22:04:26 +08:00
FLTK implementation of the "GTK Shell" Wayland protocol - cont'd
The pointer_enter() function now checks that its non-FLTK wl_surface argument is the wl_surface of the titlebar of a GTK-decorated window.
This commit is contained in:
@@ -236,13 +236,7 @@ static unsigned char *gtk_titlebar_buffer(struct libdecor_frame *frame,
|
|||||||
int *width, int *height, int *stride)
|
int *width, int *height, int *stride)
|
||||||
{
|
{
|
||||||
struct libdecor_frame_gtk *lfg = (struct libdecor_frame_gtk *)frame;
|
struct libdecor_frame_gtk *lfg = (struct libdecor_frame_gtk *)frame;
|
||||||
#if USE_SYSTEM_LIBDECOR || !HAVE_GTK
|
struct buffer *buffer = lfg->headerbar.buffer;
|
||||||
struct border_component_gtk *bc;
|
|
||||||
#else
|
|
||||||
struct border_component *bc;
|
|
||||||
#endif
|
|
||||||
bc = &lfg->headerbar;
|
|
||||||
struct buffer *buffer = bc->buffer;
|
|
||||||
*width = buffer->buffer_width;
|
*width = buffer->buffer_width;
|
||||||
*height = buffer->buffer_height;
|
*height = buffer->buffer_height;
|
||||||
*stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, buffer->buffer_width);
|
*stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, buffer->buffer_width);
|
||||||
@@ -313,6 +307,15 @@ static const char *get_libdecor_plugin_description(struct libdecor_frame *frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *plugin_name(struct libdecor_frame *frame) {
|
||||||
|
static const char *my_plugin = NULL;
|
||||||
|
if (!my_plugin) {
|
||||||
|
my_plugin = get_libdecor_plugin_description(frame);
|
||||||
|
if (!my_plugin) my_plugin = "unknown";
|
||||||
|
}
|
||||||
|
return my_plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FLTK-added utility function to give access to the pixel array representing
|
FLTK-added utility function to give access to the pixel array representing
|
||||||
the titlebar of a window decorated by the cairo plugin of libdecor.
|
the titlebar of a window decorated by the cairo plugin of libdecor.
|
||||||
@@ -324,13 +327,22 @@ static const char *get_libdecor_plugin_description(struct libdecor_frame *frame)
|
|||||||
unsigned char *fl_libdecor_titlebar_buffer(struct libdecor_frame *frame,
|
unsigned char *fl_libdecor_titlebar_buffer(struct libdecor_frame *frame,
|
||||||
int *width, int *height, int *stride)
|
int *width, int *height, int *stride)
|
||||||
{
|
{
|
||||||
static const char *my_plugin = NULL;
|
const char *name = plugin_name(frame);
|
||||||
if (!my_plugin) my_plugin = get_libdecor_plugin_description(frame);
|
if (!strcmp(name, "GTK3 plugin")) {
|
||||||
if (my_plugin && !strcmp(my_plugin, "GTK3 plugin")) {
|
|
||||||
return gtk_titlebar_buffer(frame, width, height, stride);
|
return gtk_titlebar_buffer(frame, width, height, stride);
|
||||||
}
|
}
|
||||||
else if (my_plugin && !strcmp(my_plugin, "libdecor plugin using Cairo")) {
|
else if (!strcmp(name, "libdecor plugin using Cairo")) {
|
||||||
return cairo_titlebar_buffer(frame, width, height, stride);
|
return cairo_titlebar_buffer(frame, width, height, stride);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* returns the wl_surface of the window's headerbar for GTK */
|
||||||
|
struct wl_surface *fl_headerbar_surface(struct libdecor_frame *frame) {
|
||||||
|
if (!strcmp(plugin_name(frame), "GTK3 plugin")) {
|
||||||
|
struct libdecor_frame_gtk *lfg = (struct libdecor_frame_gtk *)frame;
|
||||||
|
return lfg->headerbar.wl_surface;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <string.h> // for strerror()
|
#include <string.h> // for strerror()
|
||||||
extern "C" {
|
extern "C" {
|
||||||
bool libdecor_get_cursor_settings(char **theme, int *size);
|
bool libdecor_get_cursor_settings(char **theme, int *size);
|
||||||
|
struct wl_surface *fl_headerbar_surface(struct libdecor_frame *frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -201,7 +202,18 @@ 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,
|
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) {
|
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);
|
Fl_Window *win = event_coords_from_surface(surface, surface_x, surface_y);
|
||||||
if (!win && gtk_shell) gtk_shell_surface = surface;
|
if (!win && gtk_shell) { // check that surface is the headerbar of a GTK-decorated window
|
||||||
|
Fl_X *x = Fl_X::first;
|
||||||
|
while (x) {
|
||||||
|
struct wld_window *xid = (struct wld_window*)x->xid;
|
||||||
|
if (xid->kind == Fl_Wayland_Window_Driver::DECORATED &&
|
||||||
|
surface == fl_headerbar_surface(xid->frame)) {
|
||||||
|
gtk_shell_surface = surface;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x = x->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!win) return;
|
if (!win) return;
|
||||||
// use custom cursor if present
|
// use custom cursor if present
|
||||||
struct wl_cursor *cursor =
|
struct wl_cursor *cursor =
|
||||||
|
|||||||
Reference in New Issue
Block a user