1Title: Wayland Interaction 2 3## Wayland backend-specific functions 4 5The functions in this section are specific to the GDK Wayland backend. 6To use them, you need to include the `<gdk/wayland/gdkwayland.h>` header and 7use the Wayland-specific pkg-config `gtk4-wayland` file to build your 8application. 9 10## Checking for the Wayland backend 11 12GDK can be built with support for multiple backends, which means you will 13need to perform both compile time *and* run time checks if you wish to call 14backend-specific API; for instance, the code sample below will guard the 15calls to different backends, and error out on unsupported windowing systems: 16 17```c 18#ifdef GDK_WINDOWING_WAYLAND 19#include <gdk/wayland/gdkwayland.h> 20#endif 21#ifdef GDK_WINDOWING_X11 22#include <gdk/x11/gdkx.h> 23#endif 24 25#ifdef GDK_WINDOWING_WAYLAND 26 if (GTK_IS_WAYLAND_DISPLAY (display)) 27 { 28 // make Wayland-specific calls here 29 } 30 else 31#endif 32#ifdef GDK_WINDOWING_X11 33 if (GDK_IS_X11_DISPLAY (display)) 34 { 35 // make X11-specific calls here 36 } 37 else 38#endif 39 g_error ("Unsupported GDK backend"); 40``` 41 42The compile time check is performed by using the `GDK_WINDOWING_*` 43pre-processor symbols; there is one defined for each windowing system 44backend built into GDK. For Wayland, the symbol is `GDK_WINDOWING_WAYLAND`. 45 46The run time check is performed by looking at the type of the 47[class@Gdk.Display] object. For Wayland, the display objects will be of type 48`GdkWaylandDisplay`. 49