Merge lp:~canonical-dx-team/unity/unity.intellihide into lp:unity

Proposed by Jason Smith
Status: Merged
Merged at revision: 669
Proposed branch: lp:~canonical-dx-team/unity/unity.intellihide
Merge into: lp:unity
Diff against target: 245 lines (+95/-20)
4 files modified
src/Launcher.cpp (+65/-18)
src/Launcher.h (+12/-1)
src/unity.cpp (+15/-1)
src/unity.h (+3/-0)
To merge this branch: bzr merge lp:~canonical-dx-team/unity/unity.intellihide
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Needs Fixing
Review via email: mp+42889@code.launchpad.net

Description of the change

Implements intellihide yo

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi Jason,

I'm not able to test since nux doesn't work on both of my systems at the moment *COUGH* but some small ideas for improvement before you merge.

1) ::resizeNotify will only tell you of the new window geometry once the geometry has actually changed, not while the window is resizing, in the case that we are using the "outline, rectangle or stretch" modes. In that case you'll want to wrap handle event and listen for the "_COMPIZ_RESIZE_NOTIFY" atom and use that to determine the *current* resize geometry. Have a look at group.cpp:1827 on how this is done.

2) Your current approach wraps resizeNotify and moveNotify for every single window in the stack. This is a little bit inefficient IMO - maybe you should wrap grabNotify () to determine which window was grabbed in the first place and then enable moveNotify and resizeNotify on the window (moveNotifySetEnabled, resizeNotifySetEnabled) depending on the grab type. Also enabled ungrabNotify at this point and when that comes you can disable all of those functions. That way you aren't being pinged all the time every single time a window moves or resizes for other reasons, eg because the wall plugin shifted the screen to the left or something.

3) You should not use w->frameRegion (). Use w->inputRegion () instead. w->frameRegion () includes only the geometry of the window frame itself, eg a big region with a hole cut in the middle. In situations where the frame size is bigger than the dock size, this could lead to an awkward race condition where the two regions won't intersect because of that hole.

4) For unit testing it might not be such a good idea to bring Compiz specific definitions into Launcher.cpp such as CompScreen and CompWindow. Maybe instead of checking the entire window list there you can just call OnWindowMoved or OnWindowResized with the X Region of the inputRegion for the window on moveNotify or grabNotify and save a count of "currently intersecting regions". (To get the X region you can call someRegion->handle ()). That way you can just XIntersectRegion like normal.

Other than that it looks good.

review: Needs Fixing
Revision history for this message
Jason Smith (jassmith) wrote :

1) Dont care about that, we are okay to update intellihide *after* a resize is completed

2) resize notify and grab notify should be relatively infrequent callers. The cost of them should be a tiny fraction compared to our wrapping of the paint call. Using grab notify then means we only respond to user generated results.

3) fixed

4) Not a problem for testing since these calls are input only. If we relied on them for state generation I would be more concerned.

Revision history for this message
Alex Launi (alexlauni) wrote :

1) It's much nicer to hide during resize, rather than just after. It makes the experience just a little bit nicer to be able to interactively show/hide the launcher while performing the resize.

