Re: Detecting the gdk backend
- From: Luca Bacci <luca bacci982 gmail com>
- To: Daniel Kasak <d j kasak dk gmail com>
- Cc: "gtk-app-devel-." <gtk-app-devel-list gnome org>
- Subject: Re: Detecting the gdk backend
- Date: Thu, 7 Feb 2019 11:12:15 +0100
Hi! There is some reference code here:
https://developer.gnome.org/gdk3/stable/gdk3-Wayland-Interaction.html
https://developer.gnome.org/gdk3/stable/gdk3-X-Window-System-Interaction.html
- Include the backend specific headers: gdk/gdkx.h, gdk/gdkwayland.h
- Link with backend specific libs: gdk-x11-3.0.pc, gdk-wayland-3.0.pc
- Check the backend for the default display: if
(GDK_IS_X11_DISPLAY(gdk_display_get_default())) { /*...*/ }
Here is an example:
/* compile with
cc -o print-gdk-backend print-gdk-backend.c \
$(pkg-config --cflags --libs gtk+-3.0 gdk-x11-3.0 gdk-wayland-3.0)
*/
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
/*
GDK_WINDOWING macros are defined in header
/usr/include/gtk-3.0/gdk/gdkconfig.h
*/
int main() {
gtk_init(NULL, NULL);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
g_print("X11 backend\n");
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
g_print("Wayland backend\n");
}
#endif
return 0;
}
Il giorno gio 7 feb 2019 alle ore 06:28 Daniel Kasak via gtk-app-devel-list
<gtk-app-devel-list gnome org> ha scritto:
Hi all. Is there a way to detect the gdk backend an app is using? I know
about the environment variable - GDK_BACKEND. But often this is not set,
and gtk just picks whatever's available. I need ever-so-slightly different
app behaviour, depending on the backend. Any ideas?
Dan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]