Skip to content

Commit 78199ce

Browse files
committed
dt_gui_get_session_type: New routine, returns the session kind at runtime.
Either Wayland, X11 or Quartz.
1 parent b34c31b commit 78199ce

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/gui/gtk.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/gui/gtk.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)