think of the children

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Launcher.cpp'
--- src/Launcher.cpp 2010-12-06 22:11:41 +0000
+++ src/Launcher.cpp 2010-12-07 03:25:11 +0000
@@ -168,7 +168,7 @@
168 float FarClipPlane,168 float FarClipPlane,
169 float Fovy);169 float Fovy);
170170
171Launcher::Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_DECL)171Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DECL)
172: View(NUX_FILE_LINE_PARAM)172: View(NUX_FILE_LINE_PARAM)
173, m_ContentOffsetY(0)173, m_ContentOffsetY(0)
174, m_RunningIndicator(0)174, m_RunningIndicator(0)
@@ -177,6 +177,7 @@
177, _model (0)177, _model (0)
178{178{
179 _parent = parent;179 _parent = parent;
180 _screen = screen;
180 _active_quicklist = 0;181 _active_quicklist = 0;
181 182
182 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);183 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
@@ -252,6 +253,8 @@
252 _autohide = false;253 _autohide = false;
253 _hidden = false;254 _hidden = false;
254 _mouse_inside_launcher = false;255 _mouse_inside_launcher = false;
256 _mouse_inside_trigger = false;
257 _window_over_launcher = false;
255 258
256 // 0 out timers to avoid wonky startups259 // 0 out timers to avoid wonky startups
257 _enter_time.tv_sec = 0;260 _enter_time.tv_sec = 0;
@@ -827,7 +830,7 @@
827 return;830 return;
828 831
829 _hidden = hidden;832 _hidden = hidden;
830 SetTimeStruct (&_autohide_time, &_autohide_time, ANIM_DURATION);833 SetTimeStruct (&_autohide_time, &_autohide_time, ANIM_DURATION_SHORT);
831 834
832 _parent->EnableInputWindow(!hidden);835 _parent->EnableInputWindow(!hidden);
833 836
@@ -838,36 +841,80 @@
838{841{
839 Launcher *self = (Launcher*) data;842 Launcher *self = (Launcher*) data;
840 843
841 if (self->_hovered || self->_hidden)844 self->EnsureHiddenState ();
842 return false;
843
844 self->SetHidden (true);
845
846 self->_autohide_handle = 0;845 self->_autohide_handle = 0;
847 return false;846 return false;
848}847}
849848
849void
850Launcher::EnsureHiddenState ()
851{
852 if (!_mouse_inside_trigger && !_mouse_inside_launcher && _window_over_launcher)
853 SetHidden (true);
854 else
855 SetHidden (false);
856}
857
858void
859Launcher::CheckWindowOverLauncher ()
860{
861 CompWindowList window_list = _screen->windows ();
862 CompWindowList::iterator it;
863 nux::Geometry geo = GetGeometry ();
864
865 for (it = window_list.begin (); it != window_list.end (); it++)
866 {
867 CompWindow *window = *it;
868
869 if (window->type () != CompWindowTypeNormalMask || window->invisible ())
870 continue;
871
872 if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
873 {
874 _window_over_launcher = true;
875 EnsureHiddenState ();
876 return;
877 }
878 }
879
880 _window_over_launcher = false;
881 EnsureHiddenState ();
882}
883
884void
885Launcher::OnWindowMoved (CompWindow *window)
886{
887 if (_autohide)
888 CheckWindowOverLauncher ();
889}
890
891void
892Launcher::OnWindowResized (CompWindow *window)
893{
894 if (_autohide)
895 CheckWindowOverLauncher ();
896}
897
850void Launcher::OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)898void Launcher::OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
851{899{
852 if (!_autohide || !_hidden)900 _mouse_inside_trigger = true;
853 return;901 EnsureHiddenState ();
854
855 SetHidden (false);
856}902}
857903
858void Launcher::SetupAutohideTimer ()904void Launcher::SetupAutohideTimer ()
859{905{
860 if (_autohide)906 if (_autohide)
861 {907 {
862 if (_autohide_handle > 0)908 if (_autohide_handle > 0)
863 g_source_remove (_autohide_handle);909 g_source_remove (_autohide_handle);
864 _autohide_handle = g_timeout_add (1000, &Launcher::OnAutohideTimeout, this);910 _autohide_handle = g_timeout_add (1000, &Launcher::OnAutohideTimeout, this);
865 }911 }
866}912}
867913
868void Launcher::OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)914void Launcher::OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
869{915{
870 SetupAutohideTimer ();916 _mouse_inside_trigger = false;
917 SetupAutohideTimer ();
871}918}
872919
873bool Launcher::AutohideEnabled ()920bool Launcher::AutohideEnabled ()
874921
=== modified file 'src/Launcher.h'
--- src/Launcher.h 2010-12-06 22:11:41 +0000
+++ src/Launcher.h 2010-12-07 03:25:11 +0000
@@ -21,6 +21,7 @@
21#define LAUNCHER_H21#define LAUNCHER_H
2222
23#include <sys/time.h>23#include <sys/time.h>
24#include <core/core.h>
2425
25#include <Nux/View.h>26#include <Nux/View.h>
26#include <Nux/BaseWindow.h>27#include <Nux/BaseWindow.h>
@@ -35,7 +36,7 @@
35class Launcher : public Introspectable, public nux::View36class Launcher : public Introspectable, public nux::View
36{37{
37public:38public:
38 Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);39 Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO);
39 ~Launcher();40 ~Launcher();
4041
41 virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);42 virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
@@ -59,6 +60,9 @@
59 void SetAutohide (bool autohide, nux::View *show_trigger);60 void SetAutohide (bool autohide, nux::View *show_trigger);
60 bool AutohideEnabled ();61 bool AutohideEnabled ();
61 62
63 void OnWindowMoved (CompWindow *window);
64 void OnWindowResized (CompWindow *window);
65
62 virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);66 virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
63 virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);67 virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
64 virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);68 virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
@@ -121,9 +125,12 @@
121 bool AnimationInProgress ();125 bool AnimationInProgress ();
122 void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);126 void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);
123 127
128 void EnsureHiddenState ();
124 void EnsureAnimation ();129 void EnsureAnimation ();
125 void SetupAutohideTimer ();130 void SetupAutohideTimer ();
126 131
132 void CheckWindowOverLauncher ();
133
127 float DnDExitProgress (struct timespec const &current);134 float DnDExitProgress (struct timespec const &current);
128 float GetHoverProgress (struct timespec const &current);135 float GetHoverProgress (struct timespec const &current);
129 float AutohideProgress (struct timespec const &current);136 float AutohideProgress (struct timespec const &current);
@@ -195,6 +202,8 @@
195 bool _autohide;202 bool _autohide;
196 bool _hidden;203 bool _hidden;
197 bool _mouse_inside_launcher;204 bool _mouse_inside_launcher;
205 bool _mouse_inside_trigger;
206 bool _window_over_launcher;
198207
199 float _folded_angle;208 float _folded_angle;
200 float _neg_folded_angle;209 float _neg_folded_angle;
@@ -239,6 +248,8 @@
239 nux::View* _autohide_trigger;248 nux::View* _autohide_trigger;
240 LauncherModel* _model;249 LauncherModel* _model;
241 250
251 CompScreen* _screen;
252
242 /* event times */253 /* event times */
243 struct timespec _enter_time;254 struct timespec _enter_time;
244 struct timespec _exit_time;255 struct timespec _exit_time;
245256
=== modified file 'src/unity.cpp'
--- src/unity.cpp 2010-12-04 04:55:25 +0000
+++ src/unity.cpp 2010-12-07 03:25:11 +0000
@@ -292,6 +292,20 @@
292 window->windowNotify (n);292 window->windowNotify (n);
293}293}
294294
295void
296UnityWindow::moveNotify (int x, int y, bool immediate)
297{
298 uScreen->launcher->OnWindowMoved (window);
299 window->moveNotify (x, y, immediate);
300}
301
302void
303UnityWindow::resizeNotify (int x, int y, int w, int h)
304{
305 uScreen->launcher->OnWindowResized (window);
306 window->resizeNotify (x, y, w, h);
307}
308
295/* Configure callback for the launcher window */309/* Configure callback for the launcher window */
296void 310void
297UnityScreen::launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data)311UnityScreen::launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data)
@@ -413,7 +427,7 @@
413 UnityScreen *self = (UnityScreen*) InitData;427 UnityScreen *self = (UnityScreen*) InitData;
414 428
415 self->launcherWindow = new nux::BaseWindow(TEXT(""));429 self->launcherWindow = new nux::BaseWindow(TEXT(""));
416 self->launcher = new Launcher(self->launcherWindow);430 self->launcher = new Launcher(self->launcherWindow, self->screen);
417 self->AddChild (self->launcher);431 self->AddChild (self->launcher);
418432
419 nux::HLayout* layout = new nux::HLayout();433 nux::HLayout* layout = new nux::HLayout();
420434
=== modified file 'src/unity.h'
--- src/unity.h 2010-12-04 04:55:25 +0000
+++ src/unity.h 2010-12-07 03:25:11 +0000
@@ -171,6 +171,9 @@
171171
172 void windowNotify (CompWindowNotify n);172 void windowNotify (CompWindowNotify n);
173173
174 void moveNotify (int x, int y, bool immediate);
175
176 void resizeNotify (int x, int y, int w, int h);
174};177};
175178
176#define EX_SCREEN (screen) \179#define EX_SCREEN (screen) \