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
=== modified file 'src/PanelTitlebarGrabAreaView.cpp'
--- src/PanelTitlebarGrabAreaView.cpp 2011-03-17 15:34:34 +0000
+++ src/PanelTitlebarGrabAreaView.cpp 2011-04-20 12:42:18 +0000
@@ -90,11 +90,11 @@
90 clock_gettime(CLOCK_MONOTONIC, &event_time);90 clock_gettime(CLOCK_MONOTONIC, &event_time);
91 delta = time_diff (_last_click_time, event_time);91 delta = time_diff (_last_click_time, event_time);
9292
93 _last_click_time.tv_sec = event_time.tv_sec;
94 _last_click_time.tv_nsec = event_time.tv_nsec;
95
93 if ((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_MOUSE_DOUBLE_CLICK))96 if ((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_MOUSE_DOUBLE_CLICK))
94 RecvMouseDoubleClick (x, y, button_flags, key_flags);97 RecvMouseDoubleClick (x, y, button_flags, key_flags);
95
96 _last_click_time.tv_sec = event_time.tv_sec;
97 _last_click_time.tv_nsec = event_time.tv_nsec;
98}98}
9999
100struct timespec PanelTitlebarGrabArea::time_diff (struct timespec start, struct timespec end)100struct timespec PanelTitlebarGrabArea::time_diff (struct timespec start, struct timespec end)
101101
=== modified file 'src/PlacesController.cpp'
--- src/PlacesController.cpp 2011-04-15 10:08:19 +0000
+++ src/PlacesController.cpp 2011-04-20 12:42:18 +0000
@@ -34,6 +34,7 @@
34#include "PlacesController.h"34#include "PlacesController.h"
3535
36#define PANEL_HEIGHT 2436#define PANEL_HEIGHT 24
37#define DELTA_DOUBLE_REQUEST 500000000
3738
38int PlacesController::_launcher_size = 66;39int PlacesController::_launcher_size = 66;
3940
@@ -47,6 +48,8 @@
47 for (unsigned int i = 0; i < G_N_ELEMENTS (_ubus_handles); i++)48 for (unsigned int i = 0; i < G_N_ELEMENTS (_ubus_handles); i++)
48 _ubus_handles[i] = 0;49 _ubus_handles[i] = 0;
4950
51 _last_activate_time.tv_sec = 0;
52 _last_activate_time.tv_nsec = 0;
50 // register interest with ubus so that we get activation messages53 // register interest with ubus so that we get activation messages
51 UBusServer *ubus = ubus_server_get_default ();54 UBusServer *ubus = ubus_server_get_default ();
52 _ubus_handles[0] = ubus_server_register_interest (ubus,55 _ubus_handles[0] = ubus_server_register_interest (ubus,
@@ -311,30 +314,53 @@
311 height));314 height));
312}315}
313316
317bool PlacesController::IsActivationValid ()
318{
319 struct timespec event_time, delta;
320 clock_gettime(CLOCK_MONOTONIC, &event_time);
321 delta = time_diff (_last_activate_time, event_time);
322
323 _last_activate_time.tv_sec = event_time.tv_sec;
324 _last_activate_time.tv_nsec = event_time.tv_nsec;
325
326 // FIXME: this should be handled by ubus (not sending the request twice
327 // for some selected ones). Too intrusive for now.
328 if (!((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_DOUBLE_REQUEST)))
329 return true;
330 return false;
331}
332
314void333void
315PlacesController::ExternalActivation (GVariant *data, void *val)334PlacesController::ExternalActivation (GVariant *data, void *val)
316{335{
317 PlacesController *self = (PlacesController*)val;336 PlacesController *self = (PlacesController*)val;
318 self->ToggleShowHide ();337
338 if (self->IsActivationValid ())
339 self->ToggleShowHide ();
340
319}341}
320342
321void343void
322PlacesController::CloseRequest (GVariant *data, void *val)344PlacesController::CloseRequest (GVariant *data, void *val)
323{345{
324 PlacesController *self = (PlacesController*)val;346 PlacesController *self = (PlacesController*)val;
325 self->Hide ();347
348 if (self->IsActivationValid ())
349 self->Hide ();
326}350}
327351
328void352void
329PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags)353PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags)
330{354{
331 Hide ();355 if (IsActivationValid ())
356 Hide ();
332}357}
333358
334void359void
335PlacesController::OnActivePlaceEntryChanged (PlaceEntry *entry)360PlacesController::OnActivePlaceEntryChanged (PlaceEntry *entry)
336{361{
337 entry ? Show () : Hide ();362 if (IsActivationValid ())
363 entry ? Show () : Hide ();
338}364}
339365
340void366void
@@ -361,3 +387,17 @@
361{387{
362 // We don't need to do anything just yet over here, it's a placeholder for when we do388 // We don't need to do anything just yet over here, it's a placeholder for when we do
363}389}
390
391// TODO: put that in some "util" toolbox
392struct timespec PlacesController::time_diff (struct timespec start, struct timespec end)
393{
394 struct timespec temp;
395 if ((end.tv_nsec - start.tv_nsec) < 0) {
396 temp.tv_sec = end.tv_sec - start.tv_sec-1;
397 temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
398 } else {
399 temp.tv_sec = end.tv_sec - start.tv_sec;
400 temp.tv_nsec = end.tv_nsec - start.tv_nsec;
401 }
402 return temp;
403}
364404
=== modified file 'src/PlacesController.h'
--- src/PlacesController.h 2011-04-13 07:49:27 +0000
+++ src/PlacesController.h 2011-04-20 12:42:18 +0000
@@ -31,6 +31,8 @@
31#include "PlacesView.h"31#include "PlacesView.h"
32#include "Introspectable.h"32#include "Introspectable.h"
3333
34#include <time.h>
35
34#include <Nux/BaseWindow.h>36#include <Nux/BaseWindow.h>
35#include <Nux/TimelineEasings.h>37#include <Nux/TimelineEasings.h>
3638
@@ -81,6 +83,10 @@
81 gint64 _start_time;83 gint64 _start_time;
82 GdkRectangle _monitor_rect;84 GdkRectangle _monitor_rect;
83 85
86 bool IsActivationValid ();
87 struct timespec time_diff (struct timespec start, struct timespec end);
88 struct timespec _last_activate_time;
89
84 bool _need_show;90 bool _need_show;
8591
86 guint _ubus_handles[2];92 guint _ubus_handles[2];
8793
=== modified file 'src/PlacesHomeView.cpp'
--- src/PlacesHomeView.cpp 2011-04-14 13:52:20 +0000
+++ src/PlacesHomeView.cpp 2011-04-20 12:42:18 +0000
@@ -51,6 +51,8 @@
51#define MAIL_DIR "/desktop/gnome/url-handlers/mailto"51#define MAIL_DIR "/desktop/gnome/url-handlers/mailto"
52#define MEDIA_DIR DESKTOP_DIR"/media"52#define MEDIA_DIR DESKTOP_DIR"/media"
5353
54#define DELTA_DOUBLE_REQUEST 500000000
55
54enum56enum
55{57{
56 TYPE_PLACE=0,58 TYPE_PLACE=0,
@@ -132,6 +134,9 @@
132 (GConfClientNotifyFunc)OnKeyChanged,134 (GConfClientNotifyFunc)OnKeyChanged,
133 this,135 this,
134 NULL, NULL);136 NULL, NULL);
137
138 _last_activate_time.tv_sec = 0;
139 _last_activate_time.tv_nsec = 0;
135140
136 _ubus_handle = ubus_server_register_interest (ubus_server_get_default (),141 _ubus_handle = ubus_server_register_interest (ubus_server_get_default (),
137 UBUS_DASH_EXTERNAL_ACTIVATION,142 UBUS_DASH_EXTERNAL_ACTIVATION,
@@ -180,7 +185,19 @@
180PlacesHomeView::DashVisible (GVariant *data, void *val)185PlacesHomeView::DashVisible (GVariant *data, void *val)
181{186{
182 PlacesHomeView *self = (PlacesHomeView*)val;187 PlacesHomeView *self = (PlacesHomeView*)val;
183 self->Refresh ();188
189 struct timespec event_time, delta;
190 clock_gettime(CLOCK_MONOTONIC, &event_time);
191 delta = self->time_diff (self->_last_activate_time, event_time);
192
193 self->_last_activate_time.tv_sec = event_time.tv_sec;
194 self->_last_activate_time.tv_nsec = event_time.tv_nsec;
195
196 // FIXME: this should be handled by ubus (not sending the request twice
197 // for some selected ones). Too intrusive for now.
198 if (!((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_DOUBLE_REQUEST)))
199 self->Refresh ();
200
184}201}
185202
186void203void
@@ -404,3 +421,17 @@
404 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));421 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
405 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));422 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
406}423}
424
425// TODO: put that in some "util" toolbox
426struct timespec PlacesHomeView::time_diff (struct timespec start, struct timespec end)
427{
428 struct timespec temp;
429 if ((end.tv_nsec - start.tv_nsec) < 0) {
430 temp.tv_sec = end.tv_sec - start.tv_sec-1;
431 temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
432 } else {
433 temp.tv_sec = end.tv_sec - start.tv_sec;
434 temp.tv_nsec = end.tv_nsec - start.tv_nsec;
435 }
436 return temp;
437}
407438
=== modified file 'src/PlacesHomeView.h'
--- src/PlacesHomeView.h 2011-04-12 14:34:08 +0000
+++ src/PlacesHomeView.h 2011-04-20 12:42:18 +0000
@@ -33,6 +33,7 @@
33#include "PlacesGroup.h"33#include "PlacesGroup.h"
3434
35#include <gconf/gconf-client.h>35#include <gconf/gconf-client.h>
36#include <time.h>
3637
37class PlacesHomeView : public Introspectable, public PlacesGroup38class PlacesHomeView : public Introspectable, public PlacesGroup
38{39{
@@ -66,6 +67,9 @@
66 std::vector<std::string> _photo_alternatives;67 std::vector<std::string> _photo_alternatives;
67 std::vector<std::string> _email_alternatives;68 std::vector<std::string> _email_alternatives;
68 std::vector<std::string> _music_alternatives;69 std::vector<std::string> _music_alternatives;
70
71 struct timespec time_diff (struct timespec start, struct timespec end);
72 struct timespec _last_activate_time;
6973
70 guint _ubus_handle;74 guint _ubus_handle;
71};75};