Merge lp:~saviq/unity-2d/fix-launcher-timestamp into lp:unity-2d

Proposed by Michał Sawicz
Status: Merged
Approved by: Florian Boucault
Approved revision: 718
Merged at revision: 718
Proposed branch: lp:~saviq/unity-2d/fix-launcher-timestamp
Merge into: lp:unity-2d
Diff against target: 39 lines (+15/-6)
1 file modified
libunity-2d-private/src/launcherapplication.cpp (+15/-6)
To merge this branch: bzr merge lp:~saviq/unity-2d/fix-launcher-timestamp
Reviewer Review Type Date Requested Status
Florian Boucault Pending
Review via email: mp+75182@code.launchpad.net

Commit message

[launcher] Fix interaction with the window manager

When launching a new application, we need to forward a proper timestamp from the X server so that the window manager can successfully do focus stealing prevention.

To post a comment you must log in.
718. By Michał Sawicz

Tweak the comments.

Revision history for this message
Michał Sawicz (saviq) wrote :

[launcher] Fix interaction with the window manager

When launching a new application, we need to forward a proper timestamp from the X server so that the window manager can successfully do focus stealing prevention.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
2--- libunity-2d-private/src/launcherapplication.cpp 2011-08-18 09:40:57 +0000
3+++ libunity-2d-private/src/launcherapplication.cpp 2011-09-14 08:52:26 +0000
4@@ -56,6 +56,7 @@
5
6 extern "C" {
7 #include <gdk/gdk.h>
8+#include <gdk/gdkx.h>
9 #include <libsn/sn.h>
10 }
11
12@@ -656,14 +657,22 @@
13 }
14
15 GError* error = NULL;
16- GTimeVal timeval;
17-
18- g_get_current_time (&timeval);
19+
20+ GdkWindow* root;
21+ guint32 timestamp;
22+
23 GdkDisplay* display = gdk_display_get_default();
24 GObjectScopedPointer<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
25- /* Using GDK_CURRENT_TIME doesn’t seem to work, launched windows
26- sometimes don’t get focus (see https://launchpad.net/bugs/643616). */
27- gdk_app_launch_context_set_timestamp(context.data(), timeval.tv_sec);
28+
29+ /* We need to take the timestamp from the X server for the
30+ window manager to work properly
31+ https://bugs.launchpad.net/unity-2d/+bug/735205 */
32+ /* FIXME: ultimately we should forward the timestamps from
33+ events that triggered the launch */
34+ root = gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW());
35+ timestamp = gdk_x11_get_server_time(root);
36+
37+ gdk_app_launch_context_set_timestamp(context.data(), timestamp);
38
39 g_app_info_launch(m_appInfo.data(), NULL, (GAppLaunchContext*)context.data(), &error);
40

Subscribers

People subscribed via source and target branches