## Wayland Interaction Wayland Interaction — Wayland backend-specific functions |

## Functions

struct wl_seat * | gdk_wayland_seat_get_wl_seat ()
struct wl_keyboard * | gdk_wayland_device_get_wl_keyboard ()
struct wl_pointer * | gdk_wayland_device_get_wl_pointer ()
struct wl_seat * | gdk_wayland_device_get_wl_seat ()
struct wl_compositor * | gdk_wayland_display_get_wl_compositor ()
struct wl_display * | gdk_wayland_display_get_wl_display ()
gboolean | gdk_wayland_display_query_registry ()
GdkSurface * | gdk_wayland_surface_new_subsurface ()
struct wl_surface * | gdk_wayland_surface_get_wl_surface ()
void | gdk_wayland_surface_set_use_custom_surface ()
void | (*GdkWaylandSurfaceExported) ()
gboolean | gdk_wayland_surface_export_handle ()
void | gdk_wayland_surface_unexport_handle ()
gboolean | gdk_wayland_surface_set_transient_for_exported ()

## Includes

    #include <gdk/gdkwayland.h>

## Description

The functions in this section are specific to the GDK Wayland backend. To use them, you need to include the `&lt;gdk/gdkwayland.h>` header and use the Wayland-specific pkg-config files to build your application (either `gdk-wayland-3.0` or `gtk+-wayland-3.0`).

To make your code compile with other GDK backends, guard backend-specific calls by an ifdef as follows. Since GDK may be built with multiple backends, you should also check for the backend that is in use (e.g. by using the `GDK_IS_WAYLAND_DISPLAY()` macro).

    #ifdef GDK_WINDOWING_WAYLAND
      if (GDK_IS_WAYLAND_DISPLAY (display))
        {
          // make Wayland-specific calls here
        }
      else
    #endif
    #ifdef GDK_WINDOWING_X11
      if (GDK_IS_X11_DISPLAY (display))
        {
          // make X11-specific calls here
        }
      else
    #endif
      g_error ("Unsupported GDK backend");

## Functions

### gdk_wayland_seat_get_wl_seat ()

    struct wl_seat *
    gdk_wayland_seat_get_wl_seat (GdkSeat *seat);

Returns the Wayland wl_seat of a GdkSeat.

#### Parameters

seat | a GdkSeat. | [type GdkWaylandSeat]

#### Returns

a Wayland wl_seat.

[transfer none]

### gdk_wayland_device_get_wl_keyboard ()

    struct wl_keyboard *
    gdk_wayland_device_get_wl_keyboard (GdkDevice *device);

Returns the Wayland wl_keyboard of a GdkDevice.

#### Parameters

device | a GdkDevice. | [type GdkWaylandDevice]

#### Returns

a Wayland wl_keyboard.

[transfer none]

### gdk_wayland_device_get_wl_pointer ()

    struct wl_pointer *
    gdk_wayland_device_get_wl_pointer (GdkDevice *device);

Returns the Wayland wl_pointer of a GdkDevice.

#### Parameters

device | a GdkDevice. | [type GdkWaylandDevice]

#### Returns

a Wayland wl_pointer.

[transfer none]

### gdk_wayland_device_get_wl_seat ()

    struct wl_seat *
    gdk_wayland_device_get_wl_seat (GdkDevice *device);

Returns the Wayland wl_seat of a GdkDevice.

#### Parameters

device | a GdkDevice. | [type GdkWaylandDevice]

#### Returns

a Wayland wl_seat.

[transfer none]

### gdk_wayland_display_get_wl_compositor ()

    struct wl_compositor *
    gdk_wayland_display_get_wl_compositor (GdkDisplay *display);

Returns the Wayland global singleton compositor of a GdkDisplay.

#### Parameters

display | a GdkDisplay. | [type GdkWaylandDisplay]

#### Returns

a Wayland wl_compositor.

[transfer none]

### gdk_wayland_display_get_wl_display ()

    struct wl_display *
    gdk_wayland_display_get_wl_display (GdkDisplay *display);

Returns the Wayland wl_display of a GdkDisplay.

#### Parameters

display | a GdkDisplay. | [type GdkWaylandDisplay]

#### Returns

a Wayland wl_display.

[transfer none]

### gdk_wayland_display_query_registry ()

    gboolean
    gdk_wayland_display_query_registry (GdkDisplay *display,
                                        const gchar *global);

Returns `TRUE` if the the interface was found in the display wl_registry.global handler.

#### Parameters

display | a wayland GdkDisplay |
global | global interface to query in the registry |

#### Returns

`TRUE` if the global is offered by the compositor

### gdk_wayland_surface_new_subsurface ()

    GdkSurface *
    gdk_wayland_surface_new_subsurface (GdkDisplay *display,
                                        const GdkRectangle *position);

