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
This commit is contained in:
Mario Sanchez Prada 2018-06-04 17:27:36 +01:00
parent ef3427575f
commit 938448e0ef
6 changed files with 47 additions and 0 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;