1Title: macOS Interaction
2
3## macOS backend-specific functions
4
5The functions in this section are specific to the GDK macOS backend.
6To use them, you need to include the `<gdk/macos/gdkmacos.h>` header and
7use the macOS-specific pkg-config `gtk4-macos` file to build your
8application.
9
10## Checking for the macOS 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_MACOS
19#include <gdk/macos/gdkmacos.h>
20#endif
21#ifdef GDK_WINDOWING_WAYLAND
22#include <gdk/wayland/gdkwayland.h>
23#endif
24#ifdef GDK_WINDOWING_X11
25#include <gdk/x11/gdkx.h>
26#endif
27
28#ifdef GDK_WINDOWING_MACOS
29  if (GDK_IS_MACOS_DISPLAY (display))
30    {
31      // make macOS-specific calls here
32    }
33  else
34#endif
35#ifdef GDK_WINDOWING_WAYLAND
36  if (GTK_IS_WAYLAND_DISPLAY (display))
37    {
38      // make Wayland-specific calls here
39    }
40  else
41#endif
42#ifdef GDK_WINDOWING_X11
43  if (GDK_IS_X11_DISPLAY (display))
44    {
45      // make X11-specific calls here
46    }
47  else
48#endif
49  g_error ("Unsupported GDK backend");
50```
51
52The compile time check is performed by using the `GDK_WINDOWING_*`
53pre-processor symbols; there is one defined for each windowing system
54backend built into GDK. For Wayland, the symbol is `GDK_WINDOWING_MACOS`.
55
56The run time check is performed by looking at the type of the
57[class@Gdk.Display] object. For Wayland, the display objects will be of type
58`GdkMacosDisplay`.
59