Merge lp:~brandontschaefer/unity/lp-1215630-fix-v2 into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3491
Proposed branch: lp:~brandontschaefer/unity/lp-1215630-fix-v2
Merge into: lp:unity
Diff against target: 186 lines (+74/-22)
4 files modified
launcher/SwitcherView.cpp (+12/-3)
launcher/SwitcherView.h (+1/-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-fix-v2
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+184144@code.launchpad.net

Commit message

Ignore mouse movements if the mouse starts over a switcher icon. Clicking still works fine, we just wont steal focus from the alt+tab work.

Description of the change

Ignore mouse movements if the mouse starts over a switcher icon. Clicking still works fine, we just wont steal focus from the alt+tab work.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherView.cpp'
2--- launcher/SwitcherView.cpp 2013-08-09 17:51:06 +0000
3+++ launcher/SwitcherView.cpp 2013-09-05 18:13:04 +0000
4@@ -36,9 +36,9 @@
5
6 namespace
7 {
8- const unsigned int VERTICAL_PADDING = 45;
9- const unsigned int SPREAD_OFFSET = 100;
10- const unsigned int EXTRA_ICON_SPACE = 10;
11+ unsigned int const VERTICAL_PADDING = 45;
12+ unsigned int const SPREAD_OFFSET = 100;
13+ unsigned int const EXTRA_ICON_SPACE = 10;
14 }
15
16 NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);
17@@ -61,6 +61,7 @@
18 , last_icon_selected_(-1)
19 , last_detail_icon_selected_(-1)
20 , target_sizes_set_(false)
21+ , check_mouse_first_time_(true)
22 {
23 icon_renderer_->pip_style = OVER_TILE;
24 icon_renderer_->monitor = monitors::MAX;
25@@ -114,6 +115,7 @@
26 .add("animation-length", animation_length)
27 .add("spread-size", (float)spread_size)
28 .add("label", text_view_->GetText())
29+ .add("last_icon_selected", last_icon_selected_)
30 .add("spread_offset", SPREAD_OFFSET)
31 .add("label_visible", text_view_->IsVisible());
32 }
33@@ -260,6 +262,13 @@
34 {
35 int icon_index = IconIndexAt(x, y);
36
37+ if (check_mouse_first_time_)
38+ {
39+ last_icon_selected_ = icon_index;
40+ check_mouse_first_time_ = false;
41+ return;
42+ }
43+
44 if (icon_index >= 0)
45 {
46 if (icon_index != last_icon_selected_)
47
48=== modified file 'launcher/SwitcherView.h'
49--- launcher/SwitcherView.h 2013-08-09 17:51:06 +0000
50+++ launcher/SwitcherView.h 2013-09-05 18:13:04 +0000
51@@ -150,6 +150,7 @@
52 int last_icon_selected_;
53 int last_detail_icon_selected_;
54 bool target_sizes_set_;
55+ bool check_mouse_first_time_;
56
57 std::list<ui::RenderArg> last_args_;
58 std::list<ui::RenderArg> saved_args_;
59
60=== modified file 'tests/autopilot/unity/emulators/switcher.py'
61--- tests/autopilot/unity/emulators/switcher.py 2013-07-17 21:54:34 +0000
62+++ tests/autopilot/unity/emulators/switcher.py 2013-09-05 18:13:04 +0000
63@@ -234,6 +234,10 @@
64 class SwitcherView(UnityIntrospectionObject):
65 """An emulator class for interacting with with SwitcherView."""
66
67+ def __init__(self, *args, **kwargs):
68+ super(SwitcherView, self).__init__(*args, **kwargs)
69+ self._mouse = Mouse.create()
70+
71 @property
72 def icon_args(self):
73 return self.get_children_by_type(RenderArgs);
74@@ -242,6 +246,21 @@
75 def detail_icons(self):
76 return self.get_children_by_type(LayoutWindow);
77
78+ def move_over_icon(self, index):
79+ offset = self.spread_offset
80+ icon_arg = self.icon_args[index]
81+
82+ x = icon_arg.logical_center_x + offset
83+ y = icon_arg.logical_center_y + offset
84+
85+ self._mouse.move(x,y)
86+
87+ def move_over_detail_icon(self, index):
88+ offset = self.spread_offset
89+ x = self.detail_icons[index].x + offset
90+ y = self.detail_icons[index].y + offset
91+
92+ self._mouse.move(x,y)
93
94 class RenderArgs(UnityIntrospectionObject):
95 """An emulator class for interacting with the RenderArgs class."""
96
97=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
98--- tests/autopilot/unity/tests/test_switcher.py 2013-08-27 21:43:12 +0000
99+++ tests/autopilot/unity/tests/test_switcher.py 2013-09-05 18:13:04 +0000
100@@ -576,16 +576,49 @@
101 self.addCleanup(self.unity.switcher.terminate)
102
103 index = self.unity.switcher.selection_index
104- offset = self.unity.switcher.view.spread_offset
105-
106- icon_arg = self.unity.switcher.view.icon_args[index]
107- x = icon_arg.logical_center_x + offset
108- y = icon_arg.logical_center_y + offset
109- self.mouse.move(x, y)
110+ self.unity.switcher.view.move_over_icon(index);
111 self.mouse.click()
112
113 self.assertProperty(char_win1, is_focused=True)
114
115+ def test_mouse_doesnt_hightlight_icon_if_over_on_start(self):
116+ """
117+ First start the launcher and move the mosue over position of Text Editor icon,
118+ then close the switcher and open it again while moving the mouse a bit.
119+ Asserting that the icon does lose focus from Character Map.
120+ """
121+
122+ char_win1, char_win2 = self.start_applications("Character Map", "Text Editor")
123+ self.assertVisibleWindowStack([char_win2, char_win1])
124+ self.assertProperty(char_win1, is_focused=False)
125+
126+ self.unity.switcher.initiate()
127+ self.addCleanup(self.unity.switcher.terminate)
128+
129+ mouse_index = self.unity.switcher.selection_index - 1
130+
131+ self.unity.switcher.view.move_over_icon(mouse_index);
132+ # Assert we are over the icon we want to hover over.
133+ self.assertThat(self.unity.switcher.view.last_icon_selected, Eventually(Equals(mouse_index)))
134+
135+ self.addCleanup(self.keybinding, "switcher/cancel")
136+
137+ self.unity.switcher.terminate()
138+ self.unity.switcher.initiate()
139+
140+ index = self.unity.switcher.selection_index
141+
142+ pos = self.mouse.position()
143+ self.mouse.move(pos[0] + 5, pos[1] + 5)
144+
145+ # Assert moving the mouse does not change the selection
146+ self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(index)))
147+
148+ # Also nice to know clicking still works, even without selection
149+ self.mouse.click()
150+
151+ self.assertProperty(char_win2, is_focused=True)
152+
153 def test_mouse_highlights_switcher_deatil_icons_motion(self):
154 """
155 Gather the cords of all the detail icons, move the mouse through each
156@@ -597,15 +630,9 @@
157 self.unity.switcher.initiate(SwitcherMode.DETAIL)
158 self.addCleanup(self.unity.switcher.terminate)
159
160- offset = self.unity.switcher.view.spread_offset
161- cords = []
162-
163+ index = 0;
164 for icon in self.unity.switcher.view.detail_icons:
165- cords.append((icon.x + offset, icon.y + offset))
166-
167- index = 0;
168- for cord in cords:
169- self.mouse.move(cord[0], cord[1])
170+ self.unity.switcher.view.move_over_detail_icon(index)
171 self.assertThat(index, Equals(self.unity.switcher.detail_selection_index))
172 index += 1
173
174@@ -621,11 +648,7 @@
175 self.unity.switcher.initiate(SwitcherMode.DETAIL)
176 self.addCleanup(self.unity.switcher.terminate)
177
178- offset = self.unity.switcher.view.spread_offset
179- x = self.unity.switcher.view.detail_icons[0].x + offset
180- y = self.unity.switcher.view.detail_icons[0].y + offset
181-
182- self.mouse.move(x,y)
183+ self.unity.switcher.view.move_over_detail_icon(0);
184 self.mouse.click()
185
186 self.assertProperty(char_win1, is_focused=True)