Merge lp:~didrocks/unity/dont-ack-multiple-place-requests into lp:unity

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 1168
Proposed branch: lp:~didrocks/unity/dont-ack-multiple-place-requests
Merge into: lp:unity
Diff against target: 223 lines (+89/-8)
5 files modified
src/PanelTitlebarGrabAreaView.cpp (+3/-3)
src/PlacesController.cpp (+44/-4)
src/PlacesController.h (+6/-0)
src/PlacesHomeView.cpp (+32/-1)
src/PlacesHomeView.h (+4/-0)
To merge this branch: bzr merge lp:~didrocks/unity/dont-ack-multiple-place-requests
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+58488@code.launchpad.net

Description of the change

Don't ack double/triple click or super press on bfb and places icons.
(LP: #766776)
This is workarounded in different files right now, the correct fix will be to
handle that in the ubus level (too risky at this stage), added FIXME to remember
that for oneiric.

There is one glitch though, which cannot been tackled without the ubus rewrite:
- if you open a place, then, double click on a placeicon in the launcher to
  close it, it will be closed by will be reactivated (this is because we send
  the UBUS_PLACE_ENTRY_ACTIVATE_REQUEST again on click).
- so, the next super press will not show the home dash, but the active place
  (closing/opening it again will reset to the home dash)

I still think it's an improvment (see Charline's report in maverick for double
clicking on bfb and people being puzzled) and the last described glitch only
impact people double clicking on a place LauncherIcon for closing it…

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PanelTitlebarGrabAreaView.cpp'
2--- src/PanelTitlebarGrabAreaView.cpp 2011-03-17 15:34:34 +0000
3+++ src/PanelTitlebarGrabAreaView.cpp 2011-04-20 12:42:18 +0000
4@@ -90,11 +90,11 @@
5 clock_gettime(CLOCK_MONOTONIC, &event_time);
6 delta = time_diff (_last_click_time, event_time);
7
8+ _last_click_time.tv_sec = event_time.tv_sec;
9+ _last_click_time.tv_nsec = event_time.tv_nsec;
10+
11 if ((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_MOUSE_DOUBLE_CLICK))
12 RecvMouseDoubleClick (x, y, button_flags, key_flags);
13-
14- _last_click_time.tv_sec = event_time.tv_sec;
15- _last_click_time.tv_nsec = event_time.tv_nsec;
16 }
17
18 struct timespec PanelTitlebarGrabArea::time_diff (struct timespec start, struct timespec end)
19
20=== modified file 'src/PlacesController.cpp'
21--- src/PlacesController.cpp 2011-04-15 10:08:19 +0000
22+++ src/PlacesController.cpp 2011-04-20 12:42:18 +0000
23@@ -34,6 +34,7 @@
24 #include "PlacesController.h"
25
26 #define PANEL_HEIGHT 24
27+#define DELTA_DOUBLE_REQUEST 500000000
28
29 int PlacesController::_launcher_size = 66;
30
31@@ -47,6 +48,8 @@
32 for (unsigned int i = 0; i < G_N_ELEMENTS (_ubus_handles); i++)
33 _ubus_handles[i] = 0;
34
35+ _last_activate_time.tv_sec = 0;
36+ _last_activate_time.tv_nsec = 0;
37 // register interest with ubus so that we get activation messages
38 UBusServer *ubus = ubus_server_get_default ();
39 _ubus_handles[0] = ubus_server_register_interest (ubus,
40@@ -311,30 +314,53 @@
41 height));
42 }
43
44+bool PlacesController::IsActivationValid ()
45+{
46+ struct timespec event_time, delta;
47+ clock_gettime(CLOCK_MONOTONIC, &event_time);
48+ delta = time_diff (_last_activate_time, event_time);
49+
50+ _last_activate_time.tv_sec = event_time.tv_sec;
51+ _last_activate_time.tv_nsec = event_time.tv_nsec;
52+
53+ // FIXME: this should be handled by ubus (not sending the request twice
54+ // for some selected ones). Too intrusive for now.
55+ if (!((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_DOUBLE_REQUEST)))
56+ return true;
57+ return false;
58+}
59+
60 void
61 PlacesController::ExternalActivation (GVariant *data, void *val)
62 {
63 PlacesController *self = (PlacesController*)val;
64- self->ToggleShowHide ();
65+
66+ if (self->IsActivationValid ())
67+ self->ToggleShowHide ();
68+
69 }
70
71 void
72 PlacesController::CloseRequest (GVariant *data, void *val)
73 {
74 PlacesController *self = (PlacesController*)val;
75- self->Hide ();
76+
77+ if (self->IsActivationValid ())
78+ self->Hide ();
79 }
80
81 void
82 PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags)
83 {
84- Hide ();
85+ if (IsActivationValid ())
86+ Hide ();
87 }
88
89 void
90 PlacesController::OnActivePlaceEntryChanged (PlaceEntry *entry)
91 {
92- entry ? Show () : Hide ();
93+ if (IsActivationValid ())
94+ entry ? Show () : Hide ();
95 }
96
97 void
98@@ -361,3 +387,17 @@
99 {
100 // We don't need to do anything just yet over here, it's a placeholder for when we do
101 }
102+
103+// TODO: put that in some "util" toolbox
104+struct timespec PlacesController::time_diff (struct timespec start, struct timespec end)
105+{
106+ struct timespec temp;
107+ if ((end.tv_nsec - start.tv_nsec) < 0) {
108+ temp.tv_sec = end.tv_sec - start.tv_sec-1;
109+ temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
110+ } else {
111+ temp.tv_sec = end.tv_sec - start.tv_sec;
112+ temp.tv_nsec = end.tv_nsec - start.tv_nsec;
113+ }
114+ return temp;
115+}
116
117=== modified file 'src/PlacesController.h'
118--- src/PlacesController.h 2011-04-13 07:49:27 +0000
119+++ src/PlacesController.h 2011-04-20 12:42:18 +0000
120@@ -31,6 +31,8 @@
121 #include "PlacesView.h"
122 #include "Introspectable.h"
123
124+#include <time.h>
125+
126 #include <Nux/BaseWindow.h>
127 #include <Nux/TimelineEasings.h>
128
129@@ -81,6 +83,10 @@
130 gint64 _start_time;
131 GdkRectangle _monitor_rect;
132
133+ bool IsActivationValid ();
134+ struct timespec time_diff (struct timespec start, struct timespec end);
135+ struct timespec _last_activate_time;
136+
137 bool _need_show;
138
139 guint _ubus_handles[2];
140
141=== modified file 'src/PlacesHomeView.cpp'
142--- src/PlacesHomeView.cpp 2011-04-14 13:52:20 +0000
143+++ src/PlacesHomeView.cpp 2011-04-20 12:42:18 +0000
144@@ -51,6 +51,8 @@
145 #define MAIL_DIR "/desktop/gnome/url-handlers/mailto"
146 #define MEDIA_DIR DESKTOP_DIR"/media"
147
148+#define DELTA_DOUBLE_REQUEST 500000000
149+
150 enum
151 {
152 TYPE_PLACE=0,
153@@ -132,6 +134,9 @@
154 (GConfClientNotifyFunc)OnKeyChanged,
155 this,
156 NULL, NULL);
157+
158+ _last_activate_time.tv_sec = 0;
159+ _last_activate_time.tv_nsec = 0;
160
161 _ubus_handle = ubus_server_register_interest (ubus_server_get_default (),
162 UBUS_DASH_EXTERNAL_ACTIVATION,
163@@ -180,7 +185,19 @@
164 PlacesHomeView::DashVisible (GVariant *data, void *val)
165 {
166 PlacesHomeView *self = (PlacesHomeView*)val;
167- self->Refresh ();
168+
169+ struct timespec event_time, delta;
170+ clock_gettime(CLOCK_MONOTONIC, &event_time);
171+ delta = self->time_diff (self->_last_activate_time, event_time);
172+
173+ self->_last_activate_time.tv_sec = event_time.tv_sec;
174+ self->_last_activate_time.tv_nsec = event_time.tv_nsec;
175+
176+ // FIXME: this should be handled by ubus (not sending the request twice
177+ // for some selected ones). Too intrusive for now.
178+ if (!((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_DOUBLE_REQUEST)))
179+ self->Refresh ();
180+
181 }
182
183 void
184@@ -404,3 +421,17 @@
185 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
186 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
187 }
188+
189+// TODO: put that in some "util" toolbox
190+struct timespec PlacesHomeView::time_diff (struct timespec start, struct timespec end)
191+{
192+ struct timespec temp;
193+ if ((end.tv_nsec - start.tv_nsec) < 0) {
194+ temp.tv_sec = end.tv_sec - start.tv_sec-1;
195+ temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
196+ } else {
197+ temp.tv_sec = end.tv_sec - start.tv_sec;
198+ temp.tv_nsec = end.tv_nsec - start.tv_nsec;
199+ }
200+ return temp;
201+}
202
203=== modified file 'src/PlacesHomeView.h'
204--- src/PlacesHomeView.h 2011-04-12 14:34:08 +0000
205+++ src/PlacesHomeView.h 2011-04-20 12:42:18 +0000
206@@ -33,6 +33,7 @@
207 #include "PlacesGroup.h"
208
209 #include <gconf/gconf-client.h>
210+#include <time.h>
211
212 class PlacesHomeView : public Introspectable, public PlacesGroup
213 {
214@@ -66,6 +67,9 @@
215 std::vector<std::string> _photo_alternatives;
216 std::vector<std::string> _email_alternatives;
217 std::vector<std::string> _music_alternatives;
218+
219+ struct timespec time_diff (struct timespec start, struct timespec end);
220+ struct timespec _last_activate_time;
221
222 guint _ubus_handle;
223 };