From 938448e0efb99b8f4144d9df817643fc28adb687 Mon Sep 17 00:00:00 2001 From: Mario Sanchez Prada Date: Mon, 4 Jun 2018 17:27:36 +0100 Subject: [PATCH] display: Add new virtual gdk_display_get_startup_notification_id() method. Includes implementation for Wayland and X11, which are the only backends implementing the Startup Notification Protocol, returns NULL otherwise. https://gitlab.gnome.org/GNOME/gtk/issues/1084 --- gdk/gdkdisplay.c | 22 ++++++++++++++++++++++ gdk/gdkdisplay.h | 2 ++ gdk/gdkdisplayprivate.h | 2 ++ gdk/wayland/gdkdisplay-wayland.c | 18 ++++++++++++++++++ gdk/wayland/gdkwaylanddisplay.h | 2 ++ gdk/x11/gdkdisplay-x11.c | 1 + 6 files changed, 47 insertions(+) diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 93449e99be..eadc3c7ccb 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1283,6 +1283,28 @@ gdk_display_notify_startup_complete (GdkDisplay *display, GDK_DISPLAY_GET_CLASS (display)->notify_startup_complete (display, startup_id); } +/** + * gdk_display_get_startup_notification_id: + * @display: (type GdkX11Display): a #GdkDisplay + * + * Gets the startup notification ID for a Wayland display, or %NULL + * if no ID has been defined. + * + * Returns: the startup notification ID for @display, or %NULL + * + * Since: 4.0 + */ +const gchar * +gdk_display_get_startup_notification_id (GdkDisplay *display) +{ + g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + + if (GDK_DISPLAY_GET_CLASS (display)->get_startup_notification_id == NULL) + return NULL; + + return GDK_DISPLAY_GET_CLASS (display)->get_startup_notification_id (display); +} + void _gdk_display_pause_events (GdkDisplay *display) { diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h index b9f5d71fd8..547e2a10de 100644 --- a/gdk/gdkdisplay.h +++ b/gdk/gdkdisplay.h @@ -94,6 +94,8 @@ gboolean gdk_display_supports_input_shapes (GdkDisplay *display); GDK_AVAILABLE_IN_ALL void gdk_display_notify_startup_complete (GdkDisplay *display, const gchar *startup_id); +GDK_AVAILABLE_IN_ALL +const gchar * gdk_display_get_startup_notification_id (GdkDisplay *display); GDK_AVAILABLE_IN_ALL GdkAppLaunchContext *gdk_display_get_app_launch_context (GdkDisplay *display); diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index ac873281b5..28a656c9d8 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -136,6 +136,8 @@ struct _GdkDisplayClass void (*notify_startup_complete) (GdkDisplay *display, const gchar *startup_id); + const gchar * (*get_startup_notification_id) (GdkDisplay *display); + void (*event_data_copy) (GdkDisplay *display, const GdkEvent *event, GdkEvent *new_event); diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 2f46817be4..4c264fabee 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -857,6 +857,23 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display) return ++serial; } +/** + * gdk_wayland_display_get_startup_notification_id: + * @display: (type GdkX11Display): a #GdkDisplay + * + * Gets the startup notification ID for a Wayland display, or %NULL + * if no ID has been defined. + * + * Returns: the startup notification ID for @display, or %NULL + * + * Since: 4.0 + */ +const gchar * +gdk_wayland_display_get_startup_notification_id (GdkDisplay *display) +{ + return GDK_WAYLAND_DISPLAY (display)->startup_notification_id; +} + /** * gdk_wayland_display_set_startup_notification_id: * @display: (type GdkWaylandDisplay): a #GdkDisplay @@ -1005,6 +1022,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->supports_input_shapes = gdk_wayland_display_supports_input_shapes; display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context; display_class->get_next_serial = gdk_wayland_display_get_next_serial; + display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id; display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete; display_class->create_surface_impl = _gdk_wayland_display_create_surface_impl; display_class->get_keymap = _gdk_wayland_display_get_keymap; diff --git a/gdk/wayland/gdkwaylanddisplay.h b/gdk/wayland/gdkwaylanddisplay.h index 64c2b55f45..c6f3b24747 100644 --- a/gdk/wayland/gdkwaylanddisplay.h +++ b/gdk/wayland/gdkwaylanddisplay.h @@ -54,6 +54,8 @@ void gdk_wayland_display_set_cursor_theme (GdkDisplay *di const gchar *theme, gint size); GDK_AVAILABLE_IN_ALL +const gchar * gdk_wayland_display_get_startup_notification_id (GdkDisplay *display); +GDK_AVAILABLE_IN_ALL void gdk_wayland_display_set_startup_notification_id (GdkDisplay *display, const char *startup_id); diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index eaa457dcd7..735b6e06c1 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -3042,6 +3042,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context; display_class->get_next_serial = gdk_x11_display_get_next_serial; + display_class->get_startup_notification_id = gdk_x11_display_get_startup_notification_id; display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete; display_class->create_surface_impl = _gdk_x11_display_create_surface_impl; display_class->get_keymap = gdk_x11_display_get_keymap;