Merge branch 'wip/carlosg/startup-vs-focus-3-24' into 'gtk-3-24'

Consider startup vs focus requests for the Wayland platform [3.24]

See merge request GNOME/gtk!5443
This commit is contained in:
Matthias Clasen
2023-01-25 13:09:17 +00:00
4 changed files with 76 additions and 39 deletions

View File

@@ -4160,6 +4160,27 @@ static void
gdk_wayland_window_set_startup_id (GdkWindow *window,
const gchar *startup_id)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkDisplay *display = gdk_window_get_display (window);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
gchar *free_me = NULL;
if (!startup_id)
{
free_me = g_steal_pointer (&display_wayland->startup_notification_id);
startup_id = free_me;
}
#ifdef HAVE_XDG_ACTIVATION
if (startup_id)
{
xdg_activation_v1_activate (display_wayland->xdg_activation,
startup_id,
impl->display_server.wl_surface);
}
#endif
g_free (free_me);
}
static gboolean

View File

@@ -2901,6 +2901,7 @@ gdk_x11_window_set_startup_id (GdkWindow *window,
const gchar *startup_id)
{
GdkDisplay *display;
gchar *free_this = NULL;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -2918,6 +2919,23 @@ gdk_x11_window_set_startup_id (GdkWindow *window,
else
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"));
if (startup_id == NULL)
{
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
startup_id = free_this = display_x11->startup_notification_id;
display_x11->startup_notification_id = NULL;
if (startup_id == NULL)
return;
}
gdk_x11_display_broadcast_startup_message (display, "remove",
"ID", startup_id,
NULL);
g_free (free_this);
}
static void

View File

@@ -376,18 +376,6 @@ static void
gtk_application_after_emit (GApplication *application,
GVariant *platform_data)
{
const char *startup_notification_id = NULL;
g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_notification_id);
if (startup_notification_id)
{
GdkDisplay *display;
display = gdk_display_get_default ();
if (display)
gdk_display_notify_startup_complete (display, startup_notification_id);
}
gdk_threads_leave ();
}

View File

@@ -266,6 +266,8 @@ struct _GtkWindowPrivate
guint use_subsurface : 1;
guint in_present : 1;
GdkWindowTypeHint type_hint;
GtkGesture *multipress_gesture;
@@ -2563,15 +2565,12 @@ gtk_window_set_startup_id (GtkWindow *window,
*/
if (startup_id_is_fake (priv->startup_id))
gtk_window_present_with_time (window, timestamp);
else
else
{
gdk_window_set_startup_id (gdk_window,
priv->startup_id);
/* If window is mapped, terminate the startup-notification too */
/* If window is mapped, terminate the startup-notification */
if (_gtk_widget_get_mapped (widget) &&
!disable_startup_notification)
gdk_notify_startup_complete_with_id (priv->startup_id);
gdk_window_set_startup_id (gdk_window, priv->startup_id);
}
}
@@ -6279,6 +6278,32 @@ popover_map (GtkWidget *widget,
}
}
static void
gtk_window_notify_startup (GtkWindow *window)
{
GtkWindowPrivate *priv = window->priv;
if (!disable_startup_notification &&
!GTK_IS_OFFSCREEN_WINDOW (window) &&
priv->type != GTK_WINDOW_POPUP)
{
/* Do we have a custom startup-notification id? */
if (priv->startup_id != NULL)
{
/* Make sure we have a "real" id */
if (!startup_id_is_fake (priv->startup_id))
gdk_notify_startup_complete_with_id (priv->startup_id);
g_free (priv->startup_id);
priv->startup_id = NULL;
}
else
{
gdk_notify_startup_complete ();
}
}
}
static void
gtk_window_map (GtkWidget *widget)
{
@@ -6354,25 +6379,8 @@ gtk_window_map (GtkWidget *widget)
gdk_window_show (gdk_window);
if (!disable_startup_notification &&
!GTK_IS_OFFSCREEN_WINDOW (window) &&
priv->type != GTK_WINDOW_POPUP)
{
/* Do we have a custom startup-notification id? */
if (priv->startup_id != NULL)
{
/* Make sure we have a "real" id */
if (!startup_id_is_fake (priv->startup_id))
gdk_notify_startup_complete_with_id (priv->startup_id);
g_free (priv->startup_id);
priv->startup_id = NULL;
}
else
{
gdk_notify_startup_complete ();
}
}
if (!priv->in_present)
gtk_window_notify_startup (window);
/* if mnemonics visible is not already set
* (as in the case of popup menus), then hide mnemonics initially
@@ -7614,8 +7622,6 @@ gtk_window_realize (GtkWidget *widget)
gdk_x11_window_set_user_time (gdk_window, timestamp);
}
#endif
if (!startup_id_is_fake (priv->startup_id))
gdk_window_set_startup_id (gdk_window, priv->startup_id);
}
#ifdef GDK_WINDOWING_X11
@@ -10597,8 +10603,12 @@ gtk_window_present_with_time (GtkWindow *window,
else
{
priv->initial_timestamp = timestamp;
priv->in_present = TRUE;
gtk_widget_show (widget);
priv->in_present = FALSE;
}
gtk_window_notify_startup (window);
}
/**