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
1=== modified file 'src/Launcher.cpp'
2--- src/Launcher.cpp 2010-12-06 22:11:41 +0000
3+++ src/Launcher.cpp 2010-12-07 03:25:11 +0000
4@@ -168,7 +168,7 @@
5 float FarClipPlane,
6 float Fovy);
7
8-Launcher::Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_DECL)
9+Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DECL)
10 : View(NUX_FILE_LINE_PARAM)
11 , m_ContentOffsetY(0)
12 , m_RunningIndicator(0)
13@@ -177,6 +177,7 @@
14 , _model (0)
15 {
16 _parent = parent;
17+ _screen = screen;
18 _active_quicklist = 0;
19
20 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
21@@ -252,6 +253,8 @@
22 _autohide = false;
23 _hidden = false;
24 _mouse_inside_launcher = false;
25+ _mouse_inside_trigger = false;
26+ _window_over_launcher = false;
27
28 // 0 out timers to avoid wonky startups
29 _enter_time.tv_sec = 0;
30@@ -827,7 +830,7 @@
31 return;
32
33 _hidden = hidden;
34- SetTimeStruct (&_autohide_time, &_autohide_time, ANIM_DURATION);
35+ SetTimeStruct (&_autohide_time, &_autohide_time, ANIM_DURATION_SHORT);
36
37 _parent->EnableInputWindow(!hidden);
38
39@@ -838,36 +841,80 @@
40 {
41 Launcher *self = (Launcher*) data;
42
43- if (self->_hovered || self->_hidden)
44- return false;
45-
46- self->SetHidden (true);
47-
48+ self->EnsureHiddenState ();
49 self->_autohide_handle = 0;
50 return false;
51 }
52
53+void
54+Launcher::EnsureHiddenState ()
55+{
56+ if (!_mouse_inside_trigger && !_mouse_inside_launcher && _window_over_launcher)
57+ SetHidden (true);
58+ else
59+ SetHidden (false);
60+}
61+
62+void
63+Launcher::CheckWindowOverLauncher ()
64+{
65+ CompWindowList window_list = _screen->windows ();
66+ CompWindowList::iterator it;
67+ nux::Geometry geo = GetGeometry ();
68+
69+ for (it = window_list.begin (); it != window_list.end (); it++)
70+ {
71+ CompWindow *window = *it;
72+
73+ if (window->type () != CompWindowTypeNormalMask || window->invisible ())
74+ continue;
75+
76+ if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
77+ {
78+ _window_over_launcher = true;
79+ EnsureHiddenState ();
80+ return;
81+ }
82+ }
83+
84+ _window_over_launcher = false;
85+ EnsureHiddenState ();
86+}
87+
88+void
89+Launcher::OnWindowMoved (CompWindow *window)
90+{
91+ if (_autohide)
92+ CheckWindowOverLauncher ();
93+}
94+
95+void
96+Launcher::OnWindowResized (CompWindow *window)
97+{
98+ if (_autohide)
99+ CheckWindowOverLauncher ();
100+}
101+
102 void Launcher::OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
103 {
104- if (!_autohide || !_hidden)
105- return;
106-
107- SetHidden (false);
108+ _mouse_inside_trigger = true;
109+ EnsureHiddenState ();
110 }
111
112 void Launcher::SetupAutohideTimer ()
113 {
114- if (_autohide)
115- {
116- if (_autohide_handle > 0)
117- g_source_remove (_autohide_handle);
118- _autohide_handle = g_timeout_add (1000, &Launcher::OnAutohideTimeout, this);
119- }
120+ if (_autohide)
121+ {
122+ if (_autohide_handle > 0)
123+ g_source_remove (_autohide_handle);
124+ _autohide_handle = g_timeout_add (1000, &Launcher::OnAutohideTimeout, this);
125+ }
126 }
127
128 void Launcher::OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
129 {
130- SetupAutohideTimer ();
131+ _mouse_inside_trigger = false;
132+ SetupAutohideTimer ();
133 }
134
135 bool Launcher::AutohideEnabled ()
136
137=== modified file 'src/Launcher.h'
138--- src/Launcher.h 2010-12-06 22:11:41 +0000
139+++ src/Launcher.h 2010-12-07 03:25:11 +0000
140@@ -21,6 +21,7 @@
141 #define LAUNCHER_H
142
143 #include <sys/time.h>
144+#include <core/core.h>
145
146 #include <Nux/View.h>
147 #include <Nux/BaseWindow.h>
148@@ -35,7 +36,7 @@
149 class Launcher : public Introspectable, public nux::View
150 {
151 public:
152- Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
153+ Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO);
154 ~Launcher();
155
156 virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
157@@ -59,6 +60,9 @@
158 void SetAutohide (bool autohide, nux::View *show_trigger);
159 bool AutohideEnabled ();
160
161+ void OnWindowMoved (CompWindow *window);
162+ void OnWindowResized (CompWindow *window);
163+
164 virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
165 virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
166 virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
167@@ -121,9 +125,12 @@
168 bool AnimationInProgress ();
169 void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);
170
171+ void EnsureHiddenState ();
172 void EnsureAnimation ();
173 void SetupAutohideTimer ();
174
175+ void CheckWindowOverLauncher ();
176+
177 float DnDExitProgress (struct timespec const &current);
178 float GetHoverProgress (struct timespec const &current);
179 float AutohideProgress (struct timespec const &current);
180@@ -195,6 +202,8 @@
181 bool _autohide;
182 bool _hidden;
183 bool _mouse_inside_launcher;
184+ bool _mouse_inside_trigger;
185+ bool _window_over_launcher;
186
187 float _folded_angle;
188 float _neg_folded_angle;
189@@ -239,6 +248,8 @@
190 nux::View* _autohide_trigger;
191 LauncherModel* _model;
192
193+ CompScreen* _screen;
194+
195 /* event times */
196 struct timespec _enter_time;
197 struct timespec _exit_time;
198
199=== modified file 'src/unity.cpp'
200--- src/unity.cpp 2010-12-04 04:55:25 +0000
201+++ src/unity.cpp 2010-12-07 03:25:11 +0000
202@@ -292,6 +292,20 @@
203 window->windowNotify (n);
204 }
205
206+void
207+UnityWindow::moveNotify (int x, int y, bool immediate)
208+{
209+ uScreen->launcher->OnWindowMoved (window);
210+ window->moveNotify (x, y, immediate);
211+}
212+
213+void
214+UnityWindow::resizeNotify (int x, int y, int w, int h)
215+{
216+ uScreen->launcher->OnWindowResized (window);
217+ window->resizeNotify (x, y, w, h);
218+}
219+
220 /* Configure callback for the launcher window */
221 void
222 UnityScreen::launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data)
223@@ -413,7 +427,7 @@
224 UnityScreen *self = (UnityScreen*) InitData;
225
226 self->launcherWindow = new nux::BaseWindow(TEXT(""));
227- self->launcher = new Launcher(self->launcherWindow);
228+ self->launcher = new Launcher(self->launcherWindow, self->screen);
229 self->AddChild (self->launcher);
230
231 nux::HLayout* layout = new nux::HLayout();
232
233=== modified file 'src/unity.h'
234--- src/unity.h 2010-12-04 04:55:25 +0000
235+++ src/unity.h 2010-12-07 03:25:11 +0000
236@@ -171,6 +171,9 @@
237
238 void windowNotify (CompWindowNotify n);
239
240+ void moveNotify (int x, int y, bool immediate);
241+
242+ void resizeNotify (int x, int y, int w, int h);
243 };
244
245 #define EX_SCREEN (screen) \