Merge lp:~azzar1/unity/fix-754565-5.0 into lp:unity/5.0

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2390
Proposed branch: lp:~azzar1/unity/fix-754565-5.0
Merge into: lp:unity/5.0
Diff against target: 198 lines (+60/-29)
7 files modified
plugins/unityshell/src/AbstractLauncherIcon.h (+3/-3)
plugins/unityshell/src/Launcher.cpp (+5/-4)
plugins/unityshell/src/LauncherIcon.cpp (+8/-5)
plugins/unityshell/src/LauncherIcon.h (+5/-5)
plugins/unityshell/src/SimpleLauncherIcon.cpp (+9/-9)
plugins/unityshell/src/SimpleLauncherIcon.h (+4/-3)
tests/autopilot/autopilot/tests/test_launcher.py (+26/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-754565-5.0
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+115122@code.launchpad.net

Commit message

Description of the change

== Problem ==
Shift+Click on a launcher icon should open a new instance of the application.

== Fix ==
Backport fix

== Test ==
Backported test too. Please test it, ap doesn't work on my system.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Good for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
2--- plugins/unityshell/src/AbstractLauncherIcon.h 2012-04-26 23:27:17 +0000
3+++ plugins/unityshell/src/AbstractLauncherIcon.h 2012-07-16 14:01:42 +0000
4@@ -210,9 +210,9 @@
5
6 virtual void UnStick() = 0;
7
8- sigc::signal<void, int, int> mouse_down;
9- sigc::signal<void, int, int> mouse_up;
10- sigc::signal<void, int, int> mouse_click;
11+ sigc::signal<void, int, unsigned long, int> mouse_down;
12+ sigc::signal<void, int, unsigned long, int> mouse_up;
13+ sigc::signal<void, int, unsigned long, int> mouse_click;
14 sigc::signal<void, int> mouse_enter;
15 sigc::signal<void, int> mouse_leave;
16
17
18=== modified file 'plugins/unityshell/src/Launcher.cpp'
19--- plugins/unityshell/src/Launcher.cpp 2012-07-13 15:19:42 +0000
20+++ plugins/unityshell/src/Launcher.cpp 2012-07-16 14:01:42 +0000
21@@ -2590,7 +2590,7 @@
22 g_source_remove(_start_dragicon_handle);
23 _start_dragicon_handle = g_timeout_add(START_DRAGICON_DURATION, &Launcher::StartIconDragTimeout, this);
24
25- launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), monitor);
26+ launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), key_flags, monitor);
27 }
28 }
29
30@@ -2606,19 +2606,20 @@
31
32 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
33 {
34- _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags), monitor);
35+ _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags), key_flags, monitor);
36
37 if (GetActionState() == ACTION_NONE)
38 {
39+
40 /* This will inform the icon if the action is valid for all the monitors */
41 int action_monitor = options()->show_for_all ? -1 : monitor;
42- _icon_mouse_down->mouse_click.emit(nux::GetEventButton(button_flags), action_monitor);
43+ _icon_mouse_down->mouse_click.emit(nux::GetEventButton(button_flags), key_flags, action_monitor);
44 }
45 }
46
47 if (launcher_icon && (_icon_mouse_down != launcher_icon))
48 {
49- launcher_icon->mouse_up.emit(nux::GetEventButton(button_flags), monitor);
50+ launcher_icon->mouse_up.emit(nux::GetEventButton(button_flags), key_flags, monitor);
51 }
52
53 if (GetActionState() == ACTION_DRAG_LAUNCHER)
54
55=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
56--- plugins/unityshell/src/LauncherIcon.cpp 2012-04-26 23:27:17 +0000
57+++ plugins/unityshell/src/LauncherIcon.cpp 2012-07-16 14:01:42 +0000
58@@ -630,13 +630,13 @@
59 return true;
60 }
61
62-void LauncherIcon::RecvMouseDown(int button, int monitor)
63+void LauncherIcon::RecvMouseDown(int button, unsigned long key_flags, int monitor)
64 {
65 if (button == 3)
66 OpenQuicklist();
67 }
68
69-void LauncherIcon::RecvMouseUp(int button, int monitor)
70+void LauncherIcon::RecvMouseUp(int button, unsigned long key_flags, int monitor)
71 {
72 if (button == 3)
73 {
74@@ -645,14 +645,17 @@
75 }
76 }
77
78-void LauncherIcon::RecvMouseClick(int button, int monitor)
79+void LauncherIcon::RecvMouseClick(int button, unsigned long key_flags, int monitor)
80 {
81 ActionArg arg(ActionArg::LAUNCHER, button);
82 arg.monitor = monitor;
83+ bool shift_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_SHIFT);
84
85- if (button == 1)
86+ // Click without shift
87+ if (button == 1 && !shift_pressed)
88 Activate(arg);
89- else if (button == 2)
90+ // Middle click or click with shift
91+ else if ((button == 2) || (button == 1 && shift_pressed))
92 OpenInstance(arg);
93 }
94
95
96=== modified file 'plugins/unityshell/src/LauncherIcon.h'
97--- plugins/unityshell/src/LauncherIcon.h 2012-04-26 23:27:17 +0000
98+++ plugins/unityshell/src/LauncherIcon.h 2012-07-16 14:01:42 +0000
99@@ -76,11 +76,11 @@
100
101 void RecvMouseLeave(int monitor);
102
103- void RecvMouseDown(int button, int monitor);
104-
105- void RecvMouseUp(int button, int monitor);
106-
107- void RecvMouseClick(int button, int monitor);
108+ void RecvMouseDown(int button, unsigned long key_flags, int monitor);
109+
110+ void RecvMouseUp(int button, unsigned long key_flags, int monitor);
111+
112+ void RecvMouseClick(int button, unsigned long key_flags, int monitor);
113
114 void HideTooltip();
115
116
117=== modified file 'plugins/unityshell/src/SimpleLauncherIcon.cpp'
118--- plugins/unityshell/src/SimpleLauncherIcon.cpp 2012-03-25 22:52:20 +0000
119+++ plugins/unityshell/src/SimpleLauncherIcon.cpp 2012-07-16 14:01:42 +0000
120@@ -69,15 +69,15 @@
121 g_signal_handler_disconnect(gtk_icon_theme_get_default(), theme_changed_id_);
122 }
123
124-void SimpleLauncherIcon::OnMouseDown(int button, int monitor)
125-{
126-}
127-
128-void SimpleLauncherIcon::OnMouseUp(int button, int monitor)
129-{
130-}
131-
132-void SimpleLauncherIcon::OnMouseClick(int button, int monitor)
133+void SimpleLauncherIcon::OnMouseDown(int button, unsigned long key_flags, int monitor)
134+{
135+}
136+
137+void SimpleLauncherIcon::OnMouseUp(int button, unsigned long key_flags, int monitor)
138+{
139+}
140+
141+void SimpleLauncherIcon::OnMouseClick(int button, unsigned long key_flags, int monitor)
142 {
143 }
144
145
146=== modified file 'plugins/unityshell/src/SimpleLauncherIcon.h'
147--- plugins/unityshell/src/SimpleLauncherIcon.h 2012-03-25 22:52:20 +0000
148+++ plugins/unityshell/src/SimpleLauncherIcon.h 2012-07-16 14:01:42 +0000
149@@ -49,11 +49,12 @@
150 std::string GetName() const;
151 void AddProperties(GVariantBuilder* builder);
152
153- virtual void OnMouseDown(int button, int monitor);
154- virtual void OnMouseUp(int button, int monitor);
155- virtual void OnMouseClick(int button, int monitor);
156+ virtual void OnMouseDown(int button, unsigned long key_flags, int monitor);
157+ virtual void OnMouseUp(int button, unsigned long key_flags, int monitor);
158+ virtual void OnMouseClick(int button, unsigned long key_flags, int monitor);
159 virtual void OnMouseEnter(int monitor);
160 virtual void OnMouseLeave(int monitor);
161+
162 virtual void ActivateLauncherIcon(ActionArg arg);
163
164 private:
165
166=== modified file 'tests/autopilot/autopilot/tests/test_launcher.py'
167--- tests/autopilot/autopilot/tests/test_launcher.py 2012-06-29 23:36:10 +0000
168+++ tests/autopilot/autopilot/tests/test_launcher.py 2012-07-16 14:01:42 +0000
169@@ -900,3 +900,29 @@
170 self.mouse.move(bfb.center_x, bfb.center_y)
171
172 self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False)))
173+
174+class LauncherIconTests(UnityTestCase):
175+ """Tests for the launcher icons."""
176+
177+ def assertNumberWinsIsEventually(self, app, num):
178+ """Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds."""
179+ for i in range(10):
180+ wins = app.get_windows()
181+ if len(wins) == num:
182+ return
183+ sleep(1)
184+
185+ self.assertThat(len(app.get_windows()), Equals(num))
186+
187+ def test_shift_click_opens_new_application_instance(self):
188+ """Shift+Clicking MUST open a new instance of an already-running application."""
189+ app = self.start_app("Calculator")
190+ desktop_id = app.desktop_file
191+ icon = self.launcher.model.get_icon_by_desktop_id(desktop_id)
192+ launcher_instance = self.launcher.get_launcher_for_monitor(0)
193+
194+ self.keyboard.press("Shift")
195+ self.addCleanup(self.keyboard.release, "Shift")
196+ launcher_instance.click_launcher_icon(icon)
197+
198+ self.assertNumberWinsIsEventually(app, 2)

Subscribers

People subscribed via source and target branches

to all changes: