Merge lp:~brandontschaefer/unity/multi-monitor-dash-hud-drawing-fix into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2675
Proposed branch: lp:~brandontschaefer/unity/multi-monitor-dash-hud-drawing-fix
Merge into: lp:unity
Diff against target: 365 lines (+88/-32)
9 files modified
dash/DashController.cpp (+7/-2)
dash/DashView.cpp (+6/-6)
hud/HudController.cpp (+14/-8)
hud/HudController.h (+1/-1)
hud/HudView.cpp (+3/-0)
tests/autopilot/unity/emulators/dash.py (+7/-2)
tests/autopilot/unity/emulators/hud.py (+5/-0)
tests/autopilot/unity/tests/test_dash.py (+27/-11)
tests/autopilot/unity/tests/test_hud.py (+18/-2)
To merge this branch: bzr merge lp:~brandontschaefer/unity/multi-monitor-dash-hud-drawing-fix
Reviewer Review Type Date Requested Status
jenkins (community) continuous-integration Needs Fixing
Tim Penhey (community) Approve
Review via email: mp+123002@code.launchpad.net

Commit message

Dash and Hud get drawn correctly no matter which monitor the mouse is in.

Description of the change

=== Problem ===
Anytime the Dash or Hud would get drawn it would ask what is the ideal monitor geo...so when your mouse was in another monitor it would say that monitor is the ideal place to draw the Dash or Hud.

=== Fix ===
If the Dash or Hud is visible use that monitor rather then trying to find it again and again.

=== Tests ===
AP Tests

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Why is it called target_monitor for hud but ideal_monitor for the dash?

Could we get some consistency there?

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) wrote :

The rest of the code looks good.

Revision history for this message
Tim Penhey (thumper) wrote :

Thanks.

