Merge lp:~unity-team/unity/show-menu-later into lp:unity

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 633
Proposed branch: lp:~unity-team/unity/show-menu-later
Merge into: lp:unity
Diff against target: 91 lines (+52/-15)
1 file modified
src/IndicatorObjectFactoryRemote.cpp (+52/-15)
To merge this branch: bzr merge lp:~unity-team/unity/show-menu-later
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+41858@code.launchpad.net

Description of the change

Due to timing issues on slower systems, the current way of relying on one XFlush to make sure X honors our ungrab pointer request isn't good enough. This update pushes the calling of the dbus method to the end of the main iteration, and gives us a chance to XFlush twice, which works on those systems (tested on two affected systems: netbook (njpatel) and desktop (didrocks)).

Main thing to test here is that it hasn't broken opening menus for you. There are no tests because we can't test something like this right now.

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

+1, works here

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/IndicatorObjectFactoryRemote.cpp'
2--- src/IndicatorObjectFactoryRemote.cpp 2010-11-17 20:12:42 +0000
3+++ src/IndicatorObjectFactoryRemote.cpp 2010-11-25 13:10:03 +0000
4@@ -33,8 +33,17 @@
5 #define S_PATH "/com/canonical/Unity/Panel/Service"
6 #define S_IFACE "com.canonical.Unity.Panel.Service"
7
8-
9-// Enums
10+typedef struct
11+{
12+ GDBusProxy *proxy;
13+ gchar *entry_id;
14+ int x;
15+ int y;
16+ guint timestamp;
17+ guint32 button;
18+
19+} ShowEntryData;
20+
21
22 // Forwards
23 static void on_proxy_ready_cb (GObject *source,
24@@ -125,6 +134,35 @@
25 this);
26 }
27
28+static gboolean
29+send_show_entry (ShowEntryData *data)
30+{
31+ g_return_val_if_fail (data != NULL, FALSE);
32+ g_return_val_if_fail (G_IS_DBUS_PROXY (data->proxy), FALSE);
33+
34+ /* Re-flush 'cos X is crap like that */
35+ Display* d = nux::GetThreadGLWindow()->GetX11Display();
36+ XFlush (d);
37+
38+ g_dbus_proxy_call (data->proxy,
39+ "ShowEntry",
40+ g_variant_new ("(suiii)",
41+ data->entry_id,
42+ 0,
43+ data->x,
44+ data->y,
45+ data->button),
46+ G_DBUS_CALL_FLAGS_NONE,
47+ -1,
48+ NULL,
49+ NULL,
50+ NULL);
51+
52+ g_free (data->entry_id);
53+ g_slice_free (ShowEntryData, data);
54+ return FALSE;
55+}
56+
57 void
58 IndicatorObjectFactoryRemote::OnShowMenuRequestReceived (const char *entry_id,
59 int x,
60@@ -136,19 +174,18 @@
61 XUngrabPointer(d, CurrentTime);
62 XFlush (d);
63
64- g_dbus_proxy_call (_proxy,
65- "ShowEntry",
66- g_variant_new ("(suiii)",
67- entry_id,
68- 0,
69- x,
70- y,
71- button),
72- G_DBUS_CALL_FLAGS_NONE,
73- -1,
74- NULL,
75- NULL,
76- NULL);
77+ // We have to do this because on certain systems X won't have time to
78+ // respond to our request for XUngrabPointer and this will cause the
79+ // menu not to show
80+ ShowEntryData *data = g_slice_new0 (ShowEntryData);
81+ data->proxy = _proxy;
82+ data->entry_id = g_strdup (entry_id);
83+ data->x = x;
84+ data->y = y;
85+ data->timestamp = timestamp;
86+ data->button = button;
87+
88+ g_timeout_add (0, (GSourceFunc)send_show_entry, data);
89
90 // --------------------------------------------------------------------------
91 // FIXME: This is a workaround until the non-paired events issue is fixed in