From 33e84edf0c6d520cc158872bddfe305a4aa18894 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Oct 2020 14:02:54 +0100 Subject: [PATCH 1/3] Skip GdkWayland symbols that use wayland-client types The wayland-client API does not have introspection annotations, so we can't use these types anyway. --- gdk/wayland/gdkdevice-wayland.c | 23 ++++++++++++++++++----- gdk/wayland/gdkdisplay-wayland.c | 4 ++-- gdk/wayland/gdkmonitor-wayland.c | 2 +- gdk/wayland/gdksurface-wayland.c | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index fbbceacb65..65727857ec 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -942,7 +942,7 @@ gdk_wayland_device_pad_init (GdkWaylandDevicePad *pad) } /** - * gdk_wayland_device_get_wl_seat: + * gdk_wayland_device_get_wl_seat: (skip) * @device: (type GdkWaylandDevice): a #GdkDevice * * Returns the Wayland wl_seat of a #GdkDevice. @@ -961,7 +961,7 @@ gdk_wayland_device_get_wl_seat (GdkDevice *device) } /** - * gdk_wayland_device_get_wl_pointer: + * gdk_wayland_device_get_wl_pointer: (skip) * @device: (type GdkWaylandDevice): a #GdkDevice * * Returns the Wayland wl_pointer of a #GdkDevice. @@ -980,7 +980,7 @@ gdk_wayland_device_get_wl_pointer (GdkDevice *device) } /** - * gdk_wayland_device_get_wl_keyboard: + * gdk_wayland_device_get_wl_keyboard: (skip) * @device: (type GdkWaylandDevice): a #GdkDevice * * Returns the Wayland wl_keyboard of a #GdkDevice. @@ -4971,6 +4971,12 @@ gdk_wayland_seat_set_drag (GdkSeat *seat, g_set_object (&wayland_seat->drag, drag); } +/** + * gdk_wayland_device_get_data_device: (skip) + * @gdk_device: (type GdkWaylandDevice): a #GdkDevice + * + * ... + */ struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_device) { @@ -4982,6 +4988,13 @@ gdk_wayland_device_get_data_device (GdkDevice *gdk_device) return seat->data_device; } +/** + * gdk_wayland_device_set_selection: (skip) + * @gdk_device: (type GdkWaylandDevice): a #GdkDevice + * @source: the data source for the selection + * + * ... + */ void gdk_wayland_device_set_selection (GdkDevice *gdk_device, struct wl_data_source *source) @@ -4999,8 +5012,8 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device, } /** - * gdk_wayland_seat_get_wl_seat: - * @seat: (type GdkWaylandSeat): a #GdkSeat + * gdk_wayland_seat_get_wl_seat: (skip) + * @seat: a #GdkSeat * * Returns the Wayland wl_seat of a #GdkSeat. * diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 52dd6dcf5d..dcbd9680f1 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -1154,7 +1154,7 @@ _gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland, } /** - * gdk_wayland_display_get_wl_display: + * gdk_wayland_display_get_wl_display: (skip) * @display: (type GdkWaylandDisplay): a #GdkDisplay * * Returns the Wayland wl_display of a #GdkDisplay. @@ -1170,7 +1170,7 @@ gdk_wayland_display_get_wl_display (GdkDisplay *display) } /** - * gdk_wayland_display_get_wl_compositor: + * gdk_wayland_display_get_wl_compositor: (skip) * @display: (type GdkWaylandDisplay): a #GdkDisplay * * Returns the Wayland global singleton compositor of a #GdkDisplay. diff --git a/gdk/wayland/gdkmonitor-wayland.c b/gdk/wayland/gdkmonitor-wayland.c index 7f73dd66a6..e13a686055 100644 --- a/gdk/wayland/gdkmonitor-wayland.c +++ b/gdk/wayland/gdkmonitor-wayland.c @@ -49,7 +49,7 @@ gdk_wayland_monitor_class_init (GdkWaylandMonitorClass *class) } /** - * gdk_wayland_monitor_get_wl_output: + * gdk_wayland_monitor_get_wl_output: (skip) * @monitor: (type GdkWaylandMonitor): a #GdkMonitor * * Returns the Wayland wl_output of a #GdkMonitor. diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 4a54185dcc..d7ff188e7d 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -4033,7 +4033,7 @@ _gdk_wayland_surface_set_grab_seat (GdkSurface *surface, } /** - * gdk_wayland_surface_get_wl_surface: + * gdk_wayland_surface_get_wl_surface: (skip) * @surface: (type GdkWaylandSurface): a #GdkSurface * * Returns the Wayland surface of a #GdkSurface. From f83ee2ab6abeec1143caef6cc12ea4c4cf76927a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Oct 2020 14:04:13 +0100 Subject: [PATCH 2/3] Add type annotations for GdkWayland API The GdkWayland API takes generic GDK types and performs a run time check, which means we need to properly annotate the actual expected type in order to have methods recognised as such. --- gdk/wayland/gdkdevice-wayland.c | 11 ++++++----- gdk/wayland/gdkdisplay-wayland.c | 25 ++++++++++++++++++++----- gdk/wayland/gdksurface-wayland.c | 32 +++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 65727857ec..1fb60eadf8 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -5029,9 +5029,10 @@ gdk_wayland_seat_get_wl_seat (GdkSeat *seat) /** * gdk_wayland_device_get_node_path: - * @device: a #GdkDevice + * @device: (type GdkWaylandDevice): a #GdkDevice + * + * Returns the `/dev/input/event*` path of this device. * - * Returns the /dev/input/event* path of this device. * For #GdkDevices that possibly coalesce multiple hardware * devices (eg. mouse, keyboard, touch,...), this function * will return %NULL. @@ -5039,8 +5040,8 @@ gdk_wayland_seat_get_wl_seat (GdkSeat *seat) * This is most notably implemented for devices of type * %GDK_SOURCE_PEN, %GDK_SOURCE_TABLET_PAD. * - * Returns: the /dev/input/event* path of this device - **/ + * Returns: (nullable) (transfer none): the `/dev/input/event*` path of this device + */ const char * gdk_wayland_device_get_node_path (GdkDevice *device) { @@ -5065,7 +5066,7 @@ gdk_wayland_device_get_node_path (GdkDevice *device) /** * gdk_wayland_device_pad_set_feedback: - * @device: a %GDK_SOURCE_TABLET_PAD device + * @device: (type GdkWaylandDevice): 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 diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index dcbd9680f1..b2c182a884 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -384,6 +384,15 @@ static const struct org_kde_kwin_server_decoration_manager_listener server_decor .default_mode = server_decoration_manager_default_mode }; +/** + * gdk_wayland_display_prefers_ssd: + * @display: (type GdkWaylandDisplay): a #GdkDisplay + * + * Checks whether the Wayland compositor prefers to draw the window + * decorations or if it leaves decorations to the application. + * + * Returns: %TRUE if the compositor prefers server-side decorations + */ gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display) { @@ -859,7 +868,7 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display) /** * gdk_wayland_display_get_startup_notification_id: - * @display: (type GdkX11Display): a #GdkDisplay + * @display: (type GdkWaylandDisplay): a #GdkDisplay * * Gets the startup notification ID for a Wayland display, or %NULL * if no ID has been defined. @@ -1064,10 +1073,16 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland, return wl_cursor_theme_create ("/usr/share/icons/default/cursors", size, display_wayland->shm); } +/** + * gdk_wayland_display_set_cursor_theme: + * @display: (type GdkWaylandDisplay): a #GdkDisplay + * + * Sets the cursor theme for the given @display. + */ void -gdk_wayland_display_set_cursor_theme (GdkDisplay *display, +gdk_wayland_display_set_cursor_theme (GdkDisplay *display, const char *name, - int size) + int size) { GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display); struct wl_cursor_theme *theme; @@ -2617,11 +2632,11 @@ gdk_wayland_display_get_output_scale (GdkWaylandDisplay *display_wayland, /** * gdk_wayland_display_query_registry: - * @display: a wayland #GdkDisplay + * @display: (type GdkWaylandDisplay): a #GdkDisplay * @global: global interface to query in the registry * * Returns %TRUE if the the interface was found in the display - * wl_registry.global handler. + * `wl_registry.global` handler. * * Returns: %TRUE if the global is offered by the compositor **/ diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index d7ff188e7d..0d8fe2fe74 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -1694,6 +1694,13 @@ create_zxdg_toplevel_v6_resources (GdkSurface *surface) surface); } +/** + * gdk_wayland_toplevel_set_application_id: + * @toplevel: (type GdkWaylandToplevel): a #GdkToplevel + * @application_id: the application id for the @toplevel + * + * Sets the application id on a #GdkToplevel. + */ void gdk_wayland_toplevel_set_application_id (GdkToplevel *toplevel, const char *application_id) @@ -4225,12 +4232,12 @@ static const struct zxdg_exported_v1_listener xdg_exported_listener = { /** * GdkWaylandToplevelExported: - * @toplevel: the #GdkToplevel that is exported + * @toplevel: (type GdkWaylandToplevel): the #GdkToplevel that is exported * @handle: the handle * @user_data: user data that was passed to gdk_wayland_toplevel_export_handle() * * Callback that gets called when the handle for a surface has been - * obtained from the Wayland compositor. The handle can be passed + * 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. */ @@ -4243,7 +4250,7 @@ gdk_wayland_surface_is_exported (GdkWaylandSurface *impl) /** * gdk_wayland_toplevel_export_handle: - * @toplevel: the #GdkToplevel to obtain a handle for + * @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to obtain a handle for * @callback: callback to call with the handle * @user_data: (closure): user data for @callback * @destroy_func: destroy notify for @user_data @@ -4307,7 +4314,7 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel, /** * gdk_wayland_toplevel_unexport_handle: - * @toplevel: the #GdkToplevel to unexport + * @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to unexport * * Destroys the handle that was obtained with * gdk_wayland_toplevel_export_handle(). @@ -4361,7 +4368,7 @@ static const struct zxdg_imported_v1_listener xdg_imported_listener = { /** * gdk_wayland_toplevel_set_transient_for_exported: - * @toplevel: the #GdkToplevel to make as transient + * @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to make as transient * @parent_handle_str: an exported handle for a surface * * Marks @toplevel as transient for the surface to which the given @@ -4414,6 +4421,13 @@ gdk_wayland_surface_get_inhibitor (GdkWaylandSurface *impl, return g_hash_table_lookup (impl->shortcuts_inhibitors, gdk_seat); } +/* + * gdk_wayland_surface_inhibit_shortcuts: + * @surface: (type GdkWaylandSurface): a #GdkSurface + * @seat: the seat to inhibit + * + * Inhibits the shortcuts coming from the given @seat. + */ void gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface, GdkSeat *gdk_seat) @@ -4437,6 +4451,14 @@ gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface, g_hash_table_insert (impl->shortcuts_inhibitors, gdk_seat, inhibitor); } +/* + * gdk_wayland_surface_restore_shortcuts: + * @surface: (type GdkWaylandSurface): a #GdkSurface + * @seat: the seat to inhibit + * + * Restores the shortcuts on the given @seat inhibited by calling + * gdk_wayland_surface_inhibit_shortcuts(). + */ void gdk_wayland_surface_restore_shortcuts (GdkSurface *surface, GdkSeat *gdk_seat) From daac36ea4c18c4fbd3dec535148657a85b04008e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Oct 2020 14:05:52 +0100 Subject: [PATCH 3/3] Generate introspection for GdkWayland API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like we do for GdkX11. We can't use all of the public C API, but we can expose enough type information to allow non-C developers to actually check if they are running the Wayland GDK backend or not—plus some additional Wayland-specific API. --- gtk/meson.build | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gtk/meson.build b/gtk/meson.build index e29f0d4fdd..006ac8f31e 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -1165,6 +1165,23 @@ if build_gir gtk_dep_sources += gdk_x11_gir endif + if wayland_enabled + gdk_wayland_gir = gnome.generate_gir(libgtk, + sources: gdk_wayland_public_headers + gdk_wayland_sources, + namespace: 'GdkWayland', + nsversion: gtk_api_version, + identifier_prefix: 'Gdk', + symbol_prefix: 'gdk', + export_packages: 'gtk4-wayland', + includes: [ gdk_gir[0], ], + install: true, + dependencies: gdk_gir_dep, + header: 'gdk/gdkwayland.h', + extra_args: gir_args, + ) + gtk_dep_sources += gdk_wayland_gir + endif + gsk_gir_inc = [ gdk_gir[0] ] gsk_gir = gnome.generate_gir(libgtk,