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
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2012-11-24 15:34:32 +0000
+++ launcher/Launcher.cpp 2012-11-26 19:33:21 +0000
@@ -1119,7 +1119,6 @@
1119 // function is not smooth it is continuous, which is more important for our visual representation (icons1119 // function is not smooth it is continuous, which is more important for our visual representation (icons
1120 // wont start jumping around). As a general rule ANY if () statements that modify center.y should be seen1120 // wont start jumping around). As a general rule ANY if () statements that modify center.y should be seen
1121 // as bugs.1121 // as bugs.
1122 int index = 1;
1123 for (it = _model->main_begin(); it != _model->main_end(); ++it)1122 for (it = _model->main_begin(); it != _model->main_end(); ++it)
1124 {1123 {
1125 RenderArg arg;1124 RenderArg arg;
@@ -1128,7 +1127,6 @@
1128 autohide_offset, folded_z_distance, animation_neg_rads, current);1127 autohide_offset, folded_z_distance, animation_neg_rads, current);
1129 arg.colorify = colorify;1128 arg.colorify = colorify;
1130 launcher_args.push_back(arg);1129 launcher_args.push_back(arg);
1131 index++;
1132 }1130 }
11331131
1134 // compute maximum height of shelf1132 // compute maximum height of shelf
@@ -2261,7 +2259,13 @@
22612259
2262bool Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)2260bool Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)
2263{2261{
2264 nux::Geometry abs_geo = GetAbsoluteGeometry();2262 if (_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
2263 {
2264 owner->ReleaseBarrier(event->event_id);
2265 return true;
2266 }
2267
2268 nux::Geometry const& abs_geo = GetAbsoluteGeometry();
22652269
2266 bool apply_to_reveal = false;2270 bool apply_to_reveal = false;
2267 if (_hidden && event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width)2271 if (_hidden && event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width)
@@ -2631,7 +2635,7 @@
26312635
2632 SetMousePosition(x - _parent->GetGeometry().x, y - _parent->GetGeometry().y);2636 SetMousePosition(x - _parent->GetGeometry().x, y - _parent->GetGeometry().y);
26332637
2634 if (!IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)2638 if (monitor() == 0 && !IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)
2635 {2639 {
2636 if (_dnd_hovered_icon)2640 if (_dnd_hovered_icon)
2637 _dnd_hovered_icon->SendDndLeave();2641 _dnd_hovered_icon->SendDndLeave();
26382642
=== modified file 'tests/test_launcher.cpp'
--- tests/test_launcher.cpp 2012-11-15 22:31:46 +0000
+++ tests/test_launcher.cpp 2012-11-26 19:33:21 +0000
@@ -54,6 +54,11 @@
54 MOCK_METHOD1(Stick, void(bool));54 MOCK_METHOD1(Stick, void(bool));
55};55};
5656
57struct MockPointerBarrierWrapper : ui::PointerBarrierWrapper
58{
59 MOCK_METHOD1(ReleaseBarrier, void(int event_id));
60};
61
57}62}
5863
59class TestLauncher : public Test64class TestLauncher : public Test
@@ -114,6 +119,11 @@
114119
115 _dnd_hovered_icon = MouseIconIntersection(x, y);120 _dnd_hovered_icon = MouseIconIntersection(x, y);
116 }121 }
122
123 bool HandleBarrierEvent(ui::PointerBarrierWrapper* barrier, ui::BarrierEvent::Ptr event)
124 {
125 return Launcher::HandleBarrierEvent(barrier, event);
126 }
117 };127 };
118128
119 TestLauncher()129 TestLauncher()
@@ -437,6 +447,17 @@
437 EXPECT_FALSE(mouse_entered);447 EXPECT_FALSE(mouse_entered);
438}448}
439449
450TEST_F(TestLauncher, EdgeResistDuringDnd)
451{
452 auto barrier = std::make_shared<MockPointerBarrierWrapper>();
453 auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100);
454
455 launcher_->DndStarted("");
456
457 EXPECT_CALL(*barrier, ReleaseBarrier(100));
458 EXPECT_TRUE(launcher_->HandleBarrierEvent(barrier.get(), event));
459}
460
440TEST_F(TestLauncher, DndIsSpecialRequest)461TEST_F(TestLauncher, DndIsSpecialRequest)
441{462{
442 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));463 EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop"));