Merge lp:~aacid/unity/launcher_selection_changed_fix_1067358_for_6.0 into lp:unity/6.0

Proposed by Albert Astals Cid on 2012-10-17
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-10-17
Approved revision: 2787
Merged at revision: 2789
Proposed branch: lp:~aacid/unity/launcher_selection_changed_fix_1067358_for_6.0
Merge into: lp:unity/6.0
Diff against target: 213 lines (+71/-11)
9 files modified
launcher/AbstractLauncherIcon.h (+1/-0)
launcher/LauncherController.cpp (+18/-6)
launcher/LauncherControllerPrivate.h (+2/-0)
launcher/LauncherIcon.cpp (+5/-0)
launcher/LauncherIcon.h (+1/-0)
launcher/MockLauncherIcon.h (+4/-0)
launcher/QuicklistView.cpp (+10/-5)
launcher/QuicklistView.h (+1/-0)
tests/test_launcher_controller.cpp (+29/-0)
To merge this branch: bzr merge lp:~aacid/unity/launcher_selection_changed_fix_1067358_for_6.0
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2012-10-17 Approve on 2012-10-17
Review via email: mp+130080@code.launchpad.net

Commit message

Update the UBUS_LAUNCHER_SELECTION_CHANGED on UBUS_QUICKLIST_END_KEY_NAV

Description of the change

