diff options
author | Ryan Lortie <desrt@desrt.ca> | 2015-07-06 14:08:11 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2015-07-14 18:34:09 -0700 |
commit | a00a5ed2104b516200c13c40be3ffa174d87fd91 (patch) | |
tree | c1020275244ea74234f7681ffa10041bca8b3b40 /gdk/x11 | |
parent | 18dbe181fb13571ecbc76ce7f7f28c36c557a3d6 (diff) | |
download | gtk+-a00a5ed2104b516200c13c40be3ffa174d87fd91.tar.gz |
GtkApplication: avoid using stale timestamps
Avoid using a stale timestamp (from the last user interaction with the
application) when a message arrives from D-Bus requesting that a new
window be created.
In this case the most-correct thing that we can do is to use no
timestamp at all.
We modify gdk_x11_display_set_startup_notification_id() to allow a NULL
value to mean "reset everything" and then call this function
unconditionally on receipt of D-Bus activation requests. The result
will be that a missing desktop-startup-id in the platform-data struct
will reset the timestamp.
Under their default configuration metacity and mutter will both map
windows presented with no timestamp in the foreground. This could
result in false-positive, but there is very little we can do about that
without the original timestamp from the user event.
https://bugzilla.gnome.org/show_bug.cgi?id=752000
Diffstat (limited to 'gdk/x11')
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index dd608fa8de..da4382fad7 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -2388,33 +2388,44 @@ gdk_x11_display_set_startup_notification_id (GdkDisplay *display, g_free (display_x11->startup_notification_id); display_x11->startup_notification_id = g_strdup (startup_id); - /* Find the launch time from the startup_id, if it's there. Newer spec - * states that the startup_id is of the form <unique>_TIME<timestamp> - */ - time_str = g_strrstr (startup_id, "_TIME"); - if (time_str != NULL) + if (startup_id != NULL) { - gulong retval; - gchar *end; - errno = 0; + /* Find the launch time from the startup_id, if it's there. Newer spec + * states that the startup_id is of the form <unique>_TIME<timestamp> + */ + time_str = g_strrstr (startup_id, "_TIME"); + if (time_str != NULL) + { + gulong retval; + gchar *end; + errno = 0; - /* Skip past the "_TIME" part */ - time_str += 5; + /* Skip past the "_TIME" part */ + time_str += 5; - retval = strtoul (time_str, &end, 0); - if (end != time_str && errno == 0) - display_x11->user_time = retval; - } + retval = strtoul (time_str, &end, 0); + if (end != time_str && errno == 0) + display_x11->user_time = retval; + } + else + display_x11->user_time = 0; - /* Set the startup id on the leader window so it - * applies to all windows we create on this display - */ - XChangeProperty (display_x11->xdisplay, - display_x11->leader_window, - gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"), - gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, - PropModeReplace, - (guchar *)startup_id, strlen (startup_id)); + /* Set the startup id on the leader window so it + * applies to all windows we create on this display + */ + XChangeProperty (display_x11->xdisplay, + display_x11->leader_window, + gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"), + gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, + PropModeReplace, + (guchar *)startup_id, strlen (startup_id)); + } + else + { + XDeleteProperty (display_x11->xdisplay, display_x11->leader_window, + gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID")); + display_x11->user_time = 0; + } } static gboolean |