Merge lp:~3v1n0/unity/laucher-edge-reveal-revisited into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 1328
Proposed branch: lp:~3v1n0/unity/laucher-edge-reveal-revisited
Merge into: lp:unity
Diff against target: 115 lines (+51/-3)
3 files modified
plugins/unityshell/src/unityshell.cpp (+41/-2)
plugins/unityshell/src/unityshell.h (+2/-0)
plugins/unityshell/unityshell.xml.in (+8/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/laucher-edge-reveal-revisited
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+69701@code.launchpad.net

Description of the change

When using the edge revealing, the launcher is too slow to show and it often shows when not needed.

So, I've basically added a compiz option which allows to set the timeout to wait before showing the unity launcher, currently set to 150ms.
Then, I've introduced some more filters which should avoid unneeded revelations: basically after that the reveal timeout has been reached we also check if we didn't move "too much" the mouse along the Y axis; then if we didn't move, the launcher is shown, otherwise we retry to show the launcher until the mouse pointer is touching the left edge.

Another thing that I didn't implemented yet, but that could be considered, comes from the bug #801320: actually we only allow the launcher to show if the mouse pointer "hits" on the left screen edge, maybe we should allow also to show it if we stay on the pointerX "1px" for a longer time; maybe for something like 4*_edge_timeout, and we didn't move after this timeout (in the Y axis). Just let me know if this is something that I should add to this branch.

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

+1 looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2011-07-28 10:43:23 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2011-07-28 18:11:21 +0000
4@@ -139,6 +139,8 @@
5
6 debugger = new DebugDBusInterface(this);
7
8+ _edge_timeout = optionGetLauncherRevealEdgeTimeout ();
9+
10 optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
11 optionSetBacklightModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
12 optionSetLaunchAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
13@@ -160,6 +162,7 @@
14 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
15 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
16 optionSetLauncherRevealEdgeInitiate(boost::bind(&UnityScreen::launcherRevealEdgeInitiate, this, _1, _2, _3));
17+ optionSetLauncherRevealEdgeTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
18 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
19
20 for (unsigned int i = 0; i < G_N_ELEMENTS(_ubus_handles); i++)
21@@ -524,7 +527,33 @@
22 UnityScreen* self = reinterpret_cast<UnityScreen*>(data);
23
24 if (pointerX == 0)
25- self->launcher->EdgeRevealTriggered();
26+ {
27+ if (abs(pointerY-self->_edge_pointerY) <= 5)
28+ {
29+ self->launcher->EdgeRevealTriggered();
30+ }
31+ else
32+ {
33+ /* We are still in the edge, but moving in Y, maybe we need another chance */
34+
35+ if (abs(pointerY-self->_edge_pointerY) > 20)
36+ {
37+ /* We're quite far from the first hit spot, let's wait again */
38+ self->_edge_pointerY = pointerY;
39+ return true;
40+ }
41+ else
42+ {
43+ /* We're quite near to the first hit spot, so we can reduce our timeout */
44+ self->_edge_pointerY = pointerY;
45+ g_source_remove(self->_edge_trigger_handle);
46+ self->_edge_trigger_handle = g_timeout_add(self->_edge_timeout/2,
47+ &UnityScreen::OnEdgeTriggerTimeout,
48+ self);
49+ return false;
50+ }
51+ }
52+ }
53
54 self->_edge_trigger_handle = 0;
55 return false;
56@@ -540,7 +569,14 @@
57 if (_edge_trigger_handle)
58 g_source_remove(_edge_trigger_handle);
59
60- _edge_trigger_handle = g_timeout_add(500, &UnityScreen::OnEdgeTriggerTimeout, this);
61+ if (pointerX == 0)
62+ {
63+ _edge_pointerY = pointerY;
64+ _edge_trigger_handle = g_timeout_add(_edge_timeout,
65+ &UnityScreen::OnEdgeTriggerTimeout,
66+ this);
67+ }
68+
69 return false;
70 }
71
72@@ -982,6 +1018,9 @@
73 case UnityshellOptions::DevicesOption:
74 unity::DevicesSettings::GetDefault().SetDevicesOption((unity::DevicesSettings::DevicesOption) optionGetDevicesOption());
75 break;
76+ case UnityshellOptions::LauncherRevealEdgeTimeout:
77+ _edge_timeout = optionGetLauncherRevealEdgeTimeout();
78+ break;
79 default:
80 break;
81 }
82
83=== modified file 'plugins/unityshell/src/unityshell.h'
84--- plugins/unityshell/src/unityshell.h 2011-07-28 11:02:56 +0000
85+++ plugins/unityshell/src/unityshell.h 2011-07-28 18:11:21 +0000
86@@ -197,7 +197,9 @@
87 DebugDBusInterface* debugger;
88 bool needsRelayout;
89 guint32 relayoutSourceId;
90+ guint _edge_timeout;
91 guint _edge_trigger_handle;
92+ gint _edge_pointerY;
93 guint _ubus_handles[3];
94
95 /* keyboard-nav mode */
96
97=== modified file 'plugins/unityshell/unityshell.xml.in'
98--- plugins/unityshell/unityshell.xml.in 2011-07-26 12:33:23 +0000
99+++ plugins/unityshell/unityshell.xml.in 2011-07-28 18:11:21 +0000
100@@ -46,7 +46,14 @@
101 <edge name="Left"/>
102 </default>
103 </option>
104- <option name="launcher_hide_mode" type="int">
105+ <option name="launcher_reveal_edge_timeout" type="int">
106+ <_short>Edge Reveal Timeout</_short>
107+ <_long>How long (in ms) wait before revealing the launcher when the mouse pointer is touching the edge.</_long>
108+ <min>1</min>
109+ <max>1000</max>
110+ <default>150</default>
111+ </option>
112+ <option name="launcher_hide_mode" type="int">
113 <_short>Hide Launcher</_short>
114 <_long>Make the launcher hide automatically after some time of inactivity: always or just when the focussed window is not over the launcher</_long>
115 <min>0</min>