Merge lp:~brandontschaefer/unity/lp.1215630 into lp:unity

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~brandontschaefer/unity/lp.1215630
Merge into: lp:unity
Diff against target: 213 lines (+86/-23)
4 files modified
launcher/SwitcherView.cpp (+23/-4)
launcher/SwitcherView.h (+2/-0)
tests/autopilot/unity/emulators/switcher.py (+19/-0)
tests/autopilot/unity/tests/test_switcher.py (+42/-19)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1215630
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend Needs Information
Review via email: mp+181925@code.launchpad.net

Commit message

Only change the selection of the icon if the delta x/y is greater then 3 (either direction).

Description of the change

Only change the selection of the icon if the delta x/y is greater then 3 (either direction).

This does mean you could slowly move across an icon without it changing.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Works as intended, but a couple of things.

- I'm wondering why you switched the const and var type in the constant variable declarations. Seems easier to read with const placed first.
- Also, is it possible to have an AP test for testing a slight mouse bump (not sure if it is)?

review: Needs Information
3479. By Brandon Schaefer

* On the first time the switcher view is opened, check if the mouse is over an icon.
  if so ignore it until it enters a new icon.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
3480. By Brandon Schaefer

* Clean up switcher mouse ap test
* Add new AP test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

The approach seems fine to me, but this would lead to checking the mouse pointer on start whether there's a mouse movement or not, and it does that in sync way (blame Xorg!)... So why not just using something like this instead: http://pastebin.ubuntu.com/6055505/ ?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Thats a way better solution... Ill get to this tomorrow (as I shouldn't be checking my email ;).

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Unmerged revisions

3480. By Brandon Schaefer

* Clean up switcher mouse ap test
* Add new AP test

3479. By Brandon Schaefer

* On the first time the switcher view is opened, check if the mouse is over an icon.
  if so ignore it until it enters a new icon.

3478. By Brandon Schaefer

* If the mouse move delta x/y is to small, ignore that event. Dont
  want accidental bumping to cause unwanted selection changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/SwitcherView.cpp'
