3131#include "osx/osx.h"
3232#endif
3333
34- #ifdef GDK_WINDOWING_WAYLAND
35- #include <gdk/gdkwayland.h>
36- #endif
37-
38- #ifdef GDK_WINDOWING_X11
39- #include <gdk/gdkx.h>
40- #endif
34+ /* Wayland/X11 specifics accessed via dt_gui_get_session_type(), no need for direct gdk backends here */
4135
4236DT_MODULE (1 )
4337
@@ -221,27 +215,9 @@ static void _lib_colorlabels_edit(dt_lib_module_t *self,
221215
222216 GtkWidget * window = dt_ui_main_window (darktable .gui -> ui );
223217
224- // On Wayland, manual positioning via gtk_window_move() is unreliable and can trigger protocol warnings.
225- // We instead create a GtkPopover anchored to the clicked color label button. On other backends keep
226- // the existing lightweight undecorated GtkWindow approach.
227- gboolean use_popover = FALSE;
228- #ifdef GDK_WINDOWING_WAYLAND
229- use_popover = GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (window ));
230- #endif
231-
232- // Debug: backend and basic context
233- const char * backend = "unknown" ;
234- #ifdef GDK_WINDOWING_WAYLAND
235- if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (window ))) backend = "wayland" ;
236- #endif
237- #ifdef GDK_WINDOWING_X11
238- if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (window ))) backend = "x11" ;
239- #endif
240- dt_print (DT_DEBUG_ALWAYS ,
241- "[colorlabels] edit popup: backend=%s use_popover=%d colorlabel=%d event=(type=%d btn=%d x_root=%d y_root=%d)" ,
242- backend , use_popover , d -> colorlabel ,
243- event ? event -> type : -1 , event ? event -> button : -1 ,
244- event ? (int )event -> x_root : -1 , event ? (int )event -> y_root : -1 );
218+ // Wayland: use a GtkPopover anchored to the clicked color label button (native xdg_popup semantics).
219+ // Other session types: keep the lightweight undecorated GtkWindow (manual positioning via gtk_window_move()).
220+ const gboolean use_popover = (dt_gui_get_session_type () == DT_GUI_SESSION_WAYLAND );
245221
246222 GtkWidget * entry = gtk_entry_new ();
247223 gtk_widget_set_size_request (entry , FLOATING_ENTRY_WIDTH , -1 );
@@ -255,25 +231,13 @@ static void _lib_colorlabels_edit(dt_lib_module_t *self,
255231 {
256232 // Wayland path: use GtkPopover anchored to the clicked color label button for proper xdg_popup semantics
257233 GtkWidget * button = d -> buttons [d -> colorlabel ];
258- // Debug: anchor widget info
259234 GtkAllocation alloc = {0 };
260235 gtk_widget_get_allocation (button , & alloc );
261- // Try to translate button coords to toplevel
262- gint rx = -1 , ry = -1 ;
263- if (gtk_widget_get_toplevel (button ))
264- gtk_widget_translate_coordinates (button , window , 0 , 0 , & rx , & ry );
265- dt_print (DT_DEBUG_ALWAYS ,
266- "[colorlabels] popover anchor: button=%p name=%s alloc=(%d,%d %dx%d) toplevel_xy=(%d,%d)" ,
267- (void * )button , gtk_widget_get_name (button ),
268- alloc .x , alloc .y , alloc .width , alloc .height , rx , ry );
269236 d -> floating_window = gtk_popover_new (button );
270237 // Be explicit about relative_to and pointing rect to avoid GTK quirks in some environments
271238 gtk_popover_set_relative_to (GTK_POPOVER (d -> floating_window ), button );
272239 GdkRectangle r = { 0 , 0 , alloc .width , alloc .height };
273240 gtk_popover_set_pointing_to (GTK_POPOVER (d -> floating_window ), & r );
274- dt_print (DT_DEBUG_ALWAYS ,
275- "[colorlabels] popover pointing_to: rel_rect=(%d,%d %dx%d)" ,
276- r .x , r .y , r .width , r .height );
277241 gtk_popover_set_modal (GTK_POPOVER (d -> floating_window ), TRUE);
278242 gtk_popover_set_position (GTK_POPOVER (d -> floating_window ), GTK_POS_TOP );
279243 gtk_container_add (GTK_CONTAINER (d -> floating_window ), entry );
@@ -285,9 +249,6 @@ static void _lib_colorlabels_edit(dt_lib_module_t *self,
285249 // Legacy/X11 path: keep undecorated popup GtkWindow
286250 const gint x = event -> x_root ;
287251 const gint y = event -> y_root - DT_PIXEL_APPLY_DPI (50 );
288- dt_print (DT_DEBUG_ALWAYS ,
289- "[colorlabels] x11 popup window move: target=(%d,%d) entry_width=%d" ,
290- (int )x , (int )y , (int )FLOATING_ENTRY_WIDTH );
291252
292253 d -> floating_window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
293254#ifdef GDK_WINDOWING_QUARTZ
0 commit comments