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
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2011-07-28 10:43:23 +0000
+++ plugins/unityshell/src/unityshell.cpp 2011-07-28 18:11:21 +0000
@@ -139,6 +139,8 @@
139139
140 debugger = new DebugDBusInterface(this);140 debugger = new DebugDBusInterface(this);
141141
142 _edge_timeout = optionGetLauncherRevealEdgeTimeout ();
143
142 optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));144 optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
143 optionSetBacklightModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));145 optionSetBacklightModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
144 optionSetLaunchAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));146 optionSetLaunchAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -160,6 +162,7 @@
160 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));162 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
161 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));163 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
162 optionSetLauncherRevealEdgeInitiate(boost::bind(&UnityScreen::launcherRevealEdgeInitiate, this, _1, _2, _3));164 optionSetLauncherRevealEdgeInitiate(boost::bind(&UnityScreen::launcherRevealEdgeInitiate, this, _1, _2, _3));
165 optionSetLauncherRevealEdgeTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
163 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));166 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
164167
165 for (unsigned int i = 0; i < G_N_ELEMENTS(_ubus_handles); i++)168 for (unsigned int i = 0; i < G_N_ELEMENTS(_ubus_handles); i++)
@@ -524,7 +527,33 @@
524 UnityScreen* self = reinterpret_cast<UnityScreen*>(data);527 UnityScreen* self = reinterpret_cast<UnityScreen*>(data);
525528
526 if (pointerX == 0)529 if (pointerX == 0)
527 self->launcher->EdgeRevealTriggered();530 {
531 if (abs(pointerY-self->_edge_pointerY) <= 5)
532 {
533 self->launcher->EdgeRevealTriggered();
534 }
535 else
536 {
537 /* We are still in the edge, but moving in Y, maybe we need another chance */
538
539 if (abs(pointerY-self->_edge_pointerY) > 20)
540 {
541 /* We're quite far from the first hit spot, let's wait again */
542 self->_edge_pointerY = pointerY;
543 return true;
544 }
545 else
546 {
547 /* We're quite near to the first hit spot, so we can reduce our timeout */
548 self->_edge_pointerY = pointerY;
549 g_source_remove(self->_edge_trigger_handle);
550 self->_edge_trigger_handle = g_timeout_add(self->_edge_timeout/2,
551 &UnityScreen::OnEdgeTriggerTimeout,
552 self);
553 return false;
554 }
555 }
556 }
528557
529 self->_edge_trigger_handle = 0;558 self->_edge_trigger_handle = 0;
530 return false;559 return false;
@@ -540,7 +569,14 @@
540 if (_edge_trigger_handle)569 if (_edge_trigger_handle)
541 g_source_remove(_edge_trigger_handle);570 g_source_remove(_edge_trigger_handle);
542571
543 _edge_trigger_handle = g_timeout_add(500, &UnityScreen::OnEdgeTriggerTimeout, this);572 if (pointerX == 0)
573 {
574 _edge_pointerY = pointerY;
575 _edge_trigger_handle = g_timeout_add(_edge_timeout,
576 &UnityScreen::OnEdgeTriggerTimeout,
577 this);
578 }
579
544 return false;580 return false;
545}581}
546582
@@ -982,6 +1018,9 @@
982 case UnityshellOptions::DevicesOption:1018 case UnityshellOptions::DevicesOption:
983 unity::DevicesSettings::GetDefault().SetDevicesOption((unity::DevicesSettings::DevicesOption) optionGetDevicesOption());1019 unity::DevicesSettings::GetDefault().SetDevicesOption((unity::DevicesSettings::DevicesOption) optionGetDevicesOption());
984 break;1020 break;
1021 case UnityshellOptions::LauncherRevealEdgeTimeout:
1022 _edge_timeout = optionGetLauncherRevealEdgeTimeout();
1023 break;
985 default:1024 default:
986 break;1025 break;
987 }1026 }
9881027
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2011-07-28 11:02:56 +0000
+++ plugins/unityshell/src/unityshell.h 2011-07-28 18:11:21 +0000
@@ -197,7 +197,9 @@
197 DebugDBusInterface* debugger;197 DebugDBusInterface* debugger;
198 bool needsRelayout;198 bool needsRelayout;
199 guint32 relayoutSourceId;199 guint32 relayoutSourceId;
200 guint _edge_timeout;
200 guint _edge_trigger_handle;201 guint _edge_trigger_handle;
202 gint _edge_pointerY;
201 guint _ubus_handles[3];203 guint _ubus_handles[3];
202204
203 /* keyboard-nav mode */205 /* keyboard-nav mode */
204206
=== modified file 'plugins/unityshell/unityshell.xml.in'
--- plugins/unityshell/unityshell.xml.in 2011-07-26 12:33:23 +0000
+++ plugins/unityshell/unityshell.xml.in 2011-07-28 18:11:21 +0000
@@ -46,7 +46,14 @@
46 <edge name="Left"/>46 <edge name="Left"/>
47 </default>47 </default>
48 </option>48 </option>
49 <option name="launcher_hide_mode" type="int">49 <option name="launcher_reveal_edge_timeout" type="int">
50 <_short>Edge Reveal Timeout</_short>
51 <_long>How long (in ms) wait before revealing the launcher when the mouse pointer is touching the edge.</_long>
52 <min>1</min>
53 <max>1000</max>
54 <default>150</default>
55 </option>
56 <option name="launcher_hide_mode" type="int">
50 <_short>Hide Launcher</_short>57 <_short>Hide Launcher</_short>
51 <_long>Make the launcher hide automatically after some time of inactivity: always or just when the focussed window is not over the launcher</_long>58 <_long>Make the launcher hide automatically after some time of inactivity: always or just when the focussed window is not over the launcher</_long>
52 <min>0</min>59 <min>0</min>