Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2352233002: mus drag and drop: Add API to let the client cancel the drag. (Closed)
Patch Set: Oops. Forgot the client lib side. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/window_tree.h" 5 #include "services/ui/ws/window_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 1539
1540 // Here, we need to dramatically change how the mouse pointer works. Once 1540 // Here, we need to dramatically change how the mouse pointer works. Once
1541 // we've started a drag drop operation, cursor events don't go to windows as 1541 // we've started a drag drop operation, cursor events don't go to windows as
1542 // normal. 1542 // normal.
1543 WindowManagerState* wms = display_root->window_manager_state(); 1543 WindowManagerState* wms = display_root->window_manager_state();
1544 window_server_->StartDragLoop(change_id, window, this); 1544 window_server_->StartDragLoop(change_id, window, this);
1545 wms->SetDragDropSourceWindow(this, window, this, drag_pointer, 1545 wms->SetDragDropSourceWindow(this, window, this, drag_pointer,
1546 std::move(drag_data), drag_operation); 1546 std::move(drag_data), drag_operation);
1547 } 1547 }
1548 1548
1549 void WindowTree::CancelDragDrop(Id window_id) {
1550 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1551 bool success = window && access_policy_->CanInitiateDragLoop(window);
sky 2016/09/21 20:40:56 I wouldn't bother with the success member. That is
1552 if (!success)
1553 return;
1554
1555 if (window != window_server_->GetCurrentDragLoopWindow())
1556 return;
1557
1558 if (window_server_->GetCurrentDragLoopInitiator() != this)
1559 return;
1560
1561 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window);
1562 if (!display_root)
1563 return;
1564
1565 WindowManagerState* wms = display_root->window_manager_state();
1566 wms->CancelDragDrop();
1567 }
1568
1549 void WindowTree::PerformWindowMove(uint32_t change_id, 1569 void WindowTree::PerformWindowMove(uint32_t change_id,
1550 Id window_id, 1570 Id window_id,
1551 ui::mojom::MoveLoopSource source, 1571 ui::mojom::MoveLoopSource source,
1552 const gfx::Point& cursor) { 1572 const gfx::Point& cursor) {
1553 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1573 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1554 bool success = window && access_policy_->CanInitiateMoveLoop(window); 1574 bool success = window && access_policy_->CanInitiateMoveLoop(window);
1555 if (!success || !ShouldRouteToWindowManager(window)) { 1575 if (!success || !ShouldRouteToWindowManager(window)) {
1556 // We need to fail this move loop change, otherwise the client will just be 1576 // We need to fail this move loop change, otherwise the client will just be
1557 // waiting for |change_id|. 1577 // waiting for |change_id|.
1558 DVLOG(1) << "PerformWindowMove failed (access denied)."; 1578 DVLOG(1) << "PerformWindowMove failed (access denied).";
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 1892 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
1873 effect_bitmask, callback); 1893 effect_bitmask, callback);
1874 } 1894 }
1875 1895
1876 void WindowTree::PerformOnDragDropDone() { 1896 void WindowTree::PerformOnDragDropDone() {
1877 client()->OnDragDropDone(); 1897 client()->OnDragDropDone();
1878 } 1898 }
1879 1899
1880 } // namespace ws 1900 } // namespace ws
1881 } // namespace ui 1901 } // namespace ui
OLDNEW
« services/ui/public/cpp/window_tree_client.cc ('K') | « services/ui/ws/window_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698