Merge lp:~didrocks/unity/launcher-fixes into lp:unity
- launcher-fixes
- Merge into trunk
Proposed by
Didier Roche-Tolomelli
Status: | Merged |
---|---|
Approved by: | Mirco Müller |
Approved revision: | no longer in the source branch. |
Merged at revision: | 959 |
Proposed branch: | lp:~didrocks/unity/launcher-fixes |
Merge into: | lp:unity |
Diff against target: |
651 lines (+228/-141) 7 files modified
com.canonical.Unity.gschema.xml (+1/-1) src/Launcher.cpp (+178/-129) src/Launcher.h (+24/-7) src/LauncherController.cpp (+4/-3) src/LauncherController.h (+1/-1) src/unityshell.cpp (+17/-0) src/unityshell.h (+3/-0) |
To merge this branch: | bzr merge lp:~didrocks/unity/launcher-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+53588@code.launchpad.net |
Commit message
Description of the change
This branch:
* Fix some false-positive when the check call isn't refresh on ws change (LP:
#730679)
* enable adding a new desktop file with the dbus call (LP: #670403)
* add another drag icon action: pressing for 500ms on a launcher icon would
decouple it from the Launcher. Clean some other code as well (LP: #727922)
* do some cleanup on the launcher code as well
To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote : | # |
As discussed on IRC, the Press&Hold should only happen with the touch framework, not the mouse one and it's not implemented yet.
Revision history for this message
Mirco Müller (macslow) wrote : | # |
Ok, approved then. I only wish we would have not wasted time on this before.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'com.canonical.Unity.gschema.xml' | |||
2 | --- com.canonical.Unity.gschema.xml 2011-03-07 15:25:13 +0000 | |||
3 | +++ com.canonical.Unity.gschema.xml 2011-03-16 10:54:46 +0000 | |||
4 | @@ -14,7 +14,7 @@ | |||
5 | 14 | </schema> | 14 | </schema> |
6 | 15 | <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> | 15 | <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> |
7 | 16 | <key type="as" name="favorites"> | 16 | <key type="as" name="favorites"> |
9 | 17 | <default>[ 'ubiquity-gtkui.desktop', 'nautilus-home.desktop', 'firefox.desktop', 'ubuntuone-control-panel-gtk.desktop', 'tomboy.desktop' ]</default> | 17 | <default>[ 'ubiquity-gtkui.desktop', 'nautilus-home.desktop', 'firefox.desktop', 'libreoffice-writer.desktop', 'libreoffice-calc.desktop', 'libreoffice-impress.desktop', 'ubuntu-software-center.desktop', 'ubuntuone-control-panel-gtk.desktop' ]</default> |
10 | 18 | <summary>List of desktop file ids for favorites on the launcher.</summary> | 18 | <summary>List of desktop file ids for favorites on the launcher.</summary> |
11 | 19 | <description>These applications are shown in the Launcher by default.</description> | 19 | <description>These applications are shown in the Launcher by default.</description> |
12 | 20 | </key> | 20 | </key> |
13 | 21 | 21 | ||
14 | === modified file 'src/Launcher.cpp' | |||
15 | --- src/Launcher.cpp 2011-03-11 16:59:00 +0000 | |||
16 | +++ src/Launcher.cpp 2011-03-16 10:54:46 +0000 | |||
17 | @@ -51,6 +51,10 @@ | |||
18 | 51 | 51 | ||
19 | 52 | #define BACKLIGHT_STRENGTH 0.9f | 52 | #define BACKLIGHT_STRENGTH 0.9f |
20 | 53 | 53 | ||
21 | 54 | #define S_DBUS_NAME "com.canonical.Unity.Launcher" | ||
22 | 55 | #define S_DBUS_PATH "/com/canonical/Unity/Launcher" | ||
23 | 56 | #define S_DBUS_IFACE "com.canonical.Unity.Launcher" | ||
24 | 57 | |||
25 | 54 | NUX_IMPLEMENT_OBJECT_TYPE (Launcher); | 58 | NUX_IMPLEMENT_OBJECT_TYPE (Launcher); |
26 | 55 | 59 | ||
27 | 56 | int | 60 | int |
28 | @@ -72,6 +76,30 @@ | |||
29 | 72 | timeref->tv_nsec -= remove * 1000000; | 76 | timeref->tv_nsec -= remove * 1000000; |
30 | 73 | } | 77 | } |
31 | 74 | 78 | ||
32 | 79 | const gchar Launcher::introspection_xml[] = | ||
33 | 80 | "<node>" | ||
34 | 81 | " <interface name='com.canonical.Unity.Launcher'>" | ||
35 | 82 | "" | ||
36 | 83 | " <method name='AddLauncherItemFromPosition'>" | ||
37 | 84 | " <arg type='s' name='icon' direction='in'/>" | ||
38 | 85 | " <arg type='s' name='title' direction='in'/>" | ||
39 | 86 | " <arg type='i' name='icon_x' direction='in'/>" | ||
40 | 87 | " <arg type='i' name='icon_y' direction='in'/>" | ||
41 | 88 | " <arg type='i' name='icon_size' direction='in'/>" | ||
42 | 89 | " <arg type='s' name='desktop_file' direction='in'/>" | ||
43 | 90 | " <arg type='s' name='aptdaemon_task' direction='in'/>" | ||
44 | 91 | " </method>" | ||
45 | 92 | "" | ||
46 | 93 | " </interface>" | ||
47 | 94 | "</node>"; | ||
48 | 95 | |||
49 | 96 | GDBusInterfaceVTable Launcher::interface_vtable = | ||
50 | 97 | { | ||
51 | 98 | Launcher::handle_dbus_method_call, | ||
52 | 99 | NULL, | ||
53 | 100 | NULL | ||
54 | 101 | }; | ||
55 | 102 | |||
56 | 75 | 103 | ||
57 | 76 | /* | 104 | /* |
58 | 77 | Use this shader to pass vertices in screen coordinates in the C++ code and compute use | 105 | Use this shader to pass vertices in screen coordinates in the C++ code and compute use |
59 | @@ -303,9 +331,8 @@ | |||
60 | 303 | _autohide_handle = 0; | 331 | _autohide_handle = 0; |
61 | 304 | _autoscroll_handle = 0; | 332 | _autoscroll_handle = 0; |
62 | 305 | _redraw_handle = 0; | 333 | _redraw_handle = 0; |
63 | 334 | _start_dragicon_handle = 0; | ||
64 | 306 | _focus_keynav_handle = 0; | 335 | _focus_keynav_handle = 0; |
65 | 307 | _single_finger_hold_handle = 0; | ||
66 | 308 | _single_finger_hold_timer = NULL; | ||
67 | 309 | _floating = false; | 336 | _floating = false; |
68 | 310 | _hovered = false; | 337 | _hovered = false; |
69 | 311 | _hidden = false; | 338 | _hidden = false; |
70 | @@ -355,6 +382,15 @@ | |||
71 | 355 | ubus_server_register_interest (ubus, UBUS_LAUNCHER_ACTION_DONE, | 382 | ubus_server_register_interest (ubus, UBUS_LAUNCHER_ACTION_DONE, |
72 | 356 | (UBusCallback)&Launcher::OnActionDone, | 383 | (UBusCallback)&Launcher::OnActionDone, |
73 | 357 | this); | 384 | this); |
74 | 385 | |||
75 | 386 | _dbus_owner = g_bus_own_name (G_BUS_TYPE_SESSION, | ||
76 | 387 | S_DBUS_NAME, | ||
77 | 388 | (GBusNameOwnerFlags) (G_BUS_NAME_OWNER_FLAGS_REPLACE | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT), | ||
78 | 389 | OnBusAcquired, | ||
79 | 390 | OnNameAcquired, | ||
80 | 391 | OnNameLost, | ||
81 | 392 | this, | ||
82 | 393 | NULL); | ||
83 | 358 | 394 | ||
84 | 359 | SetDndEnabled (false, true); | 395 | SetDndEnabled (false, true); |
85 | 360 | } | 396 | } |
86 | @@ -366,6 +402,7 @@ | |||
87 | 366 | if (_superkey_labels[i]) | 402 | if (_superkey_labels[i]) |
88 | 367 | _superkey_labels[i]->UnReference (); | 403 | _superkey_labels[i]->UnReference (); |
89 | 368 | } | 404 | } |
90 | 405 | g_bus_unown_name (_dbus_owner); | ||
91 | 369 | } | 406 | } |
92 | 370 | 407 | ||
93 | 371 | /* Introspection */ | 408 | /* Introspection */ |
94 | @@ -608,11 +645,6 @@ | |||
95 | 608 | return pow (1.0f - CLAMP ((float) (TimeDelta (¤t, &_times[TIME_DRAG_END])) / (float) ANIM_DURATION_LONG, 0.0f, 1.0f), 2); | 645 | return pow (1.0f - CLAMP ((float) (TimeDelta (¤t, &_times[TIME_DRAG_END])) / (float) ANIM_DURATION_LONG, 0.0f, 1.0f), 2); |
96 | 609 | } | 646 | } |
97 | 610 | 647 | ||
98 | 611 | float Launcher::DnDStartProgress (struct timespec const ¤t) | ||
99 | 612 | { | ||
100 | 613 | return CLAMP ((float) (TimeDelta (¤t, &_times[TIME_DRAG_START])) / (float) ANIM_DURATION, 0.0f, 1.0f); | ||
101 | 614 | } | ||
102 | 615 | |||
103 | 616 | float Launcher::AutohideProgress (struct timespec const ¤t) | 648 | float Launcher::AutohideProgress (struct timespec const ¤t) |
104 | 617 | { | 649 | { |
105 | 618 | 650 | ||
106 | @@ -624,7 +656,7 @@ | |||
107 | 624 | return 0.0f; | 656 | return 0.0f; |
108 | 625 | 657 | ||
109 | 626 | // "dead" zone | 658 | // "dead" zone |
111 | 627 | if ((_trigger_mouse_position.x < 2) && (_trigger_mouse_position.y < 2)) | 659 | if ((_trigger_mouse_position.x < 3) && (_trigger_mouse_position.y < 3)) |
112 | 628 | return GetAutohidePositionMin (); | 660 | return GetAutohidePositionMin (); |
113 | 629 | 661 | ||
114 | 630 | /* | 662 | /* |
115 | @@ -749,10 +781,6 @@ | |||
116 | 749 | // hover out animation | 781 | // hover out animation |
117 | 750 | if (TimeDelta (¤t, &_times[TIME_LEAVE]) < ANIM_DURATION) | 782 | if (TimeDelta (¤t, &_times[TIME_LEAVE]) < ANIM_DURATION) |
118 | 751 | return true; | 783 | return true; |
119 | 752 | |||
120 | 753 | // drag start animation | ||
121 | 754 | if (TimeDelta (¤t, &_times[TIME_DRAG_START]) < ANIM_DURATION) | ||
122 | 755 | return true; | ||
123 | 756 | 784 | ||
124 | 757 | // drag end animation | 785 | // drag end animation |
125 | 758 | if (TimeDelta (¤t, &_times[TIME_DRAG_END]) < ANIM_DURATION_LONG) | 786 | if (TimeDelta (¤t, &_times[TIME_DRAG_END]) < ANIM_DURATION_LONG) |
126 | @@ -1442,7 +1470,7 @@ | |||
127 | 1442 | { | 1470 | { |
128 | 1443 | if (hidden == _hidden) | 1471 | if (hidden == _hidden) |
129 | 1444 | return; | 1472 | return; |
131 | 1445 | 1473 | ||
132 | 1446 | // auto lock/unlock the launcher depending on the state switch | 1474 | // auto lock/unlock the launcher depending on the state switch |
133 | 1447 | if (hidden) | 1475 | if (hidden) |
134 | 1448 | { | 1476 | { |
135 | @@ -1487,21 +1515,6 @@ | |||
136 | 1487 | return _mouse_position.y; | 1515 | return _mouse_position.y; |
137 | 1488 | } | 1516 | } |
138 | 1489 | 1517 | ||
139 | 1490 | gboolean | ||
140 | 1491 | Launcher::SingleFingerHoldTimeout (gpointer data) | ||
141 | 1492 | { | ||
142 | 1493 | Launcher* self = NULL; | ||
143 | 1494 | LauncherIcon* launcher_icon = NULL; | ||
144 | 1495 | |||
145 | 1496 | self = (Launcher*) data; | ||
146 | 1497 | launcher_icon = self->MouseIconIntersection (self->GetMouseX (), | ||
147 | 1498 | self->GetMouseY ()); | ||
148 | 1499 | if (launcher_icon) | ||
149 | 1500 | launcher_icon->OpenQuicklist (); | ||
150 | 1501 | |||
151 | 1502 | return false; | ||
152 | 1503 | } | ||
153 | 1504 | |||
154 | 1505 | gboolean Launcher::DrawLauncherTimeout (gpointer data) | 1518 | gboolean Launcher::DrawLauncherTimeout (gpointer data) |
155 | 1506 | { | 1519 | { |
156 | 1507 | Launcher *self = (Launcher*) data; | 1520 | Launcher *self = (Launcher*) data; |
157 | @@ -1542,7 +1555,7 @@ | |||
158 | 1542 | if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ()) | 1555 | if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ()) |
159 | 1543 | return false; | 1556 | return false; |
160 | 1544 | 1557 | ||
162 | 1545 | if (CompRegion (window->serverInputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height))) | 1558 | if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height))) |
163 | 1546 | return true; | 1559 | return true; |
164 | 1547 | 1560 | ||
165 | 1548 | return false; | 1561 | return false; |
166 | @@ -2337,42 +2350,31 @@ | |||
167 | 2337 | guint64 shortcut = arg.icon->GetShortcut (); | 2350 | guint64 shortcut = arg.icon->GetShortcut (); |
168 | 2338 | 2351 | ||
169 | 2339 | /* deal with dynamic labels for places, which can be set via the locale */ | 2352 | /* deal with dynamic labels for places, which can be set via the locale */ |
186 | 2340 | if (shortcut != 0 && !g_ascii_isdigit ((gchar) shortcut)) | 2353 | if (shortcut != 0) |
187 | 2341 | { | 2354 | { |
188 | 2342 | RenderIcon (GfxContext, | 2355 | if (!g_ascii_isdigit ((gchar) shortcut)) |
173 | 2343 | arg, | ||
174 | 2344 | arg.icon->GetSuperkeyLabel ()->GetDeviceTexture (), | ||
175 | 2345 | nux::Color (0xFFFFFFFF), | ||
176 | 2346 | arg.alpha, | ||
177 | 2347 | arg.icon->_xform_coords["Tile"]); | ||
178 | 2348 | } | ||
179 | 2349 | else | ||
180 | 2350 | { | ||
181 | 2351 | /* deal with the hardcoded labels used for the first 10 icons on the launcher */ | ||
182 | 2352 | gchar key = (gchar) shortcut; | ||
183 | 2353 | int index = -1; | ||
184 | 2354 | |||
185 | 2355 | switch (key) | ||
189 | 2356 | { | 2356 | { |
200 | 2357 | case '1': index = 0; break; | 2357 | RenderIcon (GfxContext, |
201 | 2358 | case '2': index = 1; break; | 2358 | arg, |
202 | 2359 | case '3': index = 2; break; | 2359 | arg.icon->GetSuperkeyLabel ()->GetDeviceTexture (), |
203 | 2360 | case '4': index = 3; break; | 2360 | nux::Color (0xFFFFFFFF), |
204 | 2361 | case '5': index = 4; break; | 2361 | arg.alpha, |
205 | 2362 | case '6': index = 5; break; | 2362 | arg.icon->_xform_coords["Tile"]); |
196 | 2363 | case '7': index = 6; break; | ||
197 | 2364 | case '8': index = 7; break; | ||
198 | 2365 | case '9': index = 8; break; | ||
199 | 2366 | case '0': index = 9; break; | ||
206 | 2367 | } | 2363 | } |
209 | 2368 | 2364 | else | |
210 | 2369 | if (index != -1) | 2365 | { |
211 | 2366 | /* deal with the hardcoded labels used for the first 10 icons on the launcher */ | ||
212 | 2367 | gchar *shortcut_str = g_strdup_printf ("%c", (gchar)shortcut); | ||
213 | 2368 | int index = (atoi (shortcut_str) + 9) % 10; // Not -1 as -1 % 10 = -1… | ||
214 | 2369 | g_free (shortcut_str); | ||
215 | 2370 | |||
216 | 2370 | RenderIcon (GfxContext, | 2371 | RenderIcon (GfxContext, |
217 | 2371 | arg, | 2372 | arg, |
218 | 2372 | _superkey_labels[index]->GetDeviceTexture (), | 2373 | _superkey_labels[index]->GetDeviceTexture (), |
219 | 2373 | nux::Color (0xFFFFFFFF), | 2374 | nux::Color (0xFFFFFFFF), |
220 | 2374 | arg.alpha, | 2375 | arg.alpha, |
221 | 2375 | arg.icon->_xform_coords["Tile"]); | 2376 | arg.icon->_xform_coords["Tile"]); |
222 | 2377 | } | ||
223 | 2376 | } | 2378 | } |
224 | 2377 | } | 2379 | } |
225 | 2378 | } | 2380 | } |
226 | @@ -2499,6 +2501,31 @@ | |||
227 | 2499 | EnsureAnimation (); | 2501 | EnsureAnimation (); |
228 | 2500 | } | 2502 | } |
229 | 2501 | 2503 | ||
230 | 2504 | |||
231 | 2505 | gboolean Launcher::StartIconDragTimeout (gpointer data) | ||
232 | 2506 | { | ||
233 | 2507 | Launcher *self = (Launcher*) data; | ||
234 | 2508 | |||
235 | 2509 | // if we are still waiting… | ||
236 | 2510 | if (self->GetActionState () == ACTION_NONE) | ||
237 | 2511 | self->StartIconDragRequest (self->GetMouseX (), self->GetMouseY ()); | ||
238 | 2512 | return false; | ||
239 | 2513 | } | ||
240 | 2514 | |||
241 | 2515 | void Launcher::StartIconDragRequest (int x, int y) | ||
242 | 2516 | { | ||
243 | 2517 | LauncherIcon *drag_icon = MouseIconIntersection ((int) (GetGeometry ().x / 2.0f), y); | ||
244 | 2518 | |||
245 | 2519 | // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying | ||
246 | 2520 | // on an internal Launcher property then | ||
247 | 2521 | if (drag_icon && (_last_button_press == 1) && _model->IconHasSister (drag_icon)) | ||
248 | 2522 | { | ||
249 | 2523 | StartIconDrag (drag_icon); | ||
250 | 2524 | SetActionState (ACTION_DRAG_ICON); | ||
251 | 2525 | UpdateDragWindowPosition (x, y); | ||
252 | 2526 | } | ||
253 | 2527 | } | ||
254 | 2528 | |||
255 | 2502 | void Launcher::StartIconDrag (LauncherIcon *icon) | 2529 | void Launcher::StartIconDrag (LauncherIcon *icon) |
256 | 2503 | { | 2530 | { |
257 | 2504 | if (!icon) | 2531 | if (!icon) |
258 | @@ -2612,8 +2639,6 @@ | |||
259 | 2612 | 2639 | ||
260 | 2613 | if (GetActionState () == ACTION_NONE) | 2640 | if (GetActionState () == ACTION_NONE) |
261 | 2614 | { | 2641 | { |
262 | 2615 | SetTimeStruct (&_times[TIME_DRAG_START]); | ||
263 | 2616 | |||
264 | 2617 | if (nux::Abs (_dnd_delta_y) >= nux::Abs (_dnd_delta_x)) | 2642 | if (nux::Abs (_dnd_delta_y) >= nux::Abs (_dnd_delta_x)) |
265 | 2618 | { | 2643 | { |
266 | 2619 | _launcher_drag_delta += _dnd_delta_y; | 2644 | _launcher_drag_delta += _dnd_delta_y; |
267 | @@ -2621,17 +2646,7 @@ | |||
268 | 2621 | } | 2646 | } |
269 | 2622 | else | 2647 | else |
270 | 2623 | { | 2648 | { |
282 | 2624 | LauncherIcon *drag_icon = MouseIconIntersection ((int) (GetGeometry ().x / 2.0f), y); | 2649 | StartIconDragRequest (x, y); |
272 | 2625 | |||
273 | 2626 | // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying | ||
274 | 2627 | // on an internal Launcher property then | ||
275 | 2628 | if (drag_icon && (_last_button_press == 1) && _model->IconHasSister (drag_icon)) | ||
276 | 2629 | { | ||
277 | 2630 | StartIconDrag (drag_icon); | ||
278 | 2631 | SetActionState (ACTION_DRAG_ICON); | ||
279 | 2632 | UpdateDragWindowPosition (x, y); | ||
280 | 2633 | } | ||
281 | 2634 | |||
283 | 2635 | } | 2650 | } |
284 | 2636 | } | 2651 | } |
285 | 2637 | else if (GetActionState () == ACTION_DRAG_LAUNCHER) | 2652 | else if (GetActionState () == ACTION_DRAG_LAUNCHER) |
286 | @@ -2883,21 +2898,14 @@ | |||
287 | 2883 | LauncherIcon* launcher_icon = 0; | 2898 | LauncherIcon* launcher_icon = 0; |
288 | 2884 | launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); | 2899 | launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); |
289 | 2885 | 2900 | ||
290 | 2886 | // this takes care of the one-finger-hold "event" on a launcher-icon | ||
291 | 2887 | if (_single_finger_hold_handle == 0) | ||
292 | 2888 | { | ||
293 | 2889 | _single_finger_hold_handle = g_timeout_add (SINGLE_FINGER_HOLD_DURATION, | ||
294 | 2890 | &Launcher::SingleFingerHoldTimeout, | ||
295 | 2891 | this); | ||
296 | 2892 | if (_single_finger_hold_timer) | ||
297 | 2893 | g_timer_destroy (_single_finger_hold_timer); | ||
298 | 2894 | |||
299 | 2895 | _single_finger_hold_timer = g_timer_new (); | ||
300 | 2896 | } | ||
301 | 2897 | |||
302 | 2898 | if (launcher_icon) | 2901 | if (launcher_icon) |
303 | 2899 | { | 2902 | { |
304 | 2900 | _icon_mouse_down = launcher_icon; | 2903 | _icon_mouse_down = launcher_icon; |
305 | 2904 | // if MouseUp after the time ended -> it's an icon drag, otherwise, it's starting an app | ||
306 | 2905 | if (_start_dragicon_handle > 0) | ||
307 | 2906 | g_source_remove (_start_dragicon_handle); | ||
308 | 2907 | _start_dragicon_handle = g_timeout_add (START_DRAGICON_DURATION, &Launcher::StartIconDragTimeout, this); | ||
309 | 2908 | |||
310 | 2901 | launcher_icon->MouseDown.emit (nux::GetEventButton (button_flags)); | 2909 | launcher_icon->MouseDown.emit (nux::GetEventButton (button_flags)); |
311 | 2902 | } | 2910 | } |
312 | 2903 | } | 2911 | } |
313 | @@ -2905,59 +2913,20 @@ | |||
314 | 2905 | void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags) | 2913 | void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags) |
315 | 2906 | { | 2914 | { |
316 | 2907 | LauncherIcon* launcher_icon = 0; | 2915 | LauncherIcon* launcher_icon = 0; |
317 | 2916 | |||
318 | 2908 | launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); | 2917 | launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); |
364 | 2909 | 2918 | ||
365 | 2910 | // this takes care of the one-finger-hold "event" on a launcher-icon | 2919 | if (_start_dragicon_handle > 0) |
366 | 2911 | if (_single_finger_hold_timer) | 2920 | g_source_remove (_start_dragicon_handle); |
367 | 2912 | { | 2921 | _start_dragicon_handle = 0; |
323 | 2913 | // user "released" before single-finger-hold threshold | ||
324 | 2914 | if (g_timer_elapsed (_single_finger_hold_timer, NULL) < (float) SINGLE_FINGER_HOLD_DURATION / 1000.0) | ||
325 | 2915 | { | ||
326 | 2916 | |||
327 | 2917 | // remove callback | ||
328 | 2918 | if (_single_finger_hold_handle > 0) | ||
329 | 2919 | { | ||
330 | 2920 | g_source_remove (_single_finger_hold_handle); | ||
331 | 2921 | _single_finger_hold_handle = 0; | ||
332 | 2922 | } | ||
333 | 2923 | } | ||
334 | 2924 | // user "released" after single-finger-hold threshold... | ||
335 | 2925 | else | ||
336 | 2926 | { | ||
337 | 2927 | // remove timer | ||
338 | 2928 | g_timer_destroy (_single_finger_hold_timer); | ||
339 | 2929 | _single_finger_hold_timer = NULL; | ||
340 | 2930 | |||
341 | 2931 | // remove callback | ||
342 | 2932 | if (_single_finger_hold_handle > 0) | ||
343 | 2933 | { | ||
344 | 2934 | g_source_remove (_single_finger_hold_handle); | ||
345 | 2935 | _single_finger_hold_handle = 0; | ||
346 | 2936 | } | ||
347 | 2937 | |||
348 | 2938 | // ... don't start app, just return | ||
349 | 2939 | _icon_mouse_down = 0; | ||
350 | 2940 | return; | ||
351 | 2941 | } | ||
352 | 2942 | |||
353 | 2943 | // remove timer | ||
354 | 2944 | g_timer_destroy (_single_finger_hold_timer); | ||
355 | 2945 | _single_finger_hold_timer = NULL; | ||
356 | 2946 | |||
357 | 2947 | // remove callback | ||
358 | 2948 | if (_single_finger_hold_handle > 0) | ||
359 | 2949 | { | ||
360 | 2950 | g_source_remove (_single_finger_hold_handle); | ||
361 | 2951 | _single_finger_hold_handle = 0; | ||
362 | 2952 | } | ||
363 | 2953 | } | ||
368 | 2954 | 2922 | ||
369 | 2955 | if (_icon_mouse_down && (_icon_mouse_down == launcher_icon)) | 2923 | if (_icon_mouse_down && (_icon_mouse_down == launcher_icon)) |
370 | 2956 | { | 2924 | { |
371 | 2957 | _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags)); | 2925 | _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags)); |
372 | 2958 | 2926 | ||
374 | 2959 | if (GetActionState () == ACTION_NONE) | 2927 | if (GetActionState () == ACTION_NONE) { |
375 | 2960 | _icon_mouse_down->MouseClick.emit (nux::GetEventButton (button_flags)); | 2928 | _icon_mouse_down->MouseClick.emit (nux::GetEventButton (button_flags)); |
376 | 2929 | } | ||
377 | 2961 | } | 2930 | } |
378 | 2962 | 2931 | ||
379 | 2963 | if (launcher_icon && (_icon_mouse_down != launcher_icon)) | 2932 | if (launcher_icon && (_icon_mouse_down != launcher_icon)) |
380 | @@ -3658,7 +3627,7 @@ | |||
381 | 3658 | 3627 | ||
382 | 3659 | if (path) | 3628 | if (path) |
383 | 3660 | { | 3629 | { |
385 | 3661 | launcher_dropped.emit (path, _dnd_hovered_icon); | 3630 | launcher_addrequest.emit (path, _dnd_hovered_icon); |
386 | 3662 | g_free (path); | 3631 | g_free (path); |
387 | 3663 | } | 3632 | } |
388 | 3664 | } | 3633 | } |
389 | @@ -3696,3 +3665,83 @@ | |||
390 | 3696 | else | 3665 | else |
391 | 3697 | return NULL; | 3666 | return NULL; |
392 | 3698 | } | 3667 | } |
393 | 3668 | |||
394 | 3669 | /* dbus handlers */ | ||
395 | 3670 | |||
396 | 3671 | void | ||
397 | 3672 | Launcher::handle_dbus_method_call (GDBusConnection *connection, | ||
398 | 3673 | const gchar *sender, | ||
399 | 3674 | const gchar *object_path, | ||
400 | 3675 | const gchar *interface_name, | ||
401 | 3676 | const gchar *method_name, | ||
402 | 3677 | GVariant *parameters, | ||
403 | 3678 | GDBusMethodInvocation *invocation, | ||
404 | 3679 | gpointer user_data) | ||
405 | 3680 | { | ||
406 | 3681 | |||
407 | 3682 | if (g_strcmp0 (method_name, "AddLauncherItemFromPosition") == 0) | ||
408 | 3683 | { | ||
409 | 3684 | gchar *icon; | ||
410 | 3685 | gchar *title; | ||
411 | 3686 | gint32 icon_x; | ||
412 | 3687 | gint32 icon_y; | ||
413 | 3688 | gint32 icon_size; | ||
414 | 3689 | gchar *desktop_file; | ||
415 | 3690 | gchar *aptdaemon_task; | ||
416 | 3691 | |||
417 | 3692 | g_variant_get (parameters, "(ssiiiss)", &icon, &title, &icon_x, &icon_y, &icon_size, &desktop_file, &aptdaemon_task, NULL); | ||
418 | 3693 | |||
419 | 3694 | Launcher *self = (Launcher*)user_data; | ||
420 | 3695 | self->launcher_addrequest.emit (desktop_file, NULL); | ||
421 | 3696 | |||
422 | 3697 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
423 | 3698 | g_free (icon); | ||
424 | 3699 | g_free (title); | ||
425 | 3700 | g_free (desktop_file); | ||
426 | 3701 | g_free (aptdaemon_task); | ||
427 | 3702 | } | ||
428 | 3703 | |||
429 | 3704 | } | ||
430 | 3705 | |||
431 | 3706 | void | ||
432 | 3707 | Launcher::OnBusAcquired (GDBusConnection *connection, | ||
433 | 3708 | const gchar *name, | ||
434 | 3709 | gpointer user_data) | ||
435 | 3710 | { | ||
436 | 3711 | GDBusNodeInfo *introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); | ||
437 | 3712 | guint registration_id; | ||
438 | 3713 | |||
439 | 3714 | if (!introspection_data) { | ||
440 | 3715 | g_warning ("No introspection data loaded. Won't get dynamic launcher addition."); | ||
441 | 3716 | return; | ||
442 | 3717 | } | ||
443 | 3718 | |||
444 | 3719 | |||
445 | 3720 | |||
446 | 3721 | registration_id = g_dbus_connection_register_object (connection, | ||
447 | 3722 | S_DBUS_PATH, | ||
448 | 3723 | introspection_data->interfaces[0], | ||
449 | 3724 | &interface_vtable, | ||
450 | 3725 | user_data, | ||
451 | 3726 | NULL, | ||
452 | 3727 | NULL); | ||
453 | 3728 | if (!registration_id) | ||
454 | 3729 | g_warning ("Object registration failed. Won't get dynamic launcher addition."); | ||
455 | 3730 | |||
456 | 3731 | } | ||
457 | 3732 | |||
458 | 3733 | void | ||
459 | 3734 | Launcher::OnNameAcquired (GDBusConnection *connection, | ||
460 | 3735 | const gchar *name, | ||
461 | 3736 | gpointer user_data) | ||
462 | 3737 | { | ||
463 | 3738 | g_debug ("Acquired the name %s on the session bus\n", name); | ||
464 | 3739 | } | ||
465 | 3740 | |||
466 | 3741 | void | ||
467 | 3742 | Launcher::OnNameLost (GDBusConnection *connection, | ||
468 | 3743 | const gchar *name, | ||
469 | 3744 | gpointer user_data) | ||
470 | 3745 | { | ||
471 | 3746 | g_debug ("Lost the name %s on the session bus\n", name); | ||
472 | 3747 | } | ||
473 | 3699 | 3748 | ||
474 | === modified file 'src/Launcher.h' | |||
475 | --- src/Launcher.h 2011-03-07 17:02:59 +0000 | |||
476 | +++ src/Launcher.h 2011-03-16 10:54:46 +0000 | |||
477 | @@ -39,7 +39,7 @@ | |||
478 | 39 | #define ANIM_DURATION_LONG 350 | 39 | #define ANIM_DURATION_LONG 350 |
479 | 40 | 40 | ||
480 | 41 | #define SUPER_TAP_DURATION 250 | 41 | #define SUPER_TAP_DURATION 250 |
482 | 42 | #define SINGLE_FINGER_HOLD_DURATION 1000 | 42 | #define START_DRAGICON_DURATION 500 |
483 | 43 | 43 | ||
484 | 44 | #define MAX_SUPERKEY_LABELS 10 | 44 | #define MAX_SUPERKEY_LABELS 10 |
485 | 45 | 45 | ||
486 | @@ -154,8 +154,10 @@ | |||
487 | 154 | 154 | ||
488 | 155 | int GetMouseX (); | 155 | int GetMouseX (); |
489 | 156 | int GetMouseY (); | 156 | int GetMouseY (); |
490 | 157 | |||
491 | 158 | void CheckWindowOverLauncher (); | ||
492 | 157 | 159 | ||
494 | 158 | sigc::signal<void, char *, LauncherIcon *> launcher_dropped; | 160 | sigc::signal<void, char *, LauncherIcon *> launcher_addrequest; |
495 | 159 | sigc::signal<void> selection_change; | 161 | sigc::signal<void> selection_change; |
496 | 160 | protected: | 162 | protected: |
497 | 161 | // Introspectable methods | 163 | // Introspectable methods |
498 | @@ -179,7 +181,6 @@ | |||
499 | 179 | { | 181 | { |
500 | 180 | TIME_ENTER, | 182 | TIME_ENTER, |
501 | 181 | TIME_LEAVE, | 183 | TIME_LEAVE, |
502 | 182 | TIME_DRAG_START, | ||
503 | 183 | TIME_DRAG_END, | 184 | TIME_DRAG_END, |
504 | 184 | TIME_DRAG_THRESHOLD, | 185 | TIME_DRAG_THRESHOLD, |
505 | 185 | TIME_AUTOHIDE, | 186 | TIME_AUTOHIDE, |
506 | @@ -223,7 +224,7 @@ | |||
507 | 223 | static gboolean DrawLauncherTimeout (gpointer data); | 224 | static gboolean DrawLauncherTimeout (gpointer data); |
508 | 224 | static gboolean StrutHack (gpointer data); | 225 | static gboolean StrutHack (gpointer data); |
509 | 225 | static gboolean MoveFocusToKeyNavModeTimeout (gpointer data); | 226 | static gboolean MoveFocusToKeyNavModeTimeout (gpointer data); |
511 | 226 | static gboolean SingleFingerHoldTimeout (gpointer data); | 227 | static gboolean StartIconDragTimeout (gpointer data); |
512 | 227 | 228 | ||
513 | 228 | void SetMousePosition (int x, int y); | 229 | void SetMousePosition (int x, int y); |
514 | 229 | 230 | ||
515 | @@ -252,7 +253,6 @@ | |||
516 | 252 | static gboolean OnScrollTimeout (gpointer data); | 253 | static gboolean OnScrollTimeout (gpointer data); |
517 | 253 | static gboolean OnUpdateDragManagerTimeout (gpointer data); | 254 | static gboolean OnUpdateDragManagerTimeout (gpointer data); |
518 | 254 | 255 | ||
519 | 255 | void CheckWindowOverLauncher (); | ||
520 | 256 | bool CheckIntersectWindow (CompWindow *window); | 256 | bool CheckIntersectWindow (CompWindow *window); |
521 | 257 | 257 | ||
522 | 258 | float DnDStartProgress (struct timespec const ¤t); | 258 | float DnDStartProgress (struct timespec const ¤t); |
523 | @@ -343,6 +343,7 @@ | |||
524 | 343 | void MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags); | 343 | void MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags); |
525 | 344 | void MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags); | 344 | void MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags); |
526 | 345 | 345 | ||
527 | 346 | void StartIconDragRequest (int x, int y); | ||
528 | 346 | void StartIconDrag (LauncherIcon *icon); | 347 | void StartIconDrag (LauncherIcon *icon); |
529 | 347 | void EndIconDrag (); | 348 | void EndIconDrag (); |
530 | 348 | void UpdateDragWindowPosition (int x, int y); | 349 | void UpdateDragWindowPosition (int x, int y); |
531 | @@ -461,8 +462,7 @@ | |||
532 | 461 | guint _autoscroll_handle; | 462 | guint _autoscroll_handle; |
533 | 462 | guint _focus_keynav_handle; | 463 | guint _focus_keynav_handle; |
534 | 463 | guint _redraw_handle; | 464 | guint _redraw_handle; |
537 | 464 | guint _single_finger_hold_handle; | 465 | guint _start_dragicon_handle; |
536 | 465 | GTimer* _single_finger_hold_timer; | ||
538 | 466 | 466 | ||
539 | 467 | nux::Point2 _mouse_position; | 467 | nux::Point2 _mouse_position; |
540 | 468 | nux::Point2 _trigger_mouse_position; | 468 | nux::Point2 _trigger_mouse_position; |
541 | @@ -483,6 +483,23 @@ | |||
542 | 483 | LauncherIcon *_dnd_hovered_icon; | 483 | LauncherIcon *_dnd_hovered_icon; |
543 | 484 | 484 | ||
544 | 485 | Atom _selection_atom; | 485 | Atom _selection_atom; |
545 | 486 | |||
546 | 487 | /* gdbus */ | ||
547 | 488 | guint _dbus_owner; | ||
548 | 489 | static const gchar introspection_xml[]; | ||
549 | 490 | static GDBusInterfaceVTable interface_vtable; | ||
550 | 491 | |||
551 | 492 | static void OnBusAcquired (GDBusConnection *connection, const gchar *name, gpointer user_data); | ||
552 | 493 | static void OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer user_data); | ||
553 | 494 | static void OnNameLost (GDBusConnection *connection, const gchar *name, gpointer user_data); | ||
554 | 495 | static void handle_dbus_method_call (GDBusConnection *connection, | ||
555 | 496 | const gchar *sender, | ||
556 | 497 | const gchar *object_path, | ||
557 | 498 | const gchar *interface_name, | ||
558 | 499 | const gchar *method_name, | ||
559 | 500 | GVariant *parameters, | ||
560 | 501 | GDBusMethodInvocation *invocation, | ||
561 | 502 | gpointer user_data); | ||
562 | 486 | 503 | ||
563 | 487 | struct timespec _times[TIME_LAST]; | 504 | struct timespec _times[TIME_LAST]; |
564 | 488 | }; | 505 | }; |
565 | 489 | 506 | ||
566 | === modified file 'src/LauncherController.cpp' | |||
567 | --- src/LauncherController.cpp 2011-02-28 15:51:59 +0000 | |||
568 | +++ src/LauncherController.cpp 2011-03-16 10:54:46 +0000 | |||
569 | @@ -38,7 +38,7 @@ | |||
570 | 38 | _sort_priority = 0; | 38 | _sort_priority = 0; |
571 | 39 | 39 | ||
572 | 40 | _launcher->SetModel (_model); | 40 | _launcher->SetModel (_model); |
574 | 41 | _launcher->launcher_dropped.connect (sigc::mem_fun (this, &LauncherController::OnLauncherDropped)); | 41 | _launcher->launcher_addrequest.connect (sigc::mem_fun (this, &LauncherController::OnLauncherAddRequest)); |
575 | 42 | _favorite_store = FavoriteStore::GetDefault (); | 42 | _favorite_store = FavoriteStore::GetDefault (); |
576 | 43 | 43 | ||
577 | 44 | _place_section = new PlaceLauncherSection (_launcher); | 44 | _place_section = new PlaceLauncherSection (_launcher); |
578 | @@ -69,7 +69,7 @@ | |||
579 | 69 | } | 69 | } |
580 | 70 | 70 | ||
581 | 71 | void | 71 | void |
583 | 72 | LauncherController::OnLauncherDropped (char *path, LauncherIcon *before) | 72 | LauncherController::OnLauncherAddRequest (char *path, LauncherIcon *before) |
584 | 73 | { | 73 | { |
585 | 74 | std::list<BamfLauncherIcon *> launchers; | 74 | std::list<BamfLauncherIcon *> launchers; |
586 | 75 | std::list<BamfLauncherIcon *>::iterator it; | 75 | std::list<BamfLauncherIcon *>::iterator it; |
587 | @@ -85,7 +85,8 @@ | |||
588 | 85 | if (result) | 85 | if (result) |
589 | 86 | { | 86 | { |
590 | 87 | RegisterIcon (result); | 87 | RegisterIcon (result); |
592 | 88 | _model->ReorderBefore (result, before, false); | 88 | if (before) |
593 | 89 | _model->ReorderBefore (result, before, false); | ||
594 | 89 | } | 90 | } |
595 | 90 | } | 91 | } |
596 | 91 | 92 | ||
597 | 92 | 93 | ||
598 | === modified file 'src/LauncherController.h' | |||
599 | --- src/LauncherController.h 2011-02-15 22:51:36 +0000 | |||
600 | +++ src/LauncherController.h 2011-03-16 10:54:46 +0000 | |||
601 | @@ -69,7 +69,7 @@ | |||
602 | 69 | 69 | ||
603 | 70 | void OnIconAdded (LauncherIcon *icon); | 70 | void OnIconAdded (LauncherIcon *icon); |
604 | 71 | 71 | ||
606 | 72 | void OnLauncherDropped (char *path, LauncherIcon *before); | 72 | void OnLauncherAddRequest (char *path, LauncherIcon *before); |
607 | 73 | 73 | ||
608 | 74 | void OnLauncerEntryRemoteAdded (LauncherEntryRemote *entry); | 74 | void OnLauncerEntryRemoteAdded (LauncherEntryRemote *entry); |
609 | 75 | void OnLauncerEntryRemoteRemoved (LauncherEntryRemote *entry); | 75 | void OnLauncerEntryRemoteRemoved (LauncherEntryRemote *entry); |
610 | 76 | 76 | ||
611 | === modified file 'src/unityshell.cpp' | |||
612 | --- src/unityshell.cpp 2011-03-10 15:39:00 +0000 | |||
613 | +++ src/unityshell.cpp 2011-03-16 10:54:46 +0000 | |||
614 | @@ -210,6 +210,23 @@ | |||
615 | 210 | } | 210 | } |
616 | 211 | } | 211 | } |
617 | 212 | 212 | ||
618 | 213 | void | ||
619 | 214 | UnityScreen::handleCompizEvent (const char *plugin, | ||
620 | 215 | const char *event, | ||
621 | 216 | CompOption::Vector &option) | ||
622 | 217 | { | ||
623 | 218 | if (strcmp (event, "end_viewport_switch") == 0) | ||
624 | 219 | { | ||
625 | 220 | // compute again the list of all window on the new viewport | ||
626 | 221 | // to decide if we should or not hide the launcher | ||
627 | 222 | launcher->CheckWindowOverLauncher (); | ||
628 | 223 | } | ||
629 | 224 | |||
630 | 225 | |||
631 | 226 | screen->handleCompizEvent (plugin, event, option); | ||
632 | 227 | |||
633 | 228 | } | ||
634 | 229 | |||
635 | 213 | bool | 230 | bool |
636 | 214 | UnityScreen::showLauncherKeyInitiate (CompAction *action, | 231 | UnityScreen::showLauncherKeyInitiate (CompAction *action, |
637 | 215 | CompAction::State state, | 232 | CompAction::State state, |
638 | 216 | 233 | ||
639 | === modified file 'src/unityshell.h' | |||
640 | --- src/unityshell.h 2011-03-09 19:12:37 +0000 | |||
641 | +++ src/unityshell.h 2011-03-16 10:54:46 +0000 | |||
642 | @@ -95,6 +95,9 @@ | |||
643 | 95 | 95 | ||
644 | 96 | /* handle X11 events */ | 96 | /* handle X11 events */ |
645 | 97 | void handleEvent (XEvent *); | 97 | void handleEvent (XEvent *); |
646 | 98 | void handleCompizEvent (const char *plugin, | ||
647 | 99 | const char *event, | ||
648 | 100 | CompOption::Vector &option); | ||
649 | 98 | 101 | ||
650 | 99 | bool | 102 | bool |
651 | 100 | showLauncherKeyInitiate (CompAction *action, CompAction::State state, | 103 | showLauncherKeyInitiate (CompAction *action, CompAction::State state, |
This branch disables the Press&Hold activation for the Quicklist.