Skip to content

Commit 583b525

Browse files
authored
Merge pull request #19646 from darktable-org/po/wayland-profile
po/wayland profile - ICC profile support for wayland
2 parents 072d2d6 + e3188b2 commit 583b525

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

src/gui/gtk.c

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,11 @@ static gboolean _scrollbar_changed(GtkWidget *widget,
770770
return TRUE;
771771
}
772772

773-
gboolean _valid_window_placement( const gint saved_x,
774-
const gint saved_y,
775-
const gint window_width,
776-
const gint window_height,
777-
const gint border)
773+
gboolean _valid_window_placement(const gint saved_x,
774+
const gint saved_y,
775+
const gint window_width,
776+
const gint window_height,
777+
const gint border)
778778
{
779779
GdkDisplay *display = gdk_display_get_default();
780780
const gint n_monitors = gdk_display_get_n_monitors(display);
@@ -975,6 +975,25 @@ static gboolean _osx_openfile_callback(GtkosxApplication *OSXapp,
975975
}
976976
#endif
977977

978+
dt_gui_session_type_t dt_gui_get_session_type(void)
979+
{
980+
#ifdef GDK_WINDOWING_QUARTZ
981+
return DT_GUI_SESSION_QUARTZ;
982+
#elif defined(GDK_WINDOWING_WAYLAND)
983+
GdkDisplay* disp = gdk_display_get_default();
984+
return G_TYPE_CHECK_INSTANCE_TYPE(disp, GDK_TYPE_WAYLAND_DISPLAY)
985+
? DT_GUI_SESSION_WAYLAND
986+
: DT_GUI_SESSION_X11;
987+
#elif defined(GDK_WINDOWING_X11)
988+
GdkDisplay* disp = gdk_display_get_default();
989+
retun G_TYPE_CHECK_INSTANCE_TYPE(disp, GDK_TYPE_X11_DISPLAY)
990+
? DT_GUI_SESSION_X11
991+
: DT_GUI_SESSION_WAYLAND;
992+
#else
993+
return DT_GUI_SESSION_UNKNOWN;
994+
#endif
995+
}
996+
978997
static gboolean _configure(GtkWidget *da,
979998
GdkEventConfigure *event,
980999
const gpointer user_data)
@@ -992,13 +1011,19 @@ static gboolean _window_configure(GtkWidget *da,
9921011
{
9931012
static int oldx = 0;
9941013
static int oldy = 0;
995-
if(oldx != event->configure.x || oldy != event->configure.y)
1014+
1015+
// FIXME: On Wayland we always configure as the even->configure x, y
1016+
// are always 0.
1017+
if(oldx != event->configure.x
1018+
|| oldy != event->configure.y
1019+
|| dt_gui_get_session_type() == DT_GUI_SESSION_WAYLAND)
9961020
{
997-
dt_colorspaces_set_display_profile(
998-
DT_COLORSPACE_DISPLAY); // maybe we are on another screen now with > 50% of the area
1021+
// maybe we are on another screen now with > 50% of the area
1022+
dt_colorspaces_set_display_profile(DT_COLORSPACE_DISPLAY);
9991023
oldx = event->configure.x;
10001024
oldy = event->configure.y;
10011025
}
1026+
10021027
return FALSE;
10031028
}
10041029

@@ -1154,7 +1179,7 @@ static void _osx_add_view_menu_item(GtkWidget* menu,
11541179
gpointer mode)
11551180
{
11561181
GtkWidget *mi = gtk_menu_item_new_with_label(label);
1157-
gtk_menu_shell_append(GTK_MENU_SHELL (menu), mi);
1182+
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
11581183
gtk_widget_show(mi);
11591184
g_signal_connect(G_OBJECT(mi), "activate",
11601185
G_CALLBACK(_osx_ctl_switch_mode_to), mode);
@@ -1490,8 +1515,8 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui)
14901515
dt_init_styles_actions();
14911516

14921517
// register ctrl-q to quit:
1493-
dt_action_register(&darktable.control->actions_global, N_("quit"), _quit_callback
1494-
, GDK_KEY_q, GDK_CONTROL_MASK);
1518+
dt_action_register(&darktable.control->actions_global, N_("quit"),
1519+
_quit_callback, GDK_KEY_q, GDK_CONTROL_MASK);
14951520

14961521
// Full-screen accelerator (no ESC handler here to enable quit-slideshow using ESC)
14971522
dt_action_register(&darktable.control->actions_global, N_("fullscreen"),

src/gui/gtk.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2009-2024 darktable developers.
3+
Copyright (C) 2009-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -28,8 +28,8 @@ G_BEGIN_DECLS
2828

2929
#define DT_GUI_THUMBSIZE_REDUCE 0.7f
3030

31-
/* helper macro that applies the DPI transformation to fixed pixel values. input should be defaulting to 96
32-
* DPI */
31+
/* helper macro that applies the DPI transformation to fixed pixel
32+
* values. input should be defaulting to 96 DPI */
3333
#define DT_PIXEL_APPLY_DPI(value) ((value) * darktable.gui->dpi_factor)
3434

3535
#define DT_RESIZE_HANDLE_SIZE DT_PIXEL_APPLY_DPI(5)
@@ -100,6 +100,14 @@ typedef enum dt_gui_color_t
100100
DT_GUI_COLOR_LAST
101101
} dt_gui_color_t;
102102

103+
typedef enum dt_gui_session_type_t
104+
{
105+
DT_GUI_SESSION_UNKNOWN,
106+
DT_GUI_SESSION_X11,
107+
DT_GUI_SESSION_QUARTZ,
108+
DT_GUI_SESSION_WAYLAND,
109+
} dt_gui_session_type_t;
110+
103111
typedef struct dt_gui_gtk_t
104112
{
105113
struct dt_ui_t *ui;
@@ -627,6 +635,9 @@ void dt_gui_commit_on_focus_loss(GtkCellRenderer *renderer, GtkCellEditable **ac
627635
// restore dialog size from config file
628636
void dt_gui_dialog_restore_size(GtkDialog *dialog, const char *conf);
629637

638+
// returns the session type at runtime
639+
dt_gui_session_type_t dt_gui_get_session_type(void);
640+
630641
G_END_DECLS
631642

632643
// clang-format off

0 commit comments

Comments
 (0)