Creates a new subsurface surface.

[constructor]

#### Parameters

display | the display to create the surface on |
position | position relative to the transient surface |

#### Returns

the new GdkSurface.

[transfer full]

### gdk_wayland_surface_get_wl_surface ()

    struct wl_surface *
    gdk_wayland_surface_get_wl_surface (GdkSurface *surface);

Returns the Wayland surface of a GdkSurface.

#### Parameters

surface | a GdkSurface. | [type GdkWaylandSurface]

#### Returns

a Wayland wl_surface.

[transfer none]

### gdk_wayland_surface_set_use_custom_surface ()

    void
    gdk_wayland_surface_set_use_custom_surface
                                   (GdkSurface *surface);

Marks a GdkSurface as a custom Wayland surface. The application is expected to register the surface as some type of surface using some Wayland interface.

A good example would be writing a panel or on-screen-keyboard as an out-of-process helper - as opposed to having those in the compositor process. In this case the underlying surface isn’t an xdg_shell surface and the panel or OSK client need to identify the wl_surface as a panel or OSK to the compositor. The assumption is that the compositor will expose a private interface to the special client that lets the client identify the wl_surface as a panel or such.

This function should be called before a GdkSurface is shown. This is best done by connecting to the “realize” signal:

      static void
      widget_realize_cb (GtkWidget *widget)
      {
        GdkSurface *surface;
        struct wl_surface *surface;
        struct input_panel_surface *ip_surface;

        surface = gtk_widget_get_surface (widget);
        gdk_wayland_surface_set_custom_surface (surface);

        surface = gdk_wayland_surface_get_wl_surface (surface);
        ip_surface = input_panel_get_input_panel_surface (input_panel, surface);
        input_panel_surface_set_panel (ip_surface);
      }

      static void
      setup_window (GtkWindow *window)
      {
        g_signal_connect (window, "realize", G_CALLBACK (widget_realize_cb), NULL);
      }

#### Parameters

surface | a GdkSurface. | [type GdkWaylandSurface]

### GdkWaylandSurfaceExported ()

    void
    (*GdkWaylandSurfaceExported) (GdkSurface *surface,
                                  const char *handle,
                                  gpointer user_data);

Callback that gets called when the handle for a surface has been obtained from the Wayland compositor. The handle can be passed to other processes, for the purpose of marking surfaces as transient for out-of-process surfaces.

#### Parameters

surface | the GdkSurface that is exported |
handle | the handle |
user_data | user data that was passed to `gdk_wayland_surface_export_handle()` |

### gdk_wayland_surface_export_handle ()

    gboolean
    gdk_wayland_surface_export_handle (GdkSurface *surface,
                                       GdkWaylandSurfaceExported callback,
                                       gpointer user_data,
                                       GDestroyNotify destroy_func);

Asynchronously obtains a handle for a surface that can be passed to other processes. When the handle has been obtained, `callback` will be called.

It is an error to call this function on a surface that is already exported.

When the handle is no longer needed, `gdk_wayland_surface_unexport_handle()` should be called to clean up resources.

The main purpose for obtaining a handle is to mark a surface from another surface as transient for this one, see `gdk_wayland_surface_set_transient_for_exported()`.

Note that this API depends on an unstable Wayland protocol, and thus may require changes in the future.

#### Parameters

surface | the GdkSurface to obtain a handle for |
callback | callback to call with the handle |
user_data | user data for `callback` |
destroy_func | destroy notify for `user_data` |

#### Returns

`TRUE` if the handle has been requested, `FALSE` if an error occurred.

### gdk_wayland_surface_unexport_handle ()

    void
    gdk_wayland_surface_unexport_handle (GdkSurface *surface);

Destroys the handle that was obtained with `gdk_wayland_surface_export_handle()`.

It is an error to call this function on a surface that does not have a handle.

Note that this API depends on an unstable Wayland protocol, and thus may require changes in the future.

#### Parameters

surface | the GdkSurface to unexport |

### gdk_wayland_surface_set_transient_for_exported ()

    gboolean
    gdk_wayland_surface_set_transient_for_exported
                                   (GdkSurface *surface,
                                    char *parent_handle_str);

Marks `surface` as transient for the surface to which the given `parent_handle_str` refers. Typically, the handle will originate from a `gdk_wayland_surface_export_handle()` call in another process.

Note that this API depends on an unstable Wayland protocol, and thus may require changes in the future.

#### Parameters

surface | the GdkSurface to make as transient |
parent_handle_str | an exported handle for a surface |

#### Returns

`TRUE` if the surface has been marked as transient, `FALSE` if an error occurred.

## Types and Values