review: Approve
Revision history for this message
jenkins (martin-mrazik+qa) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/unity-autolanding/15/

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in tests/autopilot/unity/tests/test_hud.py

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2012-08-25 03:17:58 +0000
3+++ dash/DashController.cpp 2012-09-07 20:06:22 +0000
4@@ -171,7 +171,9 @@
5 {
6 UScreen *uscreen = UScreen::GetDefault();
7 int primary_monitor;
8- if (use_primary)
9+ if (visible_)
10+ primary_monitor = monitor_;
11+ else if (use_primary)
12 primary_monitor = uscreen->GetPrimaryMonitor();
13 else
14 primary_monitor = uscreen->GetMonitorWithMouse();
15@@ -259,10 +261,12 @@
16 return;
17 }
18
19+ /* GetIdealMonitor must get called before visible_ is set */
20+ monitor_ = GetIdealMonitor();
21+
22 // The launcher must receive UBUS_OVERLAY_SHOW before window_->EnableInputWindow().
23 // Other wise the Launcher gets focus for X, which causes XIM to fail.
24 sources_.AddIdle([this] {
25- monitor_ = GetIdealMonitor();
26 GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
27 ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
28 return false;
29@@ -369,6 +373,7 @@
30 void Controller::AddProperties(GVariantBuilder* builder)
31 {
32 variant::BuilderWrapper(builder).add("visible", visible_)
33+ .add("ideal_monitor", GetIdealMonitor())
34 .add("monitor", monitor_);
35 }
36
37
38=== modified file 'dash/DashView.cpp'
39--- dash/DashView.cpp 2012-09-05 09:21:07 +0000
40+++ dash/DashView.cpp 2012-09-07 20:06:22 +0000
41@@ -407,22 +407,22 @@
42
43 if (IsFullRedraw())
44 nux::GetPainter().PushBackgroundStack();
45-
46+
47 if (preview_displaying_)
48 preview_container_->ProcessDraw(gfx_context, (!force_draw) ? IsFullRedraw() : force_draw);
49 else
50 layout_->ProcessDraw(gfx_context, force_draw);
51-
52+
53 if (IsFullRedraw())
54 nux::GetPainter().PopBackgroundStack();
55
56 renderer_.DrawInnerCleanup(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry());
57 }
58
59- void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
60- {
61- dash::Style& style = dash::Style::Instance();
62- nux::Geometry geo(content_geo_);
63+void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
64+{
65+ dash::Style& style = dash::Style::Instance();
66+ nux::Geometry geo(content_geo_);
67
68 if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP)
69 {
70
71=== modified file 'hud/HudController.cpp'
72--- hud/HudController.cpp 2012-06-26 02:22:44 +0000
73+++ hud/HudController.cpp 2012-09-07 20:06:22 +0000
74@@ -122,9 +122,14 @@
75 AddChild(view_);
76 }
77
78-int Controller::GetTargetMonitor()
79+int Controller::GetIdealMonitor()
80 {
81- return UScreen::GetDefault()->GetMonitorWithMouse();
82+ int ideal_monitor;
83+ if (visible_)
84+ ideal_monitor = monitor_index_;
85+ else
86+ ideal_monitor = UScreen::GetDefault()->GetMonitorWithMouse();
87+ return ideal_monitor;
88 }
89
90 bool Controller::IsLockedToLauncher(int monitor)
91@@ -181,8 +186,8 @@
92
93 nux::Geometry Controller::GetIdealWindowGeometry()
94 {
95- int target_monitor = GetTargetMonitor();
96- auto monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(target_monitor);
97+ int ideal_monitor = GetIdealMonitor();
98+ auto monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(ideal_monitor);
99
100 // We want to cover as much of the screen as possible to grab any mouse events
101 // outside of our window
102@@ -192,7 +197,7 @@
103 monitor_geo.width,
104 monitor_geo.height - panel_style.panel_height);
105
106- if (IsLockedToLauncher(target_monitor))
107+ if (IsLockedToLauncher(ideal_monitor))
108 {
109 geo.x += launcher_width;
110 geo.width -= launcher_width;
111@@ -273,12 +278,12 @@
112 return;
113 }
114
115- unsigned int target_monitor = GetTargetMonitor();
116+ unsigned int ideal_monitor = GetIdealMonitor();
117
118- if (target_monitor != monitor_index_)
119+ if (ideal_monitor != monitor_index_)
120 {
121 Relayout();
122- monitor_index_ = target_monitor;
123+ monitor_index_ = ideal_monitor;
124 }
125
126 view_->ShowEmbeddedIcon(!IsLockedToLauncher(monitor_index_));
127@@ -487,6 +492,7 @@
128 {
129 variant::BuilderWrapper(builder)
130 .add(window_ ? window_->GetGeometry() : nux::Geometry())
131+ .add("ideal_monitor", GetIdealMonitor())
132 .add("visible", visible_)
133 .add("hud_monitor", monitor_index_)
134 .add("locked_to_launcher", IsLockedToLauncher(monitor_index_));
135
136=== modified file 'hud/HudController.h'
137--- hud/HudController.h 2012-06-18 02:57:23 +0000
138+++ hud/HudController.h 2012-09-07 20:06:22 +0000
139@@ -71,7 +71,7 @@
140 void RegisterUBusInterests();
141 void SetIcon(std::string const& icon_name);
142
143- int GetTargetMonitor();
144+ int GetIdealMonitor();
145 bool IsLockedToLauncher(int monitor);
146
147 nux::Geometry GetIdealWindowGeometry();
148
149=== modified file 'hud/HudView.cpp'
150--- hud/HudView.cpp 2012-09-04 18:15:34 +0000
151+++ hud/HudView.cpp 2012-09-07 20:06:22 +0000
152@@ -60,6 +60,7 @@
153 View::View()
154 : AbstractView()
155 , button_views_(nullptr)
156+ , visible_(false)
157 , start_time_(0)
158 , last_known_height_(0)
159 , current_height_(0)
160@@ -350,11 +351,13 @@
161
162 void View::AboutToShow()
163 {
164+ visible_ = true;
165 renderer_.AboutToShow();
166 }
167
168 void View::AboutToHide()
169 {
170+ visible_ = false;
171 renderer_.AboutToHide();
172 }
173
174
175=== modified file 'tests/autopilot/unity/emulators/dash.py'
176--- tests/autopilot/unity/emulators/dash.py 2012-08-22 13:14:18 +0000
177+++ tests/autopilot/unity/emulators/dash.py 2012-09-07 20:06:22 +0000
178@@ -75,6 +75,11 @@
179 return self.controller.monitor
180
181 @property
182+ def ideal_monitor(self):
183+ """The ideal monitor for the dash to appear on"""
184+ return self.controller.ideal_monitor
185+
186+ @property
187 def search_string(self):
188 return self.searchbar.search_string
189
190@@ -436,7 +441,7 @@
191 if nav.direction == 2:
192 return nav
193 return None
194-
195+
196 def get_right_navigator(self):
197 """Return the right navigator object"""
198 navigators = self.get_children_by_type(PreviewNavigator)
199@@ -499,7 +504,7 @@
200 """Return the current preview object."""
201 return self.content.get_current_preview()
202 preview_initiate_count_
203-
204+
205 @property
206 def preview_initiate_count(self):
207 """Return the number of initiated previews since opened."""
208
209=== modified file 'tests/autopilot/unity/emulators/hud.py'
210--- tests/autopilot/unity/emulators/hud.py 2012-07-12 20:30:50 +0000
211+++ tests/autopilot/unity/emulators/hud.py 2012-09-07 20:06:22 +0000
212@@ -103,6 +103,11 @@
213 return self.controller.hud_monitor
214
215 @property
216+ def ideal_monitor(self):
217+ """The target monitor for the Hud to appear on."""
218+ return self.controller.ideal_monitor
219+
220+ @property
221 def geometry(self):
222 return (self.controller.x, self.controller.y, self.controller.width, self.controller.height)
223
224
225=== modified file 'tests/autopilot/unity/tests/test_dash.py'
226--- tests/autopilot/unity/tests/test_dash.py 2012-08-27 20:15:13 +0000
227+++ tests/autopilot/unity/tests/test_dash.py 2012-09-07 20:06:22 +0000
228@@ -107,6 +107,22 @@
229 self.dash.reveal_application_lens()
230 self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens')))
231
232+ def test_dash_stays_on_same_monitor(self):
233+ """If the dash is opened, then the mouse is moved to another monitor and
234+ the keyboard is used. The Dash must not move to that monitor.
235+ """
236+
237+ if self.screen_geo.get_num_monitors() < 2:
238+ self.skip ("This test must be ran with more then 1 monitor.")
239+
240+ self.dash.ensure_visible()
241+ self.addCleanup(self.dash.ensure_hidden)
242+
243+ self.screen_geo.move_mouse_to_monitor(1)
244+ self.keyboard.type("abc")
245+
246+ self.assertThat(self.dash.ideal_monitor, Eventually(Equals(0)))
247+
248
249 class DashSearchInputTests(DashTestCase):
250 """Test features involving input to the dash search"""
251@@ -205,25 +221,25 @@
252
253 # lensbar should lose focus after activation.
254 self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
255-
256+
257 def test_focus_returns_to_searchbar(self):
258 """This test makes sure that the focus is returned to the searchbar of the newly
259 activated lens."""
260 self.dash.ensure_visible()
261-
262+
263 for i in range(self.dash.get_num_rows()):
264 self.keyboard.press_and_release("Down")
265 self.keyboard.press_and_release("Right")
266 lensbar = self.dash.view.get_lensbar()
267 focused_icon = lensbar.focused_lens_icon
268 self.keyboard.press_and_release("Enter")
269-
270+
271 self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon)))
272 self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
273-
274+
275 # Now we make sure if the newly activated lens searchbar have the focus.
276 self.keyboard.type("HasFocus")
277-
278+
279 self.assertThat(self.dash.search_string, Eventually(Equals("HasFocus")))
280
281 def test_category_header_keynav(self):
282@@ -397,7 +413,7 @@
283 self.keyboard.press_and_release("Ctrl+v")
284
285 self.assertThat(self.dash.search_string, Eventually(Equals('CutPasteCutPaste')))
286-
287+
288 def test_middle_click_paste(self):
289 """Tests if Middle mouse button pastes into searchbar"""
290
291@@ -610,13 +626,13 @@
292
293
294 class PreviewInvocationTests(DashTestCase):
295- """Tests that dash previews can be opened and closed in different
296+ """Tests that dash previews can be opened and closed in different
297 lenses.
298
299 """
300-
301+
302 def test_app_lens_preview_open_close(self):
303- """Right-clicking on an application lens result must show
304+ """Right-clicking on an application lens result must show
305 its preview.
306
307 """
308@@ -666,7 +682,7 @@
309 # of failing.
310 if category is None:
311 self.skipTest("This lens is probably empty")
312-
313+
314 results = category.get_results()
315
316 result = results[0]
317@@ -694,7 +710,7 @@
318 category = lens.get_category_by_name("Online")
319 if category is None:
320 self.skipTest("This lens is probably empty")
321-
322+
323 results = category.get_results()
324
325 result = results[0]
326
327=== modified file 'tests/autopilot/unity/tests/test_hud.py'
328--- tests/autopilot/unity/tests/test_hud.py 2012-09-04 16:34:47 +0000
329+++ tests/autopilot/unity/tests/test_hud.py 2012-09-07 20:06:22 +0000
330@@ -357,9 +357,25 @@
331
332 self.assertThat(self.hud.visible, Eventually(Equals(False)))
333
334+ def test_hud_stays_on_same_monitor(self):
335+ """If the hud is opened, then the mouse is moved to another monitor and
336+ the keyboard is used. The hud must not move to that monitor.
337+ """
338+
339+ if self.screen_geo.get_num_monitors() < 2:
340+ self.skip ("This test must be ran with more then 1 monitor.")
341+
342+ self.hud.ensure_visible()
343+ self.addCleanup(self.hud.ensure_hidden)
344+
345+ self.screen_geo.move_mouse_to_monitor(1)
346+ self.keyboard.type("abc")
347+
348+ self.assertThat(self.hud.ideal_monitor, Eventually(Equals(0)))
349+
350 def test_mouse_changes_selected_hud_button(self):
351 """This tests moves the mouse from the top of the screen to the bottom, this must
352- change the selected button from 1 to 5.
353+ change the selected button from 1 to 5.
354 """
355
356 self.hud.ensure_visible()
357@@ -375,7 +391,7 @@
358
359 def test_keyboard_steals_focus_from_mouse(self):
360 """This tests moves the mouse from the top of the screen to the bottom,
361- then it presses the keyboard up 5 times, this must change the selected button from 5 to 1.
362+ then it presses the keyboard up 5 times, this must change the selected button from 5 to 1.
363 """
364
365 self.hud.ensure_visible()