--- launcher/SwitcherView.cpp 2013-08-09 17:51:06 +0000
+++ launcher/SwitcherView.cpp 2013-08-31 01:29:50 +0000
@@ -36,9 +36,9 @@
3636
37namespace37namespace
38{38{
39 const unsigned int VERTICAL_PADDING = 45;39 unsigned int const VERTICAL_PADDING = 45;
40 const unsigned int SPREAD_OFFSET = 100;40 unsigned int const SPREAD_OFFSET = 100;
41 const unsigned int EXTRA_ICON_SPACE = 10;41 unsigned int const EXTRA_ICON_SPACE = 10;
42}42}
4343
44NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);44NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);
@@ -61,6 +61,7 @@
61 , last_icon_selected_(-1)61 , last_icon_selected_(-1)
62 , last_detail_icon_selected_(-1)62 , last_detail_icon_selected_(-1)
63 , target_sizes_set_(false)63 , target_sizes_set_(false)
64 , check_mouse_first_time_(true)
64{65{
65 icon_renderer_->pip_style = OVER_TILE;66 icon_renderer_->pip_style = OVER_TILE;
66 icon_renderer_->monitor = monitors::MAX;67 icon_renderer_->monitor = monitors::MAX;
@@ -114,6 +115,7 @@
114 .add("animation-length", animation_length)115 .add("animation-length", animation_length)
115 .add("spread-size", (float)spread_size)116 .add("spread-size", (float)spread_size)
116 .add("label", text_view_->GetText())117 .add("label", text_view_->GetText())
118 .add("last_icon_selected", last_icon_selected_)
117 .add("spread_offset", SPREAD_OFFSET)119 .add("spread_offset", SPREAD_OFFSET)
118 .add("label_visible", text_view_->IsVisible());120 .add("label_visible", text_view_->IsVisible());
119}121}
@@ -232,7 +234,7 @@
232 return {geo.x + x, geo.y + y};234 return {geo.x + x, geo.y + y};
233}235}
234236
235void SwitcherView::RecvMouseMove(int x, int y, int /*dx*/, int /*dy*/, unsigned long /*button_flags*/, unsigned long /*key_flags*/)237void SwitcherView::RecvMouseMove(int x, int y, int dx, int dy, unsigned long /*button_flags*/, unsigned long /*key_flags*/)
236{238{
237 if (model_->detail_selection)239 if (model_->detail_selection)
238 {240 {
@@ -773,6 +775,23 @@
773 last_background_ = background_geo;775 last_background_ = background_geo;
774776
775 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());777 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());
778
779 if (check_mouse_first_time_)
780 {
781 CheckMouseInsideIconOnStart();
782 }
783}
784
785void SwitcherView::CheckMouseInsideIconOnStart()
786{
787 int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
788 nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor);
789
790 nux::Point const& screen_pt = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
791 nux::Point const& pt = {screen_pt.x - geo.x, screen_pt.y - geo.y};
792
793 last_icon_selected_ = IconIndexAt(pt.x - SPREAD_OFFSET, pt.y - SPREAD_OFFSET);
794 check_mouse_first_time_ = false;
776}795}
777796
778nux::Geometry SwitcherView::GetBackgroundGeometry()797nux::Geometry SwitcherView::GetBackgroundGeometry()
779798
=== modified file 'launcher/SwitcherView.h'
--- launcher/SwitcherView.h 2013-08-09 17:51:06 +0000
+++ launcher/SwitcherView.h 2013-08-31 01:29:50 +0000
@@ -141,6 +141,7 @@
141 void SaveLast();141 void SaveLast();
142142
143 bool CheckMouseInsideBackground(int x, int y) const;143 bool CheckMouseInsideBackground(int x, int y) const;
144 void CheckMouseInsideIconOnStart();
144145
145 SwitcherModel::Ptr model_;146 SwitcherModel::Ptr model_;
146 ui::LayoutSystem layout_system_;147 ui::LayoutSystem layout_system_;
@@ -150,6 +151,7 @@
150 int last_icon_selected_;151 int last_icon_selected_;
151 int last_detail_icon_selected_;152 int last_detail_icon_selected_;
152 bool target_sizes_set_;153 bool target_sizes_set_;
154 bool check_mouse_first_time_;
153155
154 std::list<ui::RenderArg> last_args_;156 std::list<ui::RenderArg> last_args_;
155 std::list<ui::RenderArg> saved_args_;157 std::list<ui::RenderArg> saved_args_;
156158
=== modified file 'tests/autopilot/unity/emulators/switcher.py'
--- tests/autopilot/unity/emulators/switcher.py 2013-07-17 21:54:34 +0000
+++ tests/autopilot/unity/emulators/switcher.py 2013-08-31 01:29:50 +0000
@@ -234,6 +234,10 @@
234class SwitcherView(UnityIntrospectionObject):234class SwitcherView(UnityIntrospectionObject):
235 """An emulator class for interacting with with SwitcherView."""235 """An emulator class for interacting with with SwitcherView."""
236236
237 def __init__(self, *args, **kwargs):
238 super(SwitcherView, self).__init__(*args, **kwargs)
239 self._mouse = Mouse.create()
240
237 @property241 @property
238 def icon_args(self):242 def icon_args(self):
239 return self.get_children_by_type(RenderArgs);243 return self.get_children_by_type(RenderArgs);
@@ -242,6 +246,21 @@
242 def detail_icons(self):246 def detail_icons(self):
243 return self.get_children_by_type(LayoutWindow);247 return self.get_children_by_type(LayoutWindow);
244248
249 def move_over_icon(self, index):
250 offset = self.spread_offset
251 icon_arg = self.icon_args[index]
252
253 x = icon_arg.logical_center_x + offset
254 y = icon_arg.logical_center_y + offset
255
256 self._mouse.move(x,y)
257
258 def move_over_detail_icon(self, index):
259 offset = self.spread_offset
260 x = self.detail_icons[index].x + offset
261 y = self.detail_icons[index].y + offset
262
263 self._mouse.move(x,y)
245264
246class RenderArgs(UnityIntrospectionObject):265class RenderArgs(UnityIntrospectionObject):
247 """An emulator class for interacting with the RenderArgs class."""266 """An emulator class for interacting with the RenderArgs class."""
248267
=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
--- tests/autopilot/unity/tests/test_switcher.py 2013-08-27 21:43:12 +0000
+++ tests/autopilot/unity/tests/test_switcher.py 2013-08-31 01:29:50 +0000
@@ -576,16 +576,49 @@
576 self.addCleanup(self.unity.switcher.terminate)576 self.addCleanup(self.unity.switcher.terminate)
577577
578 index = self.unity.switcher.selection_index578 index = self.unity.switcher.selection_index
579 offset = self.unity.switcher.view.spread_offset579 self.unity.switcher.view.move_over_icon(index);
580
581 icon_arg = self.unity.switcher.view.icon_args[index]
582 x = icon_arg.logical_center_x + offset
583 y = icon_arg.logical_center_y + offset
584 self.mouse.move(x, y)
585 self.mouse.click()580 self.mouse.click()
586581
587 self.assertProperty(char_win1, is_focused=True)582 self.assertProperty(char_win1, is_focused=True)
588583
584 def test_mouse_doesnt_hightlight_icon_if_over_on_start(self):
585 """
586 First start the launcher and move the mosue over position of Text Editor icon,
587 then close the switcher and open it again while moving the mouse a bit.
588 Asserting that the icon does lose focus from Character Map.
589 """
590
591 char_win1, char_win2 = self.start_applications("Character Map", "Text Editor")
592 self.assertVisibleWindowStack([char_win2, char_win1])
593 self.assertProperty(char_win1, is_focused=False)
594
595 self.unity.switcher.initiate()
596 self.addCleanup(self.unity.switcher.terminate)
597
598 mouse_index = self.unity.switcher.selection_index - 1
599
600 self.unity.switcher.view.move_over_icon(mouse_index);
601 # Assert we are over the icon we want to hover over.
602 self.assertThat(self.unity.switcher.view.last_icon_selected, Eventually(Equals(mouse_index)))
603
604 self.addCleanup(self.keybinding, "switcher/cancel")
605
606 self.unity.switcher.terminate()
607 self.unity.switcher.initiate()
608
609 index = self.unity.switcher.selection_index
610
611 pos = self.mouse.position()
612 self.mouse.move(pos[0] + 5, pos[1] + 5)
613
614 # Assert moving the mouse does not change the selection
615 self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(index)))
616
617 # Also nice to know clicking still works, even without selection
618 self.mouse.click()
619
620 self.assertProperty(char_win2, is_focused=True)
621
589 def test_mouse_highlights_switcher_deatil_icons_motion(self):622 def test_mouse_highlights_switcher_deatil_icons_motion(self):
590 """623 """
591 Gather the cords of all the detail icons, move the mouse through each624 Gather the cords of all the detail icons, move the mouse through each
@@ -597,15 +630,9 @@
597 self.unity.switcher.initiate(SwitcherMode.DETAIL)630 self.unity.switcher.initiate(SwitcherMode.DETAIL)
598 self.addCleanup(self.unity.switcher.terminate)631 self.addCleanup(self.unity.switcher.terminate)
599632
600 offset = self.unity.switcher.view.spread_offset633 index = 0;
601 cords = []
602
603 for icon in self.unity.switcher.view.detail_icons:634 for icon in self.unity.switcher.view.detail_icons:
604 cords.append((icon.x + offset, icon.y + offset))635 self.unity.switcher.view.move_over_detail_icon(index)
605
606 index = 0;
607 for cord in cords:
608 self.mouse.move(cord[0], cord[1])
609 self.assertThat(index, Equals(self.unity.switcher.detail_selection_index))636 self.assertThat(index, Equals(self.unity.switcher.detail_selection_index))
610 index += 1637 index += 1
611638
@@ -621,11 +648,7 @@
621 self.unity.switcher.initiate(SwitcherMode.DETAIL)648 self.unity.switcher.initiate(SwitcherMode.DETAIL)
622 self.addCleanup(self.unity.switcher.terminate)649 self.addCleanup(self.unity.switcher.terminate)
623650
624 offset = self.unity.switcher.view.spread_offset651 self.unity.switcher.view.move_over_detail_icon(0);
625 x = self.unity.switcher.view.detail_icons[0].x + offset
626 y = self.unity.switcher.view.detail_icons[0].y + offset
627
628 self.mouse.move(x,y)
629 self.mouse.click()652 self.mouse.click()
630653
631 self.assertProperty(char_win1, is_focused=True)654 self.assertProperty(char_win1, is_focused=True)