Merge lp:~3v1n0/unity/launcher-autohide-drag-window-6.0 into lp:unity/6.0

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2736
Proposed branch: lp:~3v1n0/unity/launcher-autohide-drag-window-6.0
Merge into: lp:unity/6.0
Diff against target: 134 lines (+53/-10)
3 files modified
dash/previews/Preview.cpp (+6/-5)
launcher/Launcher.cpp (+11/-4)
tests/test_launcher.cpp (+36/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/launcher-autohide-drag-window-6.0
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+126042@code.launchpad.net

This proposal supersedes a proposal from 2012-09-24.

Commit message

Launcher: check the mouse position after relasing a drag window, and in case hide it

Tests included

Description of the change

Backported branch lp:~3v1n0/unity/launcher-autohide-drag-window to unity-6.0

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/previews/Preview.cpp'
--- dash/previews/Preview.cpp 2012-09-18 09:05:50 +0000
+++ dash/previews/Preview.cpp 2012-09-24 16:03:35 +0000
@@ -102,8 +102,9 @@
102102
103 nux::InputArea* DefaultFocus() const103 nux::InputArea* DefaultFocus() const
104 {104 {
105 if (areas_.size() == 0)105 if (areas_.empty())
106 return NULL;106 return nullptr;
107
107 return *areas_.begin();108 return *areas_.begin();
108 }109 }
109110
@@ -111,10 +112,10 @@
111 unsigned long x11_key_code,112 unsigned long x11_key_code,
112 unsigned long special_keys_state)113 unsigned long special_keys_state)
113 {114 {
114 if (areas_.size() == 0)115 if (areas_.empty())
115 return nullptr;116 return nullptr;
116117
117 nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea(); 118 nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
118 auto it = std::find(areas_.begin(), areas_.end(), current_focus_area);119 auto it = std::find(areas_.begin(), areas_.end(), current_focus_area);
119 if (it != areas_.end())120 if (it != areas_.end())
120 return current_focus_area;121 return current_focus_area;
@@ -124,7 +125,7 @@
124125
125 nux::Area* KeyNavIteration(nux::KeyNavDirection direction)126 nux::Area* KeyNavIteration(nux::KeyNavDirection direction)
126 {127 {
127 if (areas_.size() == 0)128 if (areas_.empty())
128 return nullptr;129 return nullptr;
129130
130 if (direction != nux::KEY_NAV_TAB_PREVIOUS && direction != nux::KEY_NAV_TAB_NEXT)131 if (direction != nux::KEY_NAV_TAB_PREVIOUS && direction != nux::KEY_NAV_TAB_NEXT)
131132
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2012-09-19 07:09:26 +0000
+++ launcher/Launcher.cpp 2012-09-24 16:03:35 +0000
@@ -1334,12 +1334,13 @@
13341334
1335 // check the state before changing it to avoid uneeded hide calls1335 // check the state before changing it to avoid uneeded hide calls
1336 if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&1336 if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
1337 (nux::Abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||1337 (std::abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
1338 nux::Abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))1338 std::abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
1339 _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);1339 {
1340 _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
1341 }
1340}1342}
13411343
1342
1343int Launcher::GetMouseX() const1344int Launcher::GetMouseX() const
1344{1345{
1345 return _mouse_position.x;1346 return _mouse_position.x;
@@ -2091,6 +2092,12 @@
20912092
2092void Launcher::HideDragWindow()2093void Launcher::HideDragWindow()
2093{2094{
2095 nux::Geometry const& abs_geo = GetAbsoluteGeometry();
2096 nux::Point const& mouse = nux::GetWindowCompositor().GetMousePosition();
2097
2098 if (abs_geo.IsInside(mouse))
2099 mouse_enter.emit(mouse.x - abs_geo.x, mouse.y - abs_geo.y, 0, 0);
2100
2094 if (!_drag_window)2101 if (!_drag_window)
2095 return;2102 return;
20962103
20972104
=== modified file 'tests/test_launcher.cpp'
--- tests/test_launcher.cpp 2012-09-11 12:13:45 +0000
+++ tests/test_launcher.cpp 2012-09-24 16:03:35 +0000
@@ -33,7 +33,6 @@
33#include "unity-shared/UnitySettings.h"33#include "unity-shared/UnitySettings.h"
34#include "unity-shared/IconRenderer.h"34#include "unity-shared/IconRenderer.h"
35#include "test_utils.h"35#include "test_utils.h"
36using namespace unity;
3736
38namespace unity37namespace unity
39{38{
@@ -210,6 +209,14 @@
210 nux::ObjectPtr<MockLauncher> launcher_;209 nux::ObjectPtr<MockLauncher> launcher_;
211};210};
212211
212struct TestWindowCompositor
213{
214 static void SetMousePosition(int x, int y)
215 {
216 nux::GetWindowCompositor()._mouse_position = nux::Point(x, y);
217 }
218};
219
213TEST_F(TestLauncher, TestQuirksDuringDnd)220TEST_F(TestLauncher, TestQuirksDuringDnd)
214{221{
215 MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon);222 MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon);
@@ -435,6 +442,34 @@
435 launcher_->EndIconDrag();442 launcher_->EndIconDrag();
436}443}
437444
445TEST_F(TestLauncher, DragLauncherIconHidesOverLauncherEmitsMouseEnter)
446{
447 bool mouse_entered = false;
448
449 launcher_->mouse_enter.connect([&mouse_entered] (int x, int y, unsigned long, unsigned long) {
450 mouse_entered = true;
451 EXPECT_EQ(x, 1);
452 EXPECT_EQ(y, 2);
453 });
454
455 auto const& abs_geo = launcher_->GetAbsoluteGeometry();
456 TestWindowCompositor::SetMousePosition(abs_geo.x + 1, abs_geo.y + 2);
457 launcher_->HideDragWindow();
458 EXPECT_TRUE(mouse_entered);
459}
460
461TEST_F(TestLauncher, DragLauncherIconHidesOutsideLauncherEmitsMouseEnter)
462{
463 bool mouse_entered = false;
464 launcher_->mouse_enter.connect([&mouse_entered] (int, int, unsigned long, unsigned long)
465 { mouse_entered = true; });
466
467 auto const& abs_geo = launcher_->GetAbsoluteGeometry();
468 TestWindowCompositor::SetMousePosition(abs_geo.x - 1, abs_geo.y - 2);
469 launcher_->HideDragWindow();
470 EXPECT_FALSE(mouse_entered);
471}
472
438TEST_F(TestLauncher, DndIsSpecialRequest)473TEST_F(TestLauncher, DndIsSpecialRequest)
439{474{
440 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));475 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));

Subscribers

People subscribed via source and target branches