Update the UBUS_LAUNCHER_SELECTION_CHANGED on UBUS_QUICKLIST_END_KEY_NAV

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

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/AbstractLauncherIcon.h'
2--- launcher/AbstractLauncherIcon.h 2012-09-12 19:00:13 +0000
3+++ launcher/AbstractLauncherIcon.h 2012-10-17 10:31:28 +0000
4@@ -140,6 +140,7 @@
5 virtual void SetSortPriority(int priority) = 0;
6
7 virtual bool OpenQuicklist(bool select_first_item = false, int monitor = -1) = 0;
8+ virtual void CloseQuicklist() = 0;
9
10 virtual void SetCenter(nux::Point3 center, int monitor, nux::Geometry parent_geo) = 0;
11
12
13=== modified file 'launcher/LauncherController.cpp'
14--- launcher/LauncherController.cpp 2012-09-20 00:08:23 +0000
15+++ launcher/LauncherController.cpp 2012-10-17 10:31:28 +0000
16@@ -149,6 +149,13 @@
17 parent_->KeyNavGrab();
18
19 model_->SetSelection(reactivate_index);
20+ AbstractLauncherIcon::Ptr const& selected = model_->Selection();
21+
22+ if (selected)
23+ {
24+ ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
25+ g_variant_new_string(selected->tooltip_text().c_str()));
26+ }
27 });
28
29 parent_->AddChild(model_.get());
30@@ -1369,12 +1376,7 @@
31 case NUX_VK_RIGHT:
32 case NUX_KP_RIGHT:
33 case XK_Menu:
34- if (model_->Selection()->OpenQuicklist(true, keyboard_launcher_->monitor()))
35- {
36- reactivate_keynav = true;
37- reactivate_index = model_->SelectionIndex();
38- parent_->KeyNavTerminate(false);
39- }
40+ OpenQuicklist();
41 break;
42
43 // <SPACE> (open a new instance)
44@@ -1399,6 +1401,16 @@
45 }
46 }
47
48+void Controller::Impl::OpenQuicklist()
49+{
50+ if (model_->Selection()->OpenQuicklist(true, keyboard_launcher_->monitor()))
51+ {
52+ reactivate_keynav = true;
53+ reactivate_index = model_->SelectionIndex();
54+ parent_->KeyNavTerminate(false);
55+ }
56+}
57+
58 void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data)
59 {
60 GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr);
61
62=== modified file 'launcher/LauncherControllerPrivate.h'
63--- launcher/LauncherControllerPrivate.h 2012-09-17 14:57:22 +0000
64+++ launcher/LauncherControllerPrivate.h 2012-10-17 10:31:28 +0000
65@@ -107,6 +107,8 @@
66 const char* character,
67 unsigned short keyCount);
68
69+ void OpenQuicklist();
70+
71 static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data);
72 static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path,
73 const gchar* interface_name, const gchar* method_name,
74
75=== modified file 'launcher/LauncherIcon.cpp'
76--- launcher/LauncherIcon.cpp 2012-10-01 12:54:43 +0000
77+++ launcher/LauncherIcon.cpp 2012-10-17 10:31:28 +0000
78@@ -634,6 +634,11 @@
79 return true;
80 }
81
82+void LauncherIcon::CloseQuicklist()
83+{
84+ _quicklist->HideAndEndQuicklistNav();
85+}
86+
87 void LauncherIcon::RecvMouseDown(int button, int monitor, unsigned long key_flags)
88 {
89 if (button == 3)
90
91=== modified file 'launcher/LauncherIcon.h'
92--- launcher/LauncherIcon.h 2012-09-12 19:00:13 +0000
93+++ launcher/LauncherIcon.h 2012-10-17 10:31:28 +0000
94@@ -81,6 +81,7 @@
95 void ShowTooltip();
96
97 bool OpenQuicklist(bool select_first_item = false, int monitor = -1);
98+ void CloseQuicklist();
99
100 void SetCenter(nux::Point3 center, int parent_monitor, nux::Geometry parent_geo);
101
102
103=== modified file 'launcher/MockLauncherIcon.h'
104--- launcher/MockLauncherIcon.h 2012-09-17 20:22:35 +0000
105+++ launcher/MockLauncherIcon.h 2012-10-17 10:31:28 +0000
106@@ -130,6 +130,10 @@
107 return false;
108 }
109
110+ void CloseQuicklist()
111+ {
112+ }
113+
114 void SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)
115 {
116 center.x += geo.x;
117
118=== modified file 'launcher/QuicklistView.cpp'
119--- launcher/QuicklistView.cpp 2012-10-01 15:12:05 +0000
120+++ launcher/QuicklistView.cpp 2012-10-17 10:31:28 +0000
121@@ -279,11 +279,7 @@
122 // left (close quicklist, go back to laucher key-nav)
123 case NUX_VK_LEFT:
124 case NUX_KP_LEFT:
125- Hide();
126- // inform Launcher we switch back to Launcher key-nav
127- ubus_server_send_message(ubus_server_get_default(),
128- UBUS_QUICKLIST_END_KEY_NAV,
129- NULL);
130+ HideAndEndQuicklistNav();
131 break;
132
133 // esc (close quicklist, exit key-nav)
134@@ -407,6 +403,15 @@
135 }
136 }
137
138+void QuicklistView::HideAndEndQuicklistNav()
139+{
140+ Hide();
141+ // inform Launcher we switch back to Launcher key-nav
142+ ubus_server_send_message(ubus_server_get_default(),
143+ UBUS_QUICKLIST_END_KEY_NAV,
144+ NULL);
145+}
146+
147 void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
148 {
149 CairoBaseWindow::Draw(gfxContext, forceDraw);
150
151=== modified file 'launcher/QuicklistView.h'
152--- launcher/QuicklistView.h 2012-08-15 02:51:33 +0000
153+++ launcher/QuicklistView.h 2012-10-17 10:31:28 +0000
154@@ -60,6 +60,7 @@
155
156 void Show();
157 void Hide();
158+ void HideAndEndQuicklistNav();
159
160 int GetNumItems();
161 QuicklistMenuItem* GetNthItems(int index);
162
163=== modified file 'tests/test_launcher_controller.cpp'
164--- tests/test_launcher_controller.cpp 2012-10-12 16:34:45 +0000
165+++ tests/test_launcher_controller.cpp 2012-10-17 10:31:28 +0000
166@@ -32,6 +32,7 @@
167 #include "SoftwareCenterLauncherIcon.h"
168 #include "PanelStyle.h"
169 #include "UnitySettings.h"
170+#include "UBusMessages.h"
171 #include "test_utils.h"
172 #include "test_uscreen_mock.h"
173 #include "test_mock_devices.h"
174@@ -204,6 +205,14 @@
175 lc.multiple_launchers = true;
176 }
177
178+ void ProcessUBusMessages()
179+ {
180+ bool expired = false;
181+ glib::Idle idle([&] { expired = true; return false; },
182+ glib::Source::Priority::LOW);
183+ Utils::WaitUntil(expired);
184+ }
185+
186 protected:
187 struct MockLauncherController : Controller
188 {
189@@ -1498,4 +1507,24 @@
190 EXPECT_TRUE(lc.Impl()->expo_icon_->IsVisible());
191 }
192
193+TEST_F(TestLauncherController, UpdateSelectionChanged)
194+{
195+ UBusManager manager;
196+ std::string last_selection_change;
197+ manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) { last_selection_change = g_variant_get_string(data, 0); });
198+
199+ lc.KeyNavGrab();
200+ ProcessUBusMessages();
201+ ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
202+
203+ lc.KeyNavNext();
204+ ProcessUBusMessages();
205+ ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
206+
207+ lc.Impl()->OpenQuicklist();
208+ lc.Impl()->model_->Selection()->CloseQuicklist();
209+ ProcessUBusMessages();
210+ ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
211+}
212+
213 }

Subscribers

People subscribed via source and target branches