Skip to content

Commit 3571083

Browse files
vtyrtovTurboGit
authored andcommitted
tagging/colorlabels: Wayland popover for safe positioning + unified session detection; remove debug logs and unused gdk backend includes
1 parent 096dbb1 commit 3571083

File tree

2 files changed

+6
-52
lines changed

2 files changed

+6
-52
lines changed

src/libs/tagging.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
#ifdef GDK_WINDOWING_QUARTZ
3535
#include "osx/osx.h"
3636
#endif
37-
#ifdef GDK_WINDOWING_WAYLAND
38-
#include <gdk/gdkwayland.h>
39-
#endif
4037
#include <gdk/gdkkeysyms.h>
4138
#include <math.h>
4239

@@ -3423,11 +3420,7 @@ static void _lib_tagging_tag_show(dt_action_t *action)
34233420
d->floating_tag_imgs = dt_act_on_get_images(FALSE, TRUE, FALSE);
34243421
GtkWidget *window = dt_ui_main_window(darktable.gui->ui);
34253422
GtkWidget *center = dt_ui_center(darktable.gui->ui);
3426-
#ifdef GDK_WINDOWING_WAYLAND
3427-
const gboolean on_wayland = GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(window));
3428-
#else
3429-
const gboolean on_wayland = FALSE;
3430-
#endif
3423+
const gboolean on_wayland = dt_gui_get_session_type() == DT_GUI_SESSION_WAYLAND;
34313424

34323425
if(on_wayland)
34333426
{
@@ -3475,7 +3468,7 @@ static void _lib_tagging_tag_show(dt_action_t *action)
34753468
gtk_widget_get_allocation(center, &a);
34763469
GdkRectangle rect;
34773470
rect.x = MAX(0, (a.width - FLOATING_ENTRY_WIDTH) / 2);
3478-
rect.y = MAX(0, a.height - 1 - 50); // small bottom offset
3471+
rect.y = MAX(0, a.height - 1);
34793472
rect.width = FLOATING_ENTRY_WIDTH;
34803473
rect.height = 1;
34813474
gtk_popover_set_pointing_to(GTK_POPOVER(d->floating_tag_window), &rect);

src/libs/tools/colorlabels.c

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@
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

4236
DT_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

Comments
 (0)