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

Proposed by Albert Astals Cid
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
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) Approve
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.
Revision history for this message
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
=== modified file 'launcher/AbstractLauncherIcon.h'
--- launcher/AbstractLauncherIcon.h 2012-09-12 19:00:13 +0000
+++ launcher/AbstractLauncherIcon.h 2012-10-17 10:31:28 +0000
@@ -140,6 +140,7 @@
140 virtual void SetSortPriority(int priority) = 0;140 virtual void SetSortPriority(int priority) = 0;
141141
142 virtual bool OpenQuicklist(bool select_first_item = false, int monitor = -1) = 0;142 virtual bool OpenQuicklist(bool select_first_item = false, int monitor = -1) = 0;
143 virtual void CloseQuicklist() = 0;
143144
144 virtual void SetCenter(nux::Point3 center, int monitor, nux::Geometry parent_geo) = 0;145 virtual void SetCenter(nux::Point3 center, int monitor, nux::Geometry parent_geo) = 0;
145146
146147
=== modified file 'launcher/LauncherController.cpp'
--- launcher/LauncherController.cpp 2012-09-20 00:08:23 +0000
+++ launcher/LauncherController.cpp 2012-10-17 10:31:28 +0000
@@ -149,6 +149,13 @@
149 parent_->KeyNavGrab();149 parent_->KeyNavGrab();
150150
151 model_->SetSelection(reactivate_index);151 model_->SetSelection(reactivate_index);
152 AbstractLauncherIcon::Ptr const& selected = model_->Selection();
153
154 if (selected)
155 {
156 ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
157 g_variant_new_string(selected->tooltip_text().c_str()));
158 }
152 });159 });
153160
154 parent_->AddChild(model_.get());161 parent_->AddChild(model_.get());
@@ -1369,12 +1376,7 @@
1369 case NUX_VK_RIGHT:1376 case NUX_VK_RIGHT:
1370 case NUX_KP_RIGHT:1377 case NUX_KP_RIGHT:
1371 case XK_Menu:1378 case XK_Menu:
1372 if (model_->Selection()->OpenQuicklist(true, keyboard_launcher_->monitor()))1379 OpenQuicklist();
1373 {
1374 reactivate_keynav = true;
1375 reactivate_index = model_->SelectionIndex();
1376 parent_->KeyNavTerminate(false);
1377 }
1378 break;1380 break;
13791381
1380 // <SPACE> (open a new instance)1382 // <SPACE> (open a new instance)
@@ -1399,6 +1401,16 @@
1399 }1401 }
1400}1402}
14011403
1404void Controller::Impl::OpenQuicklist()
1405{
1406 if (model_->Selection()->OpenQuicklist(true, keyboard_launcher_->monitor()))
1407 {
1408 reactivate_keynav = true;
1409 reactivate_index = model_->SelectionIndex();
1410 parent_->KeyNavTerminate(false);
1411 }
1412}
1413
1402void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data)1414void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data)
1403{1415{
1404 GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr);1416 GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr);
14051417
=== modified file 'launcher/LauncherControllerPrivate.h'
--- launcher/LauncherControllerPrivate.h 2012-09-17 14:57:22 +0000
+++ launcher/LauncherControllerPrivate.h 2012-10-17 10:31:28 +0000
@@ -107,6 +107,8 @@
107 const char* character,107 const char* character,
108 unsigned short keyCount);108 unsigned short keyCount);
109109
110 void OpenQuicklist();
111
110 static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data);112 static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data);
111 static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path,113 static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path,
112 const gchar* interface_name, const gchar* method_name,114 const gchar* interface_name, const gchar* method_name,
113115
=== modified file 'launcher/LauncherIcon.cpp'
--- launcher/LauncherIcon.cpp 2012-10-01 12:54:43 +0000
+++ launcher/LauncherIcon.cpp 2012-10-17 10:31:28 +0000
@@ -634,6 +634,11 @@
634 return true;634 return true;
635}635}
636636
637void LauncherIcon::CloseQuicklist()
638{
639 _quicklist->HideAndEndQuicklistNav();
640}
641
637void LauncherIcon::RecvMouseDown(int button, int monitor, unsigned long key_flags)642void LauncherIcon::RecvMouseDown(int button, int monitor, unsigned long key_flags)
638{643{
639 if (button == 3)644 if (button == 3)
640645
=== modified file 'launcher/LauncherIcon.h'
--- launcher/LauncherIcon.h 2012-09-12 19:00:13 +0000
+++ launcher/LauncherIcon.h 2012-10-17 10:31:28 +0000
@@ -81,6 +81,7 @@
81 void ShowTooltip();81 void ShowTooltip();
8282
83 bool OpenQuicklist(bool select_first_item = false, int monitor = -1);83 bool OpenQuicklist(bool select_first_item = false, int monitor = -1);
84 void CloseQuicklist();
8485
85 void SetCenter(nux::Point3 center, int parent_monitor, nux::Geometry parent_geo);86 void SetCenter(nux::Point3 center, int parent_monitor, nux::Geometry parent_geo);
8687
8788
=== modified file 'launcher/MockLauncherIcon.h'
--- launcher/MockLauncherIcon.h 2012-09-17 20:22:35 +0000
+++ launcher/MockLauncherIcon.h 2012-10-17 10:31:28 +0000
@@ -130,6 +130,10 @@
130 return false;130 return false;
131 }131 }
132132
133 void CloseQuicklist()
134 {
135 }
136
133 void SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)137 void SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)
134 {138 {
135 center.x += geo.x;139 center.x += geo.x;
136140
=== modified file 'launcher/QuicklistView.cpp'
--- launcher/QuicklistView.cpp 2012-10-01 15:12:05 +0000
+++ launcher/QuicklistView.cpp 2012-10-17 10:31:28 +0000
@@ -279,11 +279,7 @@
279 // left (close quicklist, go back to laucher key-nav)279 // left (close quicklist, go back to laucher key-nav)
280 case NUX_VK_LEFT:280 case NUX_VK_LEFT:
281 case NUX_KP_LEFT:281 case NUX_KP_LEFT:
282 Hide();282 HideAndEndQuicklistNav();
283 // inform Launcher we switch back to Launcher key-nav
284 ubus_server_send_message(ubus_server_get_default(),
285 UBUS_QUICKLIST_END_KEY_NAV,
286 NULL);
287 break;283 break;
288284
289 // esc (close quicklist, exit key-nav)285 // esc (close quicklist, exit key-nav)
@@ -407,6 +403,15 @@
407 }403 }
408}404}
409405
406void QuicklistView::HideAndEndQuicklistNav()
407{
408 Hide();
409 // inform Launcher we switch back to Launcher key-nav
410 ubus_server_send_message(ubus_server_get_default(),
411 UBUS_QUICKLIST_END_KEY_NAV,
412 NULL);
413}
414
410void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)415void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
411{416{
412 CairoBaseWindow::Draw(gfxContext, forceDraw);417 CairoBaseWindow::Draw(gfxContext, forceDraw);
413418
=== modified file 'launcher/QuicklistView.h'
--- launcher/QuicklistView.h 2012-08-15 02:51:33 +0000
+++ launcher/QuicklistView.h 2012-10-17 10:31:28 +0000
@@ -60,6 +60,7 @@
6060
61 void Show();61 void Show();
62 void Hide();62 void Hide();
63 void HideAndEndQuicklistNav();
6364
64 int GetNumItems();65 int GetNumItems();
65 QuicklistMenuItem* GetNthItems(int index);66 QuicklistMenuItem* GetNthItems(int index);
6667
=== modified file 'tests/test_launcher_controller.cpp'
--- tests/test_launcher_controller.cpp 2012-10-12 16:34:45 +0000
+++ tests/test_launcher_controller.cpp 2012-10-17 10:31:28 +0000
@@ -32,6 +32,7 @@
32#include "SoftwareCenterLauncherIcon.h"32#include "SoftwareCenterLauncherIcon.h"
33#include "PanelStyle.h"33#include "PanelStyle.h"
34#include "UnitySettings.h"34#include "UnitySettings.h"
35#include "UBusMessages.h"
35#include "test_utils.h"36#include "test_utils.h"
36#include "test_uscreen_mock.h"37#include "test_uscreen_mock.h"
37#include "test_mock_devices.h"38#include "test_mock_devices.h"
@@ -204,6 +205,14 @@
204 lc.multiple_launchers = true;205 lc.multiple_launchers = true;
205 }206 }
206207
208 void ProcessUBusMessages()
209 {
210 bool expired = false;
211 glib::Idle idle([&] { expired = true; return false; },
212 glib::Source::Priority::LOW);
213 Utils::WaitUntil(expired);
214 }
215
207protected:216protected:
208 struct MockLauncherController : Controller217 struct MockLauncherController : Controller
209 {218 {
@@ -1498,4 +1507,24 @@
1498 EXPECT_TRUE(lc.Impl()->expo_icon_->IsVisible());1507 EXPECT_TRUE(lc.Impl()->expo_icon_->IsVisible());
1499}1508}
15001509
1510TEST_F(TestLauncherController, UpdateSelectionChanged)
1511{
1512 UBusManager manager;
1513 std::string last_selection_change;
1514 manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) { last_selection_change = g_variant_get_string(data, 0); });
1515
1516 lc.KeyNavGrab();
1517 ProcessUBusMessages();
1518 ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
1519
1520 lc.KeyNavNext();
1521 ProcessUBusMessages();
1522 ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
1523
1524 lc.Impl()->OpenQuicklist();
1525 lc.Impl()->model_->Selection()->CloseQuicklist();
1526 ProcessUBusMessages();
1527 ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
1528}
1529
1501}1530}

Subscribers

People subscribed via source and target branches