Merge lp:~brandontschaefer/unity/ql-right-click-fixes into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2555
Proposed branch: lp:~brandontschaefer/unity/ql-right-click-fixes
Merge into: lp:unity
Diff against target: 119 lines (+56/-1)
3 files modified
launcher/LauncherIcon.cpp (+16/-1)
launcher/LauncherIcon.h (+2/-0)
tests/autopilot/unity/tests/test_quicklist.py (+38/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/ql-right-click-fixes
Reviewer Review Type Date Requested Status
Thomi Richards (community) quality Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+117369@code.launchpad.net

Commit message

Right clicking a launcher icon will open its quicklist even if a quicklist is already open.

Description of the change

=== Problem ===
If you right click a launcher icon, then right click another launcher icon it will not open that quicklist.

=== Fix ===
Instead of opening the quicklist on mouse pressed, open it on mouse released. So when a click outside of the quicklist happens that event can activate the quicklist.

=== Test ===
AP test

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

After fixing the multimonitor issue, +1 from me ;)

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/983/console reported an error when processing this lp:~brandontschaefer/unity/ql-right-click-fixes branch.
Not merging it.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Oh, noticed that clicking again on a ql causes it to be closed and re-opened. It should stay.

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Another thing... I think we shouldn't change the behavior of the click, so the quicklist should be always be opened on mouse-down, not on mouse-up.

At this point you should probably refactor the quicklist and the manager, so that QuicklistView::RecvMouseDownOutsideOfQuicklist won't always hide a quicklist, but we'll hide it only if the clicked area there's not a "quicklist owner".

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This solution is better, just one thing:

Use OpenQuicklist(false, monitor); or it won't work in multi-monitor setup.

The _open_quicklist is a little bit confusing, since it seems to indicate that the quicklist is currently open, while it 's actually used allow a quicklist to open... Probably inverting the logic could be better.

72 - mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseDownOutsideOfQuicklist));

Mhmh... Maybe it's better not to remove this as well, I'd just Hide the quicklist in QuicklistView, and I'd connect to the same signal on LauncherIcon to set the value you need...

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Nice, approved!

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1018/console reported an error when processing this lp:~brandontschaefer/unity/ql-right-click-fixes branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve (quality)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherIcon.cpp'
2--- launcher/LauncherIcon.cpp 2012-08-02 11:30:02 +0000
3+++ launcher/LauncherIcon.cpp 2012-08-13 17:23:38 +0000
4@@ -87,6 +87,7 @@
5 , _last_stable(max_num_monitors)
6 , _parent_geo(max_num_monitors)
7 , _saved_center(max_num_monitors)
8+ , _allow_quicklist_to_show(true)
9 {
10 for (unsigned i = 0; i < unsigned(Quirk::LAST); i++)
11 {
12@@ -153,6 +154,11 @@
13 _quicklist = new QuicklistView();
14 AddChild(_quicklist.GetPointer());
15
16+ _quicklist->mouse_down_outside_pointer_grab_area.connect([&] (int x, int y, unsigned long button_flags, unsigned long key_flags)
17+ {
18+ _allow_quicklist_to_show = false;
19+ });
20+
21 QuicklistManager::Default()->RegisterQuicklist(_quicklist.GetPointer());
22 }
23
24@@ -532,6 +538,7 @@
25 void LauncherIcon::RecvMouseLeave(int monitor)
26 {
27 _last_monitor = -1;
28+ _allow_quicklist_to_show = true;
29
30 if (_tooltip)
31 _tooltip->ShowWindow(false);
32@@ -624,16 +631,24 @@
33 void LauncherIcon::RecvMouseDown(int button, int monitor, unsigned long key_flags)
34 {
35 if (button == 3)
36- OpenQuicklist();
37+ OpenQuicklist(false, monitor);
38 }
39
40 void LauncherIcon::RecvMouseUp(int button, int monitor, unsigned long key_flags)
41 {
42 if (button == 3)
43 {
44+ if (_allow_quicklist_to_show)
45+ {
46+ OpenQuicklist(false, monitor);
47+ }
48+
49 if (_quicklist && _quicklist->IsVisible())
50+ {
51 _quicklist->CaptureMouseDownAnyWhereElse(true);
52+ }
53 }
54+ _allow_quicklist_to_show = true;
55 }
56
57 void LauncherIcon::RecvMouseClick(int button, int monitor, unsigned long key_flags)
58
59=== modified file 'launcher/LauncherIcon.h'
60--- launcher/LauncherIcon.h 2012-08-02 11:30:02 +0000
61+++ launcher/LauncherIcon.h 2012-08-13 17:23:38 +0000
62@@ -339,6 +339,8 @@
63 bool _quirks[unsigned(Quirk::LAST)];
64 struct timespec _quirk_times[unsigned(Quirk::LAST)];
65
66+ bool _allow_quicklist_to_show;
67+
68 std::list<LauncherEntryRemote::Ptr> _entry_list;
69
70 protected:
71
72=== modified file 'tests/autopilot/unity/tests/test_quicklist.py'
73--- tests/autopilot/unity/tests/test_quicklist.py 2012-08-09 01:37:02 +0000
74+++ tests/autopilot/unity/tests/test_quicklist.py 2012-08-13 17:23:38 +0000
75@@ -155,6 +155,44 @@
76 self.addCleanup(self.dash.ensure_hidden)
77 self.assertThat(self.dash.visible, Eventually(Equals(True)))
78
79+ def test_right_click_opens_quicklist_if_already_open(self):
80+ """A right click to another icon in the launcher must
81+ close the current open quicklist and open the other
82+ icons quicklist.
83+ lp:890991
84+ """
85+
86+ calc_win = self.start_app_window("Calculator")
87+ mahj_win = self.start_app_window("Mahjongg")
88+
89+ calc_icon = self.launcher.model.get_icon(
90+ desktop_id=calc_win.application.desktop_file)
91+ mahj_icon = self.launcher.model.get_icon(
92+ desktop_id=mahj_win.application.desktop_file)
93+
94+ calc_ql = self.open_quicklist_for_icon(calc_icon)
95+ self.assertThat(calc_ql.active, Eventually(Equals(True)))
96+
97+ mahj_ql = self.open_quicklist_for_icon(mahj_icon)
98+ self.assertThat(mahj_ql.active, Eventually(Equals(True)))
99+ self.assertThat(calc_ql.active, Eventually(Equals(False)))
100+
101+ def test_right_clicking_same_icon_doesnt_reopen_ql(self):
102+ """A right click to the same icon in the launcher must
103+ not re-open the quicklist if already open. It must hide.
104+ """
105+
106+ calc_win = self.start_app_window("Calculator")
107+
108+ calc_icon = self.launcher.model.get_icon(
109+ desktop_id=calc_win.application.desktop_file)
110+
111+ calc_ql = self.open_quicklist_for_icon(calc_icon)
112+ self.assertThat(calc_ql.active, Eventually(Equals(True)))
113+
114+ calc_ql = self.open_quicklist_for_icon(calc_icon)
115+ self.assertThat(calc_ql.active, Eventually(Equals(False)))
116+
117
118 class QuicklistKeyNavigationTests(UnityTestCase):
119 """Tests for the quicklist key navigation."""