Merge lp:~didrocks/unity/launcher-bug-fix-fest into lp:unity

Proposed by Didier Roche-Tolomelli
Status: Merged
Merged at revision: 1032
Proposed branch: lp:~didrocks/unity/launcher-bug-fix-fest
Merge into: lp:unity
Diff against target: 818 lines (+281/-128)
14 files modified
src/BamfLauncherIcon.cpp (+0/-9)
src/BamfLauncherIcon.h (+0/-1)
src/Launcher.cpp (+59/-63)
src/Launcher.h (+6/-3)
src/LauncherHoverMachine.cpp (+119/-0)
src/LauncherHoverMachine.h (+64/-0)
src/LauncherIcon.cpp (+22/-2)
src/LauncherIcon.h (+2/-1)
src/PlaceEntryRemote.cpp (+1/-1)
src/PlaceLauncherIcon.cpp (+0/-11)
src/PlaceLauncherIcon.h (+0/-1)
src/SimpleLauncherIcon.cpp (+0/-3)
src/TrashLauncherIcon.cpp (+7/-30)
src/TrashLauncherIcon.h (+1/-3)
To merge this branch: bzr merge lp:~didrocks/unity/launcher-bug-fix-fest
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+55182@code.launchpad.net

Description of the change

This branch intends to:
- don't show empty shortcut for places not defining a label (LP: #742985)
- use regular and not tweaked quicklist system for trashlaunchericon (LP:
  #741793)
- clean the activation, QL, opennewinstance stack, as it triggered a lot of bugs
  and is more straightforward now (LP: #744196)
- only open quicklist if there is one to open (LP: #741772)
- add an HoverMachine and ensure we don't hover when tapping super (LP: #744344)

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

+1 Awesome work didier!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/BamfLauncherIcon.cpp'
--- src/BamfLauncherIcon.cpp 2011-03-25 17:45:08 +0000
+++ src/BamfLauncherIcon.cpp 2011-03-28 16:21:41 +0000
@@ -434,15 +434,6 @@
434}434}
435435
436void436void
437BamfLauncherIcon::OnMouseClick (int button)
438{
439 if (button == 1)
440 ActivateLauncherIcon ();
441 else if (button == 2)
442 OpenInstanceLauncherIcon ();
443}
444
445void
446BamfLauncherIcon::OnClosed (BamfView *view, gpointer data)437BamfLauncherIcon::OnClosed (BamfView *view, gpointer data)
447{438{
448 BamfLauncherIcon *self = (BamfLauncherIcon *) data;439 BamfLauncherIcon *self = (BamfLauncherIcon *) data;
449440
=== modified file 'src/BamfLauncherIcon.h'
--- src/BamfLauncherIcon.h 2011-03-24 01:34:07 +0000
+++ src/BamfLauncherIcon.h 2011-03-28 16:21:41 +0000
@@ -46,7 +46,6 @@
46 void ActivateLauncherIcon ();46 void ActivateLauncherIcon ();
4747
48protected:48protected:
49 void OnMouseClick (int button);
50 std::list<DbusmenuMenuitem *> GetMenus ();49 std::list<DbusmenuMenuitem *> GetMenus ();
5150
52 void UpdateIconGeometries (nux::Point3 center);51 void UpdateIconGeometries (nux::Point3 center);
5352
=== modified file 'src/Launcher.cpp'
--- src/Launcher.cpp 2011-03-28 16:03:00 +0000
+++ src/Launcher.cpp 2011-03-28 16:21:41 +0000
@@ -229,6 +229,9 @@
229 229
230 _hide_machine = new LauncherHideMachine ();230 _hide_machine = new LauncherHideMachine ();
231 _hide_machine->should_hide_changed.connect (sigc::mem_fun (this, &Launcher::SetHidden));231 _hide_machine->should_hide_changed.connect (sigc::mem_fun (this, &Launcher::SetHidden));
232
233 _hover_machine = new LauncherHoverMachine ();
234 _hover_machine->should_hover_changed.connect (sigc::mem_fun (this, &Launcher::SetHover));
232235
233 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);236 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
234237
@@ -537,11 +540,11 @@
537Launcher::startKeyNavMode ()540Launcher::startKeyNavMode ()
538{541{
539 _hide_machine->SetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE, true);542 _hide_machine->SetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE, true);
543 _hover_machine->SetQuirk (LauncherHoverMachine::KEY_NAV_ACTIVE, true);
540 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);544 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
541 545
542 GrabKeyboard ();546 GrabKeyboard ();
543 GrabPointer ();547 GrabPointer ();
544 EnsureHoverState ();
545 548
546 // FIXME: long term solution is to rewrite the keynav handle549 // FIXME: long term solution is to rewrite the keynav handle
547 if (_focus_keynav_handle > 0)550 if (_focus_keynav_handle > 0)
@@ -597,11 +600,11 @@
597 UnGrabKeyboard ();600 UnGrabKeyboard ();
598 UnGrabPointer ();601 UnGrabPointer ();
599 _hide_machine->SetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE, false);602 _hide_machine->SetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE, false);
603 _hover_machine->SetQuirk (LauncherHoverMachine::KEY_NAV_ACTIVE, false);
600604
601 _current_icon_index = -1;605 _current_icon_index = -1;
602 _last_icon_index = _current_icon_index;606 _last_icon_index = _current_icon_index;
603 QueueDraw ();607 QueueDraw ();
604 EnsureHoverState ();
605 ubus_server_send_message (ubus_server_get_default (),608 ubus_server_send_message (ubus_server_get_default (),
606 UBUS_LAUNCHER_END_KEY_NAV,609 UBUS_LAUNCHER_END_KEY_NAV,
607 NULL);610 NULL);
@@ -637,6 +640,18 @@
637 EnsureScrollTimer ();640 EnsureScrollTimer ();
638}641}
639642
643void Launcher::SetStateMouseOverLauncher (bool over_launcher)
644{
645 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER, over_launcher);
646 _hover_machine->SetQuirk (LauncherHoverMachine::MOUSE_OVER_LAUNCHER, over_launcher);
647}
648
649void Launcher::SetStateMouseOverBFB (bool over_bfb)
650{
651 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_BFB, over_bfb);
652 _hover_machine->SetQuirk (LauncherHoverMachine::MOUSE_OVER_BFB, over_bfb);
653}
654
640bool Launcher::MouseBeyondDragThreshold ()655bool Launcher::MouseBeyondDragThreshold ()
641{656{
642 if (GetActionState () == ACTION_DRAG_ICON)657 if (GetActionState () == ACTION_DRAG_ICON)
@@ -1379,9 +1394,19 @@
1379gboolean Launcher::TapOnSuper ()1394gboolean Launcher::TapOnSuper ()
1380{1395{
1381 struct timespec current;1396 struct timespec current;
1382 clock_gettime (CLOCK_MONOTONIC, &current); 1397 bool tap_on_super;
1398 bool shortcuts_shown = false;
1399 clock_gettime (CLOCK_MONOTONIC, &current);
1383 1400
1384 return (TimeDelta (&current, &_times[TIME_TAP_SUPER]) < SUPER_TAP_DURATION);1401 tap_on_super = (TimeDelta (&current, &_times[TIME_TAP_SUPER]) < SUPER_TAP_DURATION);
1402
1403 if (_hide_machine->GetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN))
1404 shortcuts_shown = !tap_on_super;
1405
1406 _hover_machine->SetQuirk (LauncherHoverMachine::SHOTCUT_KEYS_VISIBLE, shortcuts_shown);
1407
1408 return tap_on_super;
1409
1385}1410}
13861411
1387/* Launcher Show/Hide logic */1412/* Launcher Show/Hide logic */
@@ -1391,7 +1416,6 @@
1391 _hide_machine->SetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN, true);1416 _hide_machine->SetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN, true);
1392 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);1417 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
1393 QueueDraw ();1418 QueueDraw ();
1394 EnsureHoverState ();
1395 SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION);1419 SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION);
1396 if (_redraw_handle > 0)1420 if (_redraw_handle > 0)
1397 g_source_remove (_redraw_handle);1421 g_source_remove (_redraw_handle);
@@ -1402,8 +1426,8 @@
1402{1426{
1403 1427
1404 _hide_machine->SetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN, false);1428 _hide_machine->SetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN, false);
1429 _hover_machine->SetQuirk (LauncherHoverMachine::SHOTCUT_KEYS_VISIBLE, false);
1405 QueueDraw ();1430 QueueDraw ();
1406 EnsureHoverState ();
14071431
1408 // it's a tap on super1432 // it's a tap on super
1409 if (TapOnSuper ())1433 if (TapOnSuper ())
@@ -1416,7 +1440,7 @@
1416 self->_hide_machine->SetQuirk (LauncherHideMachine::PLACES_VISIBLE, true);1440 self->_hide_machine->SetQuirk (LauncherHideMachine::PLACES_VISIBLE, true);
1417 1441
1418 // hack around issue in nux where leave events dont always come after a grab1442 // hack around issue in nux where leave events dont always come after a grab
1419 self->_hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_BFB, false);1443 self->SetStateMouseOverBFB (false);
1420}1444}
14211445
1422void Launcher::OnPlaceViewHidden (GVariant *data, void *val)1446void Launcher::OnPlaceViewHidden (GVariant *data, void *val)
@@ -1465,9 +1489,7 @@
1465 {1489 {
1466 if (g_str_equal ("hovered", prop_key))1490 if (g_str_equal ("hovered", prop_key))
1467 {1491 {
1468 self->_hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_BFB, g_variant_get_boolean (prop_value));1492 self->SetStateMouseOverBFB (g_variant_get_boolean (prop_value));
1469
1470 self->EnsureHoverState ();
1471 self->EnsureScrollTimer (); 1493 self->EnsureScrollTimer ();
1472 }1494 }
1473 }1495 }
@@ -1490,6 +1512,8 @@
14901512
1491 _hidden = hidden;1513 _hidden = hidden;
1492 _hide_machine->SetQuirk (LauncherHideMachine::LAUNCHER_HIDDEN, hidden);1514 _hide_machine->SetQuirk (LauncherHideMachine::LAUNCHER_HIDDEN, hidden);
1515 _hover_machine->SetQuirk (LauncherHoverMachine::LAUNCHER_HIDDEN, hidden);
1516
1493 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);1517 _hide_machine->SetQuirk (LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
1494 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, false);1518 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, false);
1495 1519
@@ -1756,6 +1780,8 @@
1756 1780
1757 _launcher_action_state = actionstate;1781 _launcher_action_state = actionstate;
1758 1782
1783 _hover_machine->SetQuirk (LauncherHoverMachine::LAUNCHER_IN_ACTION, (actionstate != ACTION_NONE));
1784
1759 if (_hide_machine->GetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE))1785 if (_hide_machine->GetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE))
1760 exitKeyNavMode ();1786 exitKeyNavMode ();
1761}1787}
@@ -1766,40 +1792,24 @@
1766 return _launcher_action_state;1792 return _launcher_action_state;
1767}1793}
17681794
1769void1795void Launcher::SetHover (bool hovered)
1770Launcher::EnsureHoverState ()
1771{1796{
1772 if (_hide_machine->GetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER) || _hide_machine->GetQuirk (LauncherHideMachine::MOUSE_OVER_BFB) || 1797
1773 _hide_machine->GetQuirk (LauncherHideMachine::TRIGGER_BUTTON_DOWN) || _hide_machine->GetQuirk (LauncherHideMachine::KEY_NAV_ACTIVE) ||1798 if (hovered == _hovered)
1774 QuicklistManager::Default ()->Current() || GetActionState () != ACTION_NONE)1799 return;
1775 {1800
1776 SetHover ();1801 _hovered = hovered;
1777 }
1778 else
1779 {
1780 UnsetHover ();
1781 }
1782}
17831802
1784void Launcher::SetHover ()
1785{
1786 if (_hovered)1803 if (_hovered)
1787 return;1804 {
17881805 _enter_y = (int) _mouse_position.y;
1789 _enter_y = (int) _mouse_position.y;1806 SetTimeStruct (&_times[TIME_ENTER], &_times[TIME_LEAVE], ANIM_DURATION);
17901807 }
1791 _hovered = true;1808 else
1792 SetTimeStruct (&_times[TIME_ENTER], &_times[TIME_LEAVE], ANIM_DURATION);1809 {
1793 EnsureAnimation ();1810 SetTimeStruct (&_times[TIME_LEAVE], &_times[TIME_ENTER], ANIM_DURATION);
1794}1811 }
17951812
1796void Launcher::UnsetHover ()
1797{
1798 if (!_hovered)
1799 return;
1800
1801 _hovered = false;
1802 SetTimeStruct (&_times[TIME_LEAVE], &_times[TIME_ENTER], ANIM_DURATION);
1803 EnsureAnimation ();1813 EnsureAnimation ();
1804}1814}
18051815
@@ -2631,12 +2641,6 @@
2631{2641{
2632 SetMousePosition (x, y);2642 SetMousePosition (x, y);
2633 nux::Geometry geo = GetGeometry ();2643 nux::Geometry geo = GetGeometry ();
2634
2635 if (GetActionState () != ACTION_NONE && !geo.IsInside(nux::Point(x, y)))
2636 {
2637 // we are no longer hovered
2638 EnsureHoverState ();
2639 }
2640 2644
2641 MouseUpLogic (x, y, button_flags, key_flags);2645 MouseUpLogic (x, y, button_flags, key_flags);
2642 2646
@@ -2649,7 +2653,6 @@
2649 _dnd_delta_x = 0;2653 _dnd_delta_x = 0;
2650 _dnd_delta_y = 0;2654 _dnd_delta_y = 0;
2651 _last_button_press = 0;2655 _last_button_press = 0;
2652 EnsureHoverState ();
2653 EnsureAnimation ();2656 EnsureAnimation ();
2654}2657}
26552658
@@ -2705,9 +2708,7 @@
2705 return;2708 return;
2706 2709
2707 SetMousePosition (x, y);2710 SetMousePosition (x, y);
2708 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER, true);2711 SetStateMouseOverLauncher (true);
2709
2710 EnsureHoverState ();
27112712
2712 EventLogic ();2713 EventLogic ();
2713 EnsureAnimation ();2714 EnsureAnimation ();
@@ -2721,10 +2722,7 @@
2721 return;2722 return;
27222723
2723 SetMousePosition (x, y);2724 SetMousePosition (x, y);
2724 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER, false);2725 SetStateMouseOverLauncher (false);
2725
2726 if (GetActionState () == ACTION_NONE)
2727 EnsureHoverState ();
27282726
2729 EventLogic ();2727 EventLogic ();
2730 EnsureAnimation ();2728 EnsureAnimation ();
@@ -2866,8 +2864,8 @@
2866 it = _model->at (_current_icon_index);2864 it = _model->at (_current_icon_index);
2867 if (it != (LauncherModel::iterator)NULL)2865 if (it != (LauncherModel::iterator)NULL)
2868 {2866 {
2869 (*it)->OpenQuicklist (true);2867 if ((*it)->OpenQuicklist (true))
2870 leaveKeyNavMode ();2868 leaveKeyNavMode ();
2871 }2869 }
2872 break;2870 break;
28732871
@@ -2901,17 +2899,17 @@
2901void Launcher::RecvQuicklistOpened (QuicklistView *quicklist)2899void Launcher::RecvQuicklistOpened (QuicklistView *quicklist)
2902{2900{
2903 _hide_machine->SetQuirk (LauncherHideMachine::QUICKLIST_OPEN, true);2901 _hide_machine->SetQuirk (LauncherHideMachine::QUICKLIST_OPEN, true);
2902 _hover_machine->SetQuirk (LauncherHoverMachine::QUICKLIST_OPEN, true);
2904 EventLogic ();2903 EventLogic ();
2905 EnsureHoverState ();
2906 EnsureAnimation ();2904 EnsureAnimation ();
2907}2905}
29082906
2909void Launcher::RecvQuicklistClosed (QuicklistView *quicklist)2907void Launcher::RecvQuicklistClosed (QuicklistView *quicklist)
2910{2908{
2911 _hide_machine->SetQuirk (LauncherHideMachine::QUICKLIST_OPEN, false);2909 _hide_machine->SetQuirk (LauncherHideMachine::QUICKLIST_OPEN, false);
2910 _hover_machine->SetQuirk (LauncherHoverMachine::QUICKLIST_OPEN, false);
29122911
2913 EventLogic ();2912 EventLogic ();
2914 EnsureHoverState ();
2915 EnsureAnimation ();2913 EnsureAnimation ();
2916}2914}
29172915
@@ -3456,7 +3454,7 @@
3456void 3454void
3457Launcher::ProcessDndLeave ()3455Launcher::ProcessDndLeave ()
3458{3456{
3459 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER, false);3457 SetStateMouseOverLauncher (false);
3460 _drag_edge_touching = false;3458 _drag_edge_touching = false;
34613459
3462 SetActionState (ACTION_NONE);3460 SetActionState (ACTION_NONE);
@@ -3494,7 +3492,6 @@
3494 _steal_drag = false;3492 _steal_drag = false;
3495 _dnd_hovered_icon = 0;3493 _dnd_hovered_icon = 0;
3496 3494
3497 EnsureHoverState ();
3498}3495}
34993496
3500std::list<char *>3497std::list<char *>
@@ -3556,7 +3553,7 @@
35563553
3557 // only set hover once we know our first x/y3554 // only set hover once we know our first x/y
3558 SetActionState (ACTION_DRAG_EXTERNAL);3555 SetActionState (ACTION_DRAG_EXTERNAL);
3559 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_LAUNCHER, true);3556 SetStateMouseOverLauncher (true);
3560 3557
3561 LauncherModel::iterator it;3558 LauncherModel::iterator it;
3562 for (it = _model->begin (); it != _model->end () && !_steal_drag; it++)3559 for (it = _model->begin (); it != _model->end () && !_steal_drag; it++)
@@ -3567,7 +3564,6 @@
3567 (*it)->SetQuirk (LauncherIcon::QUIRK_DROP_DIM, true);3564 (*it)->SetQuirk (LauncherIcon::QUIRK_DROP_DIM, true);
3568 }3565 }
3569 3566
3570 EnsureHoverState ();
3571 }3567 }
3572 3568
3573 g_free (uri_list_const);3569 g_free (uri_list_const);
35743570
=== modified file 'src/Launcher.h'
--- src/Launcher.h 2011-03-23 20:33:39 +0000
+++ src/Launcher.h 2011-03-28 16:21:41 +0000
@@ -31,6 +31,7 @@
31#include "LauncherIcon.h"31#include "LauncherIcon.h"
32#include "LauncherDragWindow.h"32#include "LauncherDragWindow.h"
33#include "LauncherHideMachine.h"33#include "LauncherHideMachine.h"
34#include "LauncherHoverMachine.h"
34#include "NuxGraphics/IOpenGLAsmShader.h"35#include "NuxGraphics/IOpenGLAsmShader.h"
35#include "Nux/TimerProc.h"36#include "Nux/TimerProc.h"
36#include "PluginAdapter.h"37#include "PluginAdapter.h"
@@ -240,6 +241,9 @@
240241
241 void SetMousePosition (int x, int y);242 void SetMousePosition (int x, int y);
242 243
244 void SetStateMouseOverLauncher (bool over_launcher);
245 void SetStateMouseOverBFB (bool over_bfb);
246
243 bool MouseBeyondDragThreshold ();247 bool MouseBeyondDragThreshold ();
244248
245 void OnDragWindowAnimCompleted ();249 void OnDragWindowAnimCompleted ();
@@ -250,7 +254,6 @@
250 void SetActionState (LauncherActionState actionstate);254 void SetActionState (LauncherActionState actionstate);
251 LauncherActionState GetActionState(); 255 LauncherActionState GetActionState();
252256
253 void EnsureHoverState ();
254 void EnsureAnimation ();257 void EnsureAnimation ();
255 void EnsureScrollTimer ();258 void EnsureScrollTimer ();
256 259
@@ -284,8 +287,7 @@
284 float IconDropDimValue (LauncherIcon *icon, struct timespec const &current);287 float IconDropDimValue (LauncherIcon *icon, struct timespec const &current);
285 float IconCenterTransitionProgress (LauncherIcon *icon, struct timespec const &current);288 float IconCenterTransitionProgress (LauncherIcon *icon, struct timespec const &current);
286289
287 void SetHover ();290 void SetHover (bool hovered);
288 void UnsetHover ();
289 void SetHidden (bool hidden);291 void SetHidden (bool hidden);
290292
291 void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec const &current);293 void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec const &current);
@@ -469,6 +471,7 @@
469 LauncherModel* _model;471 LauncherModel* _model;
470 LauncherDragWindow* _drag_window;472 LauncherDragWindow* _drag_window;
471 LauncherHideMachine *_hide_machine;473 LauncherHideMachine *_hide_machine;
474 LauncherHoverMachine *_hover_machine;
472 CompScreen* _screen;475 CompScreen* _screen;
473 476
474 std::list<char *> _drag_data;477 std::list<char *> _drag_data;
475478
=== added file 'src/LauncherHoverMachine.cpp'
--- src/LauncherHoverMachine.cpp 1970-01-01 00:00:00 +0000
+++ src/LauncherHoverMachine.cpp 2011-03-28 16:21:41 +0000
@@ -0,0 +1,119 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2011 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Didier Roche <didrocks@ubuntu.com>
18 */
19
20#include "LauncherHoverMachine.h"
21
22LauncherHoverMachine::LauncherHoverMachine ()
23{
24 _quirks = DEFAULT;
25 _should_hover = false;
26 _pending_should_hover = false; // avoid building a struct in the callback
27 _hover_changed_emit_handle = 0;
28
29}
30
31LauncherHoverMachine::~LauncherHoverMachine ()
32{
33 if (_hover_changed_emit_handle)
34 {
35 g_source_remove (_hover_changed_emit_handle);
36 _hover_changed_emit_handle = 0;
37 }
38}
39
40/* == Quick Quirk Reference : please keep up to date ==
41 DEFAULT = 0,
42 LAUNCHER_HIDDEN = 1 << 0, 1
43 MOUSE_OVER_LAUNCHER = 1 << 1, 2
44 MOUSE_OVER_BFB = 1 << 2, 4
45 SHOTCUT_KEYS_VISIBLE = 1 << 3, 8
46 QUICKLIST_OPEN = 1 << 4, 16
47 KEY_NAV_ACTIVE = 1 << 5, 32
48 LAUNCHER_IN_ACTION = 1 << 6, 64
49*/
50
51void
52LauncherHoverMachine::EnsureHoverState ()
53{
54 bool should_hover;
55
56 if (GetQuirk (LAUNCHER_HIDDEN))
57 {
58 SetShouldHover (false);
59 return;
60 }
61
62 if (GetQuirk ((HoverQuirk) (MOUSE_OVER_LAUNCHER | MOUSE_OVER_BFB |
63 SHOTCUT_KEYS_VISIBLE | KEY_NAV_ACTIVE |
64 QUICKLIST_OPEN | LAUNCHER_IN_ACTION)))
65 should_hover = true;
66 else
67 should_hover = false;
68
69
70 SetShouldHover (should_hover);
71}
72
73void
74LauncherHoverMachine::SetShouldHover (bool value)
75{
76 if (_hover_changed_emit_handle)
77 g_source_remove (_hover_changed_emit_handle);
78
79 _pending_should_hover = value;
80 _hover_changed_emit_handle = g_timeout_add (0, &EmitShouldHoverChanged, this);
81}
82
83gboolean
84LauncherHoverMachine::EmitShouldHoverChanged (gpointer data)
85{
86 LauncherHoverMachine *self = static_cast<LauncherHoverMachine *> (data);
87
88 if (self->_should_hover == self->_pending_should_hover)
89 return false;
90
91 self->_should_hover = self->_pending_should_hover;
92 self->_hover_changed_emit_handle = 0;
93
94 self->should_hover_changed.emit (self->_should_hover);
95 return false;
96}
97
98void
99LauncherHoverMachine::SetQuirk (LauncherHoverMachine::HoverQuirk quirk, bool active)
100{
101 if (GetQuirk (quirk) == active)
102 return;
103
104 if (active)
105 _quirks = (HoverQuirk) (_quirks | quirk);
106 else
107 _quirks = (HoverQuirk) (_quirks & ~quirk);
108
109 EnsureHoverState ();
110}
111
112bool
113LauncherHoverMachine::GetQuirk (LauncherHoverMachine::HoverQuirk quirk, bool allow_partial)
114{
115 if (allow_partial)
116 return _quirks & quirk;
117 return (_quirks & quirk) == quirk;
118}
119
0120
=== added file 'src/LauncherHoverMachine.h'
--- src/LauncherHoverMachine.h 1970-01-01 00:00:00 +0000
+++ src/LauncherHoverMachine.h 2011-03-28 16:21:41 +0000
@@ -0,0 +1,64 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2011 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Didier Roche <didrocks@ubuntu.com>
18 */
19
20#ifndef LAUNCHERHOVERMACHINE
21#define LAUNCHERHOVERMACHINE
22
23#include <sigc++/sigc++.h>
24#include <glib.h>
25
26class LauncherHoverMachine : public sigc::trackable
27{
28 public:
29
30 typedef enum
31 {
32 DEFAULT = 0,
33 LAUNCHER_HIDDEN = 1 << 0,
34 MOUSE_OVER_LAUNCHER = 1 << 1,
35 MOUSE_OVER_BFB = 1 << 2,
36 SHOTCUT_KEYS_VISIBLE = 1 << 3,
37 QUICKLIST_OPEN = 1 << 4,
38 KEY_NAV_ACTIVE = 1 << 5,
39 LAUNCHER_IN_ACTION = 1 << 6,
40 } HoverQuirk;
41
42 LauncherHoverMachine ();
43 virtual ~LauncherHoverMachine ();
44
45 void SetQuirk (HoverQuirk quirk, bool active);
46 bool GetQuirk (HoverQuirk quirk, bool allow_partial = true);
47
48 sigc::signal<void, bool> should_hover_changed;
49
50 private:
51 void EnsureHoverState ();
52 void SetShouldHover (bool value);
53
54 static gboolean EmitShouldHoverChanged (gpointer data);
55
56 bool _should_hover;
57 bool _pending_should_hover;
58 HoverQuirk _quirks;
59
60 guint _hover_changed_emit_handle;
61
62};
63
64#endif
065
=== modified file 'src/LauncherIcon.cpp'
--- src/LauncherIcon.cpp 2011-03-25 20:38:29 +0000
+++ src/LauncherIcon.cpp 2011-03-28 16:21:41 +0000
@@ -94,6 +94,7 @@
94 MouseLeave.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave));94 MouseLeave.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave));
95 MouseDown.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));95 MouseDown.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));
96 MouseUp.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));96 MouseUp.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));
97 MouseClick.connect (sigc::mem_fun (this, &LauncherIcon::RecvMouseClick));
97 98
98}99}
99100
@@ -150,12 +151,18 @@
150void151void
151LauncherIcon::Activate ()152LauncherIcon::Activate ()
152{153{
154 if (PluginAdapter::Default ()->IsScaleActive())
155 PluginAdapter::Default ()->TerminateScale ();
156
153 ActivateLauncherIcon ();157 ActivateLauncherIcon ();
154}158}
155159
156void160void
157LauncherIcon::OpenInstance ()161LauncherIcon::OpenInstance ()
158{162{
163 if (PluginAdapter::Default ()->IsScaleActive())
164 PluginAdapter::Default ()->TerminateScale ();
165
159 OpenInstanceLauncherIcon ();166 OpenInstanceLauncherIcon ();
160}167}
161168
@@ -387,14 +394,17 @@
387 _tooltip->ShowWindow (false);394 _tooltip->ShowWindow (false);
388}395}
389396
390void LauncherIcon::OpenQuicklist (bool default_to_first_item)397gboolean LauncherIcon::OpenQuicklist (bool default_to_first_item)
391{398{
392 _tooltip->ShowWindow (false); 399 _tooltip->ShowWindow (false);
393 _quicklist->RemoveAllMenuItem ();400 _quicklist->RemoveAllMenuItem ();
394401
395 std::list<DbusmenuMenuitem *> menus = Menus ();402 std::list<DbusmenuMenuitem *> menus = Menus ();
396 if (menus.empty ())403 if (menus.empty ())
397 return;404 return false;
405
406 if (PluginAdapter::Default ()->IsScaleActive())
407 PluginAdapter::Default ()->TerminateScale ();
398408
399 std::list<DbusmenuMenuitem *>::iterator it;409 std::list<DbusmenuMenuitem *>::iterator it;
400 for (it = menus.begin (); it != menus.end (); it++)410 for (it = menus.begin (); it != menus.end (); it++)
@@ -433,6 +443,8 @@
433 int tip_x = geo.x + geo.width + 1;443 int tip_x = geo.x + geo.width + 1;
434 int tip_y = geo.y + _center.y;444 int tip_y = geo.y + _center.y;
435 QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);445 QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
446
447 return true;
436}448}
437449
438void LauncherIcon::RecvMouseDown (int button)450void LauncherIcon::RecvMouseDown (int button)
@@ -450,6 +462,14 @@
450 }462 }
451}463}
452464
465void LauncherIcon::RecvMouseClick (int button)
466{
467 if (button == 1)
468 Activate ();
469 else if (button == 2)
470 OpenInstance ();
471}
472
453void LauncherIcon::HideTooltip ()473void LauncherIcon::HideTooltip ()
454{474{
455 _tooltip->ShowWindow (false);475 _tooltip->ShowWindow (false);
456476
=== modified file 'src/LauncherIcon.h'
--- src/LauncherIcon.h 2011-03-23 19:21:46 +0000
+++ src/LauncherIcon.h 2011-03-28 16:21:41 +0000
@@ -93,9 +93,10 @@
93 void RecvMouseLeave ();93 void RecvMouseLeave ();
94 void RecvMouseDown (int button);94 void RecvMouseDown (int button);
95 void RecvMouseUp (int button);95 void RecvMouseUp (int button);
96 void RecvMouseClick (int button);
96 97
97 void HideTooltip ();98 void HideTooltip ();
98 void OpenQuicklist (bool default_to_first_item = false);99 gboolean OpenQuicklist (bool default_to_first_item = false);
99100
100 void SetCenter (nux::Point3 center);101 void SetCenter (nux::Point3 center);
101 nux::Point3 GetCenter ();102 nux::Point3 GetCenter ();
102103
=== modified file 'src/PlaceEntryRemote.cpp'
--- src/PlaceEntryRemote.cpp 2011-03-23 19:35:06 +0000
+++ src/PlaceEntryRemote.cpp 2011-03-28 16:21:41 +0000
@@ -188,7 +188,7 @@
188 _icon (NULL),188 _icon (NULL),
189 _description (NULL),189 _description (NULL),
190 _searchhint (_("Search")),190 _searchhint (_("Search")),
191 _shortcut (10), // impossible shortcut191 _shortcut (0),
192 _position (0),192 _position (0),
193 _mimetypes (NULL),193 _mimetypes (NULL),
194 _sensitive (true),194 _sensitive (true),
195195
=== modified file 'src/PlaceLauncherIcon.cpp'
--- src/PlaceLauncherIcon.cpp 2011-03-24 10:40:26 +0000
+++ src/PlaceLauncherIcon.cpp 2011-03-28 16:21:41 +0000
@@ -61,17 +61,6 @@
61}61}
6262
63void63void
64PlaceLauncherIcon::OnMouseClick (int button)
65{
66 SimpleLauncherIcon::OnMouseClick (button);
67
68 if (button == 1)
69 {
70 ActivateLauncherIcon ();
71 }
72}
73
74void
75PlaceLauncherIcon::ActivateLauncherIcon ()64PlaceLauncherIcon::ActivateLauncherIcon ()
76{65{
77 ActivatePlace (0, "");66 ActivatePlace (0, "");
7867
=== modified file 'src/PlaceLauncherIcon.h'
--- src/PlaceLauncherIcon.h 2011-03-09 17:25:03 +0000
+++ src/PlaceLauncherIcon.h 2011-03-28 16:21:41 +0000
@@ -36,7 +36,6 @@
36 virtual nux::Color GlowColor ();36 virtual nux::Color GlowColor ();
3737
38protected:38protected:
39 void OnMouseClick (int button);
40 void UpdatePlaceIcon ();39 void UpdatePlaceIcon ();
41 std::list<DbusmenuMenuitem *> GetMenus ();40 std::list<DbusmenuMenuitem *> GetMenus ();
4241
4342
=== modified file 'src/SimpleLauncherIcon.cpp'
--- src/SimpleLauncherIcon.cpp 2011-03-28 10:04:47 +0000
+++ src/SimpleLauncherIcon.cpp 2011-03-28 16:21:41 +0000
@@ -69,8 +69,6 @@
69void69void
70SimpleLauncherIcon::OnMouseClick (int button)70SimpleLauncherIcon::OnMouseClick (int button)
71{71{
72 if (button == 1 && PluginAdapter::Default ()->IsScaleActive())
73 PluginAdapter::Default ()->TerminateScale ();
74}72}
7573
76void74void
@@ -86,7 +84,6 @@
86void84void
87SimpleLauncherIcon::ActivateLauncherIcon ()85SimpleLauncherIcon::ActivateLauncherIcon ()
88{86{
89 MouseClick.emit (1);
90}87}
9188
92nux::BaseTexture *89nux::BaseTexture *
9390
=== modified file 'src/TrashLauncherIcon.cpp'
--- src/TrashLauncherIcon.cpp 2011-03-08 23:14:23 +0000
+++ src/TrashLauncherIcon.cpp 2011-03-28 16:21:41 +0000
@@ -70,11 +70,12 @@
70 return nux::Color (0xFF333333);70 return nux::Color (0xFF333333);
71}71}
7272
73void73std::list<DbusmenuMenuitem *>
74TrashLauncherIcon::EnsureMenuItemsReady ()74TrashLauncherIcon::GetMenus ()
75{75{
76 std::list<DbusmenuMenuitem *> result;
76 DbusmenuMenuitem *menu_item;77 DbusmenuMenuitem *menu_item;
7778
78 /* Empty Trash */79 /* Empty Trash */
79 menu_item = dbusmenu_menuitem_new ();80 menu_item = dbusmenu_menuitem_new ();
80 g_object_ref (menu_item);81 g_object_ref (menu_item);
@@ -82,36 +83,12 @@
82 dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash..."));83 dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash..."));
83 dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !_empty);84 dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !_empty);
84 dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);85 dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
85
86 g_signal_connect (menu_item,86 g_signal_connect (menu_item,
87 DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, 87 DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
88 (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);88 (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);
8989 result.push_back(menu_item);
90 _menu_items["Empty"] = menu_item;90
91}91 return result;
92
93void
94TrashLauncherIcon::OnMouseClick (int button)
95{
96 SimpleLauncherIcon::OnMouseClick (button);
97
98 if (button == 1)
99 ActivateLauncherIcon ();
100
101 else if (button == 3)
102 {
103 EnsureMenuItemsReady ();
104
105 _quicklist->RemoveAllMenuItem ();
106 QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel (_menu_items["Empty"], NUX_TRACKER_LOCATION);
107 _quicklist->AddMenuItem (item);
108
109 int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
110 nux::Point3 center = GetCenter ();
111 int tip_y = center.y+ _launcher->GetParent ()->GetGeometry ().y;
112 QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
113 nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist);
114 }
115}92}
11693
117void94void
11895
=== modified file 'src/TrashLauncherIcon.h'
--- src/TrashLauncherIcon.h 2011-02-22 13:46:36 +0000
+++ src/TrashLauncherIcon.h 2011-03-28 16:21:41 +0000
@@ -33,19 +33,17 @@
33 virtual nux::Color GlowColor ();33 virtual nux::Color GlowColor ();
3434
35protected:35protected:
36 void OnMouseClick (int button);
37 void UpdateTrashIcon ();36 void UpdateTrashIcon ();
38 37
39 nux::DndAction OnQueryAcceptDrop (std::list<char *> uris);38 nux::DndAction OnQueryAcceptDrop (std::list<char *> uris);
40 void OnAcceptDrop (std::list<char *> uris);39 void OnAcceptDrop (std::list<char *> uris);
4140
42private:41private:
43 std::map<std::string, DbusmenuMenuitem *> _menu_items;
44 GFileMonitor *m_TrashMonitor;42 GFileMonitor *m_TrashMonitor;
45 gboolean _empty;43 gboolean _empty;
4644
47 void ActivateLauncherIcon ();45 void ActivateLauncherIcon ();
48 void EnsureMenuItemsReady ();46 std::list<DbusmenuMenuitem *> GetMenus ();
4947
50 static void UpdateTrashIconCb (GObject *source, GAsyncResult *res, gpointer data);48 static void UpdateTrashIconCb (GObject *source, GAsyncResult *res, gpointer data);
51 static void OnTrashChanged (GFileMonitor *monitor, GFile *file, GFile *other_file,49 static void OnTrashChanged (GFileMonitor *monitor, GFile *file, GFile *other_file,