Merge lp:~3v1n0/unity/icon-dragging-cancels-on-windows-mapping into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2652
Proposed branch: lp:~3v1n0/unity/icon-dragging-cancels-on-windows-mapping
Merge into: lp:unity
Diff against target: 161 lines (+37/-32)
6 files modified
launcher/Launcher.cpp (+2/-24)
launcher/Launcher.h (+0/-3)
launcher/LauncherDragWindow.cpp (+12/-4)
launcher/LauncherDragWindow.h (+1/-0)
tests/test_launcher.cpp (+1/-1)
tests/test_launcher_drag_window.cpp (+21/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/icon-dragging-cancels-on-windows-mapping
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+122392@code.launchpad.net

Commit message

LauncherDragWindow: cancel drag on window mapped/unmapped

Description of the change

Make sure that an icon dragged from the launcher emits a drag-cancel signal when a window is mapped/unmapped.

unit tests added.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2012-08-31 21:32:38 +0000
+++ launcher/Launcher.cpp 2012-09-01 14:28:19 +0000
@@ -177,9 +177,8 @@
177 ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed));177 ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed));
178178
179 WindowManager& plugin_adapter = *(WindowManager::Default());179 WindowManager& plugin_adapter = *(WindowManager::Default());
180 plugin_adapter.window_mapped.connect(sigc::mem_fun(this, &Launcher::OnWindowMapped));180 plugin_adapter.window_mapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup)));
181 plugin_adapter.window_unmapped.connect(sigc::mem_fun(this, &Launcher::OnWindowUnmapped));181 plugin_adapter.window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup)));
182
183 plugin_adapter.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));182 plugin_adapter.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
184 plugin_adapter.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));183 plugin_adapter.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
185 plugin_adapter.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));184 plugin_adapter.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
@@ -1392,27 +1391,6 @@
1392 sources_.AddTimeout(200, cb_func, DND_CHECK_TIMEOUT);1391 sources_.AddTimeout(200, cb_func, DND_CHECK_TIMEOUT);
1393}1392}
13941393
1395void Launcher::OnWindowMapped(guint32 xid)
1396{
1397 //CompWindow* window = _screen->findWindow(xid);
1398 //if (window && window->type() | CompWindowTypeDndMask)
1399 //{
1400 DndTimeoutSetup();
1401 //}
1402
1403 if (GetActionState() != ACTION_NONE)
1404 ResetMouseDragState();
1405}
1406
1407void Launcher::OnWindowUnmapped(guint32 xid)
1408{
1409 //CompWindow* window = _screen->findWindow(xid);
1410 //if (window && window->type() | CompWindowTypeDndMask)
1411 //{
1412 DndTimeoutSetup();
1413 //}
1414}
1415
1416void Launcher::OnPluginStateChanged()1394void Launcher::OnPluginStateChanged()
1417{1395{
1418 _hide_machine.SetQuirk (LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default ()->IsExpoActive ());1396 _hide_machine.SetQuirk (LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default ()->IsExpoActive ());
14191397
=== modified file 'launcher/Launcher.h'
--- launcher/Launcher.h 2012-08-31 20:13:12 +0000
+++ launcher/Launcher.h 2012-09-01 14:28:19 +0000
@@ -188,9 +188,6 @@
188 void OnOptionChanged();188 void OnOptionChanged();
189 void UpdateOptions(Options::Ptr options);189 void UpdateOptions(Options::Ptr options);
190190
191 void OnWindowMapped(guint32 xid);
192 void OnWindowUnmapped(guint32 xid);
193
194 void OnDragStart(const nux::GestureEvent &event);191 void OnDragStart(const nux::GestureEvent &event);
195 void OnDragUpdate(const nux::GestureEvent &event);192 void OnDragUpdate(const nux::GestureEvent &event);
196 void OnDragFinish(const nux::GestureEvent &event);193 void OnDragFinish(const nux::GestureEvent &event);
197194
=== modified file 'launcher/LauncherDragWindow.cpp'
--- launcher/LauncherDragWindow.cpp 2012-08-31 20:13:37 +0000
+++ launcher/LauncherDragWindow.cpp 2012-09-01 14:28:19 +0000
@@ -24,6 +24,7 @@
24#include <Nux/TextureArea.h>24#include <Nux/TextureArea.h>
2525
26#include "LauncherDragWindow.h"26#include "LauncherDragWindow.h"
27#include "unity-shared/WindowManager.h"
2728
28namespace unity29namespace unity
29{30{
@@ -41,11 +42,12 @@
4142
42 key_down.connect([this] (unsigned long, unsigned long keysym, unsigned long, const char*, unsigned short) {43 key_down.connect([this] (unsigned long, unsigned long keysym, unsigned long, const char*, unsigned short) {
43 if (keysym == NUX_VK_ESCAPE)44 if (keysym == NUX_VK_ESCAPE)
44 {45 CancelDrag();
45 _cancelled = true;
46 drag_cancel_request.emit();
47 }
48 });46 });
47
48 auto wm = WindowManager::Default();
49 wm->window_mapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag)));
50 wm->window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag)));
49}51}
5052
51LauncherDragWindow::~LauncherDragWindow()53LauncherDragWindow::~LauncherDragWindow()
@@ -66,6 +68,12 @@
66 return _cancelled;68 return _cancelled;
67}69}
6870
71void LauncherDragWindow::CancelDrag()
72{
73 _cancelled = true;
74 drag_cancel_request.emit();
75}
76
69void LauncherDragWindow::SetAnimationTarget(int x, int y)77void LauncherDragWindow::SetAnimationTarget(int x, int y)
70{78{
71 _animation_target = nux::Point2(x, y);79 _animation_target = nux::Point2(x, y);
7280
=== modified file 'launcher/LauncherDragWindow.h'
--- launcher/LauncherDragWindow.h 2012-08-31 14:40:17 +0000
+++ launcher/LauncherDragWindow.h 2012-09-01 14:28:19 +0000
@@ -57,6 +57,7 @@
5757
58private:58private:
59 bool OnAnimationTimeout();59 bool OnAnimationTimeout();
60 void CancelDrag();
6061
61 bool _cancelled;62 bool _cancelled;
62 nux::ObjectPtr<nux::IOpenGLBaseTexture> _icon;63 nux::ObjectPtr<nux::IOpenGLBaseTexture> _icon;
6364
=== modified file 'tests/test_launcher.cpp'
--- tests/test_launcher.cpp 2012-08-31 20:14:18 +0000
+++ tests/test_launcher.cpp 2012-09-01 14:28:19 +0000
@@ -204,7 +204,7 @@
204 EXPECT_EQ(launcher_->IconBackgroundIntensity(third, current), 0.0f);204 EXPECT_EQ(launcher_->IconBackgroundIntensity(third, current), 0.0f);
205}205}
206206
207TEST_F(TestLauncher, CancellingDragLauncherIcon)207TEST_F(TestLauncher, DragLauncherIconCancelRestoresIconOrder)
208{208{
209 MockMockLauncherIcon::Ptr icon1(new MockMockLauncherIcon);209 MockMockLauncherIcon::Ptr icon1(new MockMockLauncherIcon);
210 MockMockLauncherIcon::Ptr icon2(new MockMockLauncherIcon);210 MockMockLauncherIcon::Ptr icon2(new MockMockLauncherIcon);
211211
=== modified file 'tests/test_launcher_drag_window.cpp'
--- tests/test_launcher_drag_window.cpp 2012-08-31 20:14:18 +0000
+++ tests/test_launcher_drag_window.cpp 2012-09-01 14:28:19 +0000
@@ -20,6 +20,7 @@
20#include <gmock/gmock.h>20#include <gmock/gmock.h>
2121
22#include "LauncherDragWindow.h"22#include "LauncherDragWindow.h"
23#include "WindowManager.h"
2324
24using namespace unity::launcher;25using namespace unity::launcher;
25using namespace testing;26using namespace testing;
@@ -67,4 +68,24 @@
67 EXPECT_TRUE(drag_window.Cancelled());68 EXPECT_TRUE(drag_window.Cancelled());
68}69}
6970
71TEST_F(TestLauncherDragWindow, CancelsOnWindowMapped)
72{
73 bool got_signal;
74 drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; });
75 WindowManager::Default()->window_mapped.emit(0);
76
77 EXPECT_TRUE(got_signal);
78 EXPECT_TRUE(drag_window.Cancelled());
79}
80
81TEST_F(TestLauncherDragWindow, CancelsOnWindowUnmapped)
82{
83 bool got_signal;
84 drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; });
85 WindowManager::Default()->window_unmapped.emit(0);
86
87 EXPECT_TRUE(got_signal);
88 EXPECT_TRUE(drag_window.Cancelled());
89}
90
70}91}