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
=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
--- plugins/unityshell/src/AbstractLauncherIcon.h 2012-04-26 23:27:17 +0000
+++ plugins/unityshell/src/AbstractLauncherIcon.h 2012-07-16 14:01:42 +0000
@@ -210,9 +210,9 @@
210 210
211 virtual void UnStick() = 0;211 virtual void UnStick() = 0;
212212
213 sigc::signal<void, int, int> mouse_down;213 sigc::signal<void, int, unsigned long, int> mouse_down;
214 sigc::signal<void, int, int> mouse_up;214 sigc::signal<void, int, unsigned long, int> mouse_up;
215 sigc::signal<void, int, int> mouse_click;215 sigc::signal<void, int, unsigned long, int> mouse_click;
216 sigc::signal<void, int> mouse_enter;216 sigc::signal<void, int> mouse_enter;
217 sigc::signal<void, int> mouse_leave;217 sigc::signal<void, int> mouse_leave;
218218
219219
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2012-07-13 15:19:42 +0000
+++ plugins/unityshell/src/Launcher.cpp 2012-07-16 14:01:42 +0000
@@ -2590,7 +2590,7 @@
2590 g_source_remove(_start_dragicon_handle);2590 g_source_remove(_start_dragicon_handle);
2591 _start_dragicon_handle = g_timeout_add(START_DRAGICON_DURATION, &Launcher::StartIconDragTimeout, this);2591 _start_dragicon_handle = g_timeout_add(START_DRAGICON_DURATION, &Launcher::StartIconDragTimeout, this);
25922592
2593 launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), monitor);2593 launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), key_flags, monitor);
2594 }2594 }
2595}2595}
25962596
@@ -2606,19 +2606,20 @@
26062606
2607 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))2607 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
2608 {2608 {
2609 _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags), monitor);2609 _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags), key_flags, monitor);
26102610
2611 if (GetActionState() == ACTION_NONE)2611 if (GetActionState() == ACTION_NONE)
2612 {2612 {
2613
2613 /* This will inform the icon if the action is valid for all the monitors */2614 /* This will inform the icon if the action is valid for all the monitors */
2614 int action_monitor = options()->show_for_all ? -1 : monitor;2615 int action_monitor = options()->show_for_all ? -1 : monitor;
2615 _icon_mouse_down->mouse_click.emit(nux::GetEventButton(button_flags), action_monitor);2616 _icon_mouse_down->mouse_click.emit(nux::GetEventButton(button_flags), key_flags, action_monitor);
2616 }2617 }
2617 }2618 }
26182619
2619 if (launcher_icon && (_icon_mouse_down != launcher_icon))2620 if (launcher_icon && (_icon_mouse_down != launcher_icon))
2620 {2621 {
2621 launcher_icon->mouse_up.emit(nux::GetEventButton(button_flags), monitor);2622 launcher_icon->mouse_up.emit(nux::GetEventButton(button_flags), key_flags, monitor);
2622 }2623 }
26232624
2624 if (GetActionState() == ACTION_DRAG_LAUNCHER)2625 if (GetActionState() == ACTION_DRAG_LAUNCHER)
26252626
=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
--- plugins/unityshell/src/LauncherIcon.cpp 2012-04-26 23:27:17 +0000
+++ plugins/unityshell/src/LauncherIcon.cpp 2012-07-16 14:01:42 +0000
@@ -630,13 +630,13 @@
630 return true;630 return true;
631}631}
632632
633void LauncherIcon::RecvMouseDown(int button, int monitor)633void LauncherIcon::RecvMouseDown(int button, unsigned long key_flags, int monitor)
634{634{
635 if (button == 3)635 if (button == 3)
636 OpenQuicklist();636 OpenQuicklist();
637}637}
638638
639void LauncherIcon::RecvMouseUp(int button, int monitor)639void LauncherIcon::RecvMouseUp(int button, unsigned long key_flags, int monitor)
640{640{
641 if (button == 3)641 if (button == 3)
642 {642 {
@@ -645,14 +645,17 @@
645 }645 }
646}646}
647647
648void LauncherIcon::RecvMouseClick(int button, int monitor)648void LauncherIcon::RecvMouseClick(int button, unsigned long key_flags, int monitor)
649{649{
650 ActionArg arg(ActionArg::LAUNCHER, button);650 ActionArg arg(ActionArg::LAUNCHER, button);
651 arg.monitor = monitor;651 arg.monitor = monitor;
652 bool shift_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_SHIFT);
652653
653 if (button == 1)654 // Click without shift
655 if (button == 1 && !shift_pressed)
654 Activate(arg);656 Activate(arg);
655 else if (button == 2)657 // Middle click or click with shift
658 else if ((button == 2) || (button == 1 && shift_pressed))
656 OpenInstance(arg);659 OpenInstance(arg);
657}660}
658661
659662
=== modified file 'plugins/unityshell/src/LauncherIcon.h'
--- plugins/unityshell/src/LauncherIcon.h 2012-04-26 23:27:17 +0000
+++ plugins/unityshell/src/LauncherIcon.h 2012-07-16 14:01:42 +0000
@@ -76,11 +76,11 @@
7676
77 void RecvMouseLeave(int monitor);77 void RecvMouseLeave(int monitor);
7878
79 void RecvMouseDown(int button, int monitor);79 void RecvMouseDown(int button, unsigned long key_flags, int monitor);
8080
81 void RecvMouseUp(int button, int monitor);81 void RecvMouseUp(int button, unsigned long key_flags, int monitor);
8282
83 void RecvMouseClick(int button, int monitor);83 void RecvMouseClick(int button, unsigned long key_flags, int monitor);
8484
85 void HideTooltip();85 void HideTooltip();
8686
8787
=== modified file 'plugins/unityshell/src/SimpleLauncherIcon.cpp'
--- plugins/unityshell/src/SimpleLauncherIcon.cpp 2012-03-25 22:52:20 +0000
+++ plugins/unityshell/src/SimpleLauncherIcon.cpp 2012-07-16 14:01:42 +0000
@@ -69,15 +69,15 @@
69 g_signal_handler_disconnect(gtk_icon_theme_get_default(), theme_changed_id_);69 g_signal_handler_disconnect(gtk_icon_theme_get_default(), theme_changed_id_);
70}70}
7171
72void SimpleLauncherIcon::OnMouseDown(int button, int monitor)72void SimpleLauncherIcon::OnMouseDown(int button, unsigned long key_flags, int monitor)
73{73{
74}74}
7575
76void SimpleLauncherIcon::OnMouseUp(int button, int monitor)76void SimpleLauncherIcon::OnMouseUp(int button, unsigned long key_flags, int monitor)
77{77{
78}78}
7979
80void SimpleLauncherIcon::OnMouseClick(int button, int monitor)80void SimpleLauncherIcon::OnMouseClick(int button, unsigned long key_flags, int monitor)
81{81{
82}82}
8383
8484
=== modified file 'plugins/unityshell/src/SimpleLauncherIcon.h'
--- plugins/unityshell/src/SimpleLauncherIcon.h 2012-03-25 22:52:20 +0000
+++ plugins/unityshell/src/SimpleLauncherIcon.h 2012-07-16 14:01:42 +0000
@@ -49,11 +49,12 @@
49 std::string GetName() const;49 std::string GetName() const;
50 void AddProperties(GVariantBuilder* builder);50 void AddProperties(GVariantBuilder* builder);
5151
52 virtual void OnMouseDown(int button, int monitor);52 virtual void OnMouseDown(int button, unsigned long key_flags, int monitor);
53 virtual void OnMouseUp(int button, int monitor);53 virtual void OnMouseUp(int button, unsigned long key_flags, int monitor);
54 virtual void OnMouseClick(int button, int monitor);54 virtual void OnMouseClick(int button, unsigned long key_flags, int monitor);
55 virtual void OnMouseEnter(int monitor);55 virtual void OnMouseEnter(int monitor);
56 virtual void OnMouseLeave(int monitor);56 virtual void OnMouseLeave(int monitor);
57
57 virtual void ActivateLauncherIcon(ActionArg arg);58 virtual void ActivateLauncherIcon(ActionArg arg);
5859
59private:60private:
6061
=== modified file 'tests/autopilot/autopilot/tests/test_launcher.py'
--- tests/autopilot/autopilot/tests/test_launcher.py 2012-06-29 23:36:10 +0000
+++ tests/autopilot/autopilot/tests/test_launcher.py 2012-07-16 14:01:42 +0000
@@ -900,3 +900,29 @@
900 self.mouse.move(bfb.center_x, bfb.center_y)900 self.mouse.move(bfb.center_x, bfb.center_y)
901901
902 self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False)))902 self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False)))
903
904class LauncherIconTests(UnityTestCase):
905 """Tests for the launcher icons."""
906
907 def assertNumberWinsIsEventually(self, app, num):
908 """Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds."""
909 for i in range(10):
910 wins = app.get_windows()
911 if len(wins) == num:
912 return
913 sleep(1)
914
915 self.assertThat(len(app.get_windows()), Equals(num))
916
917 def test_shift_click_opens_new_application_instance(self):
918 """Shift+Clicking MUST open a new instance of an already-running application."""
919 app = self.start_app("Calculator")
920 desktop_id = app.desktop_file
921 icon = self.launcher.model.get_icon_by_desktop_id(desktop_id)
922 launcher_instance = self.launcher.get_launcher_for_monitor(0)
923
924 self.keyboard.press("Shift")
925 self.addCleanup(self.keyboard.release, "Shift")
926 launcher_instance.click_launcher_icon(icon)
927
928 self.assertNumberWinsIsEventually(app, 2)

Subscribers

People subscribed via source and target branches

to all changes: