Merge lp:~azzar1/unity/fix-1035304-dnd-edge into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2931
Proposed branch: lp:~azzar1/unity/fix-1035304-dnd-edge
Merge into: lp:unity
Diff against target: 89 lines (+29/-4)
2 files modified
launcher/Launcher.cpp (+8/-4)
tests/test_launcher.cpp (+21/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1035304-dnd-edge
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Marco Trevisan (Treviño) Approve
Review via email: mp+135945@code.launchpad.net

Commit message

Disable sticky edges during drag and drop.

Description of the change

== Probelem ==
Bug #1035304: Window management - When dragging a icon or selected text, sticky edges should not apply (regardless of sticky edge setting)

== Fix ==
Release pointer barrier in Launcher::HandlePointerBarrier.

== Test ==
Unit test added.

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

Good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-11-24 15:34:32 +0000
3+++ launcher/Launcher.cpp 2012-11-26 19:33:21 +0000
4@@ -1119,7 +1119,6 @@
5 // function is not smooth it is continuous, which is more important for our visual representation (icons
6 // wont start jumping around). As a general rule ANY if () statements that modify center.y should be seen
7 // as bugs.
8- int index = 1;
9 for (it = _model->main_begin(); it != _model->main_end(); ++it)
10 {
11 RenderArg arg;
12@@ -1128,7 +1127,6 @@
13 autohide_offset, folded_z_distance, animation_neg_rads, current);
14 arg.colorify = colorify;
15 launcher_args.push_back(arg);
16- index++;
17 }
18
19 // compute maximum height of shelf
20@@ -2261,7 +2259,13 @@
21
22 bool Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)
23 {
24- nux::Geometry abs_geo = GetAbsoluteGeometry();
25+ if (_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
26+ {
27+ owner->ReleaseBarrier(event->event_id);
28+ return true;
29+ }
30+
31+ nux::Geometry const& abs_geo = GetAbsoluteGeometry();
32
33 bool apply_to_reveal = false;
34 if (_hidden && event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width)
35@@ -2631,7 +2635,7 @@
36
37 SetMousePosition(x - _parent->GetGeometry().x, y - _parent->GetGeometry().y);
38
39- if (!IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)
40+ if (monitor() == 0 && !IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)
41 {
42 if (_dnd_hovered_icon)
43 _dnd_hovered_icon->SendDndLeave();
44
45=== modified file 'tests/test_launcher.cpp'
46--- tests/test_launcher.cpp 2012-11-15 22:31:46 +0000
47+++ tests/test_launcher.cpp 2012-11-26 19:33:21 +0000
48@@ -54,6 +54,11 @@
49 MOCK_METHOD1(Stick, void(bool));
50 };
51
52+struct MockPointerBarrierWrapper : ui::PointerBarrierWrapper
53+{
54+ MOCK_METHOD1(ReleaseBarrier, void(int event_id));
55+};
56+
57 }
58
59 class TestLauncher : public Test
60@@ -114,6 +119,11 @@
61
62 _dnd_hovered_icon = MouseIconIntersection(x, y);
63 }
64+
65+ bool HandleBarrierEvent(ui::PointerBarrierWrapper* barrier, ui::BarrierEvent::Ptr event)
66+ {
67+ return Launcher::HandleBarrierEvent(barrier, event);
68+ }
69 };
70
71 TestLauncher()
72@@ -437,6 +447,17 @@
73 EXPECT_FALSE(mouse_entered);
74 }
75
76+TEST_F(TestLauncher, EdgeResistDuringDnd)
77+{
78+ auto barrier = std::make_shared<MockPointerBarrierWrapper>();
79+ auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100);
80+
81+ launcher_->DndStarted("");
82+
83+ EXPECT_CALL(*barrier, ReleaseBarrier(100));
84+ EXPECT_TRUE(launcher_->HandleBarrierEvent(barrier.get(), event));
85+}
86+
87 TEST_F(TestLauncher, DndIsSpecialRequest)
88 {
89 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));