diff --git a/libdecor/build/fl_libdecor-plugins.c b/libdecor/build/fl_libdecor-plugins.c index 61cd55836..df7c1c399 100644 --- a/libdecor/build/fl_libdecor-plugins.c +++ b/libdecor/build/fl_libdecor-plugins.c @@ -236,13 +236,7 @@ static unsigned char *gtk_titlebar_buffer(struct libdecor_frame *frame, int *width, int *height, int *stride) { struct libdecor_frame_gtk *lfg = (struct libdecor_frame_gtk *)frame; -#if USE_SYSTEM_LIBDECOR || !HAVE_GTK - struct border_component_gtk *bc; -#else - struct border_component *bc; -#endif - bc = &lfg->headerbar; - struct buffer *buffer = bc->buffer; + struct buffer *buffer = lfg->headerbar.buffer; *width = buffer->buffer_width; *height = buffer->buffer_height; *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 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, int *width, int *height, int *stride) { - static const char *my_plugin = NULL; - if (!my_plugin) my_plugin = get_libdecor_plugin_description(frame); - if (my_plugin && !strcmp(my_plugin, "GTK3 plugin")) { + const char *name = plugin_name(frame); + if (!strcmp(name, "GTK3 plugin")) { 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 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; +} diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index cd98d23a0..26f85ede0 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -47,6 +47,7 @@ #include // for strerror() extern "C" { 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, 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 && 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; // use custom cursor if present struct wl_cursor *cursor =