Wayland Interaction

Wayland Interaction — Wayland backend-specific functions

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_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_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_query_registry ()

gboolean
gdk_wayland_display_query_registry (GdkDisplay *display,
                                    const char *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_display_set_cursor_theme ()

void
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
                                      const char *theme,
                                      int size);

gdk_wayland_display_get_startup_notification_id ()

const char *
gdk_wayland_display_get_startup_notification_id
                               (GdkDisplay *display);

Gets the startup notification ID for a Wayland display, or NULL if no ID has been defined.

Parameters

display

a GdkDisplay.

[type GdkX11Display]

Returns

the startup notification ID for display , or NULL


gdk_wayland_display_set_startup_notification_id ()

void
gdk_wayland_display_set_startup_notification_id
                               (GdkDisplay *display,
                                const char *startup_id);

Sets the startup notification ID for a display.

This is usually taken from the value of the DESKTOP_STARTUP_ID environment variable, but in some cases (such as the application not being launched using exec()) it can come from other sources.

The startup ID is also what is used to signal that the startup is complete (for example, when opening a window or when calling gdk_display_notify_startup_complete()).

Parameters

display

a GdkDisplay.

[type GdkWaylandDisplay]

startup_id

the startup notification ID (must be valid utf8)

 

gdk_wayland_display_prefers_ssd ()

gboolean
gdk_wayland_display_prefers_ssd (GdkDisplay *display);

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_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_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_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_pad_set_feedback ()

void
gdk_wayland_device_pad_set_feedback (GdkDevice *device,
                                     GdkDevicePadFeature feature,
                                     guint feature_idx,
                                     const char *label);

Sets the feedback label for the given feature/index. This may be used by the compositor to provide user feedback of the actions available/performed.

Parameters

device

a GDK_SOURCE_TABLET_PAD device

 

feature

Feature to set the feedback label for

 

feature_idx

0-indexed index of the feature to set the feedback label for

 

label

Feedback label

 

gdk_wayland_monitor_get_wl_output ()

struct wl_output *
gdk_wayland_monitor_get_wl_output (GdkMonitor *monitor);

Returns the Wayland wl_output of a GdkMonitor.

Parameters

monitor

a GdkMonitor.

[type GdkWaylandMonitor]

Returns

a Wayland wl_output.

[transfer none]


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]


GdkWaylandToplevelExported ()

void
(*GdkWaylandToplevelExported) (GdkToplevel *toplevel,
                               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

toplevel

the GdkToplevel that is exported

 

handle

the handle

 

user_data

user data that was passed to gdk_wayland_toplevel_export_handle()

 

gdk_wayland_toplevel_export_handle ()

gboolean
gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
                                    GdkWaylandToplevelExported 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_toplevel_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_toplevel_set_transient_for_exported().

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

Parameters

toplevel

the GdkToplevel 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_toplevel_unexport_handle ()

void
gdk_wayland_toplevel_unexport_handle (GdkToplevel *toplevel);

Destroys the handle that was obtained with gdk_wayland_toplevel_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

toplevel

the GdkToplevel to unexport

 

gdk_wayland_toplevel_set_transient_for_exported ()

gboolean
gdk_wayland_toplevel_set_transient_for_exported
                               (GdkToplevel *toplevel,
                                const char *parent_handle_str);

Marks toplevel as transient for the surface to which the given parent_handle_str refers. Typically, the handle will originate from a gdk_wayland_toplevel_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

toplevel

the GdkToplevel 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.


gdk_wayland_toplevel_set_application_id ()

void
gdk_wayland_toplevel_set_application_id
                               (GdkToplevel *toplevel,
                                const char *application_id);

gdk_wayland_toplevel_announce_csd ()

void
gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel);

gdk_wayland_toplevel_inhibit_idle ()

gboolean
gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel);

gdk_wayland_toplevel_uninhibit_idle ()

void
gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel);