Wayland Interaction

Wayland Interaction — Wayland backend-specific functions

Includes

#include <gdk/wayland/gdkwayland.h>

Description

The functions in this section are specific to the GDK Wayland backend. To use them, you need to include the <gdk/wayland/gdkwayland.h> header and use the Wayland-specific pkg-config gtk4-wayland file to build your application.

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).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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_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]


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 .

[closure]

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.