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
1=== modified file 'dash/previews/Preview.cpp'
2--- dash/previews/Preview.cpp 2012-09-18 09:05:50 +0000
3+++ dash/previews/Preview.cpp 2012-09-24 16:03:35 +0000
4@@ -102,8 +102,9 @@
5
6 nux::InputArea* DefaultFocus() const
7 {
8- if (areas_.size() == 0)
9- return NULL;
10+ if (areas_.empty())
11+ return nullptr;
12+
13 return *areas_.begin();
14 }
15
16@@ -111,10 +112,10 @@
17 unsigned long x11_key_code,
18 unsigned long special_keys_state)
19 {
20- if (areas_.size() == 0)
21+ if (areas_.empty())
22 return nullptr;
23
24- nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
25+ nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
26 auto it = std::find(areas_.begin(), areas_.end(), current_focus_area);
27 if (it != areas_.end())
28 return current_focus_area;
29@@ -124,7 +125,7 @@
30
31 nux::Area* KeyNavIteration(nux::KeyNavDirection direction)
32 {
33- if (areas_.size() == 0)
34+ if (areas_.empty())
35 return nullptr;
36
37 if (direction != nux::KEY_NAV_TAB_PREVIOUS && direction != nux::KEY_NAV_TAB_NEXT)
38
39=== modified file 'launcher/Launcher.cpp'
40--- launcher/Launcher.cpp 2012-09-19 07:09:26 +0000
41+++ launcher/Launcher.cpp 2012-09-24 16:03:35 +0000
42@@ -1334,12 +1334,13 @@
43
44 // check the state before changing it to avoid uneeded hide calls
45 if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
46- (nux::Abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
47- nux::Abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
48- _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
49+ (std::abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
50+ std::abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
51+ {
52+ _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
53+ }
54 }
55
56-
57 int Launcher::GetMouseX() const
58 {
59 return _mouse_position.x;
60@@ -2091,6 +2092,12 @@
61
62 void Launcher::HideDragWindow()
63 {
64+ nux::Geometry const& abs_geo = GetAbsoluteGeometry();
65+ nux::Point const& mouse = nux::GetWindowCompositor().GetMousePosition();
66+
67+ if (abs_geo.IsInside(mouse))
68+ mouse_enter.emit(mouse.x - abs_geo.x, mouse.y - abs_geo.y, 0, 0);
69+
70 if (!_drag_window)
71 return;
72
73
74=== modified file 'tests/test_launcher.cpp'
75--- tests/test_launcher.cpp 2012-09-11 12:13:45 +0000
76+++ tests/test_launcher.cpp 2012-09-24 16:03:35 +0000
77@@ -33,7 +33,6 @@
78 #include "unity-shared/UnitySettings.h"
79 #include "unity-shared/IconRenderer.h"
80 #include "test_utils.h"
81-using namespace unity;
82
83 namespace unity
84 {
85@@ -210,6 +209,14 @@
86 nux::ObjectPtr<MockLauncher> launcher_;
87 };
88
89+struct TestWindowCompositor
90+{
91+ static void SetMousePosition(int x, int y)
92+ {
93+ nux::GetWindowCompositor()._mouse_position = nux::Point(x, y);
94+ }
95+};
96+
97 TEST_F(TestLauncher, TestQuirksDuringDnd)
98 {
99 MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon);
100@@ -435,6 +442,34 @@
101 launcher_->EndIconDrag();
102 }
103
104+TEST_F(TestLauncher, DragLauncherIconHidesOverLauncherEmitsMouseEnter)
105+{
106+ bool mouse_entered = false;
107+
108+ launcher_->mouse_enter.connect([&mouse_entered] (int x, int y, unsigned long, unsigned long) {
109+ mouse_entered = true;
110+ EXPECT_EQ(x, 1);
111+ EXPECT_EQ(y, 2);
112+ });
113+
114+ auto const& abs_geo = launcher_->GetAbsoluteGeometry();
115+ TestWindowCompositor::SetMousePosition(abs_geo.x + 1, abs_geo.y + 2);
116+ launcher_->HideDragWindow();
117+ EXPECT_TRUE(mouse_entered);
118+}
119+
120+TEST_F(TestLauncher, DragLauncherIconHidesOutsideLauncherEmitsMouseEnter)
121+{
122+ bool mouse_entered = false;
123+ launcher_->mouse_enter.connect([&mouse_entered] (int, int, unsigned long, unsigned long)
124+ { mouse_entered = true; });
125+
126+ auto const& abs_geo = launcher_->GetAbsoluteGeometry();
127+ TestWindowCompositor::SetMousePosition(abs_geo.x - 1, abs_geo.y - 2);
128+ launcher_->HideDragWindow();
129+ EXPECT_FALSE(mouse_entered);
130+}
131+
132 TEST_F(TestLauncher, DndIsSpecialRequest)
133 {
134 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));

Subscribers

People subscribed via source and target branches