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

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

Issue 2655463009: aura-mus: Implement DesktopWindowTreeHostMus::StackAbove(). (Closed)
Patch Set: Add comment. Created 3 years, 10 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
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1275 }
1276 1276
1277 void WindowTree::SetModal(uint32_t change_id, Id window_id) { 1277 void WindowTree::SetModal(uint32_t change_id, Id window_id) {
1278 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id))); 1278 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id)));
1279 } 1279 }
1280 1280
1281 void WindowTree::ReorderWindow(uint32_t change_id, 1281 void WindowTree::ReorderWindow(uint32_t change_id,
1282 Id window_id, 1282 Id window_id,
1283 Id relative_window_id, 1283 Id relative_window_id,
1284 mojom::OrderDirection direction) { 1284 mojom::OrderDirection direction) {
1285 // TODO(erg): This implementation allows reordering two windows that are
1286 // children of a parent window which the two implementations can't see. There
1287 // should be a security check to prevent this.
1285 bool success = false; 1288 bool success = false;
1286 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1289 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1287 ServerWindow* relative_window = 1290 ServerWindow* relative_window =
1288 GetWindowByClientId(ClientWindowId(relative_window_id)); 1291 GetWindowByClientId(ClientWindowId(relative_window_id));
1289 DVLOG(3) << "reorder client=" << id_ << " client window_id=" << window_id 1292 DVLOG(3) << "reorder client=" << id_ << " client window_id=" << window_id
1290 << " global window_id=" 1293 << " global window_id="
1291 << (window ? WindowIdToTransportId(window->id()) : 0) 1294 << (window ? WindowIdToTransportId(window->id()) : 0)
1292 << " relative client window_id=" << relative_window_id 1295 << " relative client window_id=" << relative_window_id
1293 << " relative global window_id=" 1296 << " relative global window_id="
1294 << (relative_window ? WindowIdToTransportId(relative_window->id()) 1297 << (relative_window ? WindowIdToTransportId(relative_window->id())
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 // The window isn't parented. There's nothing to do. 1592 // The window isn't parented. There's nothing to do.
1590 DVLOG(1) << "DeactivateWindow failed (window unparented)"; 1593 DVLOG(1) << "DeactivateWindow failed (window unparented)";
1591 return; 1594 return;
1592 } 1595 }
1593 1596
1594 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); 1597 WindowTree* wm_tree = display_root->window_manager_state()->window_tree();
1595 wm_tree->window_manager_internal_->WmDeactivateWindow( 1598 wm_tree->window_manager_internal_->WmDeactivateWindow(
1596 wm_tree->ClientWindowIdForWindow(window).id); 1599 wm_tree->ClientWindowIdForWindow(window).id);
1597 } 1600 }
1598 1601
1602 void WindowTree::StackAbove(uint32_t change_id, Id above_id, Id below_id) {
1603 ServerWindow* above = GetWindowByClientId(ClientWindowId(above_id));
1604 if (!above) {
1605 DVLOG(1) << "StackAtTop failed (invalid above id)";
1606 client()->OnChangeCompleted(change_id, false);
1607 return;
1608 }
1609
1610 ServerWindow* below = GetWindowByClientId(ClientWindowId(below_id));
1611 if (!below) {
1612 DVLOG(1) << "StackAtTop failed (invalid below id)";
1613 client()->OnChangeCompleted(change_id, false);
1614 return;
1615 }
1616
1617 if (!access_policy_->CanStackAbove(above, below)) {
1618 DVLOG(1) << "StackAtTop failed (access denied)";
1619 client()->OnChangeCompleted(change_id, false);
1620 return;
1621 }
1622
1623 ServerWindow* parent = above->parent();
1624 ServerWindow* below_parent = below->parent();
1625 if (!parent) {
1626 DVLOG(1) << "StackAtTop failed (above unparented)";
1627 client()->OnChangeCompleted(change_id, false);
1628 return;
1629 }
1630 if (!below_parent) {
1631 DVLOG(1) << "StackAtTop failed (below unparented)";
1632 client()->OnChangeCompleted(change_id, false);
1633 return;
1634 }
1635 if (parent != below_parent) {
1636 DVLOG(1) << "StackAtTop failed (windows have different parents)";
1637 client()->OnChangeCompleted(change_id, false);
1638 return;
1639 }
1640
1641 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(above);
1642 if (!display_root) {
1643 DVLOG(1) << "StackAtTop (no display root)";
1644 client()->OnChangeCompleted(change_id, false);
1645 return;
1646 }
1647
1648 // Window reordering assumes that it is the owner of parent who is sending
1649 // the message, and does not deal gracefully with other clients reordering
1650 // their windows. So tell the window manager to send us a reorder message.
1651 WindowTree* wm_tree = display_root->window_manager_state()->window_tree();
1652 const uint32_t wm_change_id =
1653 window_server_->GenerateWindowManagerChangeId(this, change_id);
1654 wm_tree->window_manager_internal_->WmStackAbove(
1655 wm_change_id,
1656 wm_tree->ClientWindowIdForWindow(above).id,
1657 wm_tree->ClientWindowIdForWindow(below).id);
1658 }
1659
1599 void WindowTree::StackAtTop(uint32_t change_id, Id window_id) { 1660 void WindowTree::StackAtTop(uint32_t change_id, Id window_id) {
1600 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1661 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1601 if (!window) { 1662 if (!window) {
1602 DVLOG(1) << "StackAtTop failed (invalid id)"; 1663 DVLOG(1) << "StackAtTop failed (invalid id)";
1603 client()->OnChangeCompleted(change_id, false); 1664 client()->OnChangeCompleted(change_id, false);
1604 return; 1665 return;
1605 } 1666 }
1606 1667
1607 if (!access_policy_->CanStackAtTop(window)) { 1668 if (!access_policy_->CanStackAtTop(window)) {
1608 DVLOG(1) << "StackAtTop failed (access denied)"; 1669 DVLOG(1) << "StackAtTop failed (access denied)";
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 2141 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2081 effect_bitmask, callback); 2142 effect_bitmask, callback);
2082 } 2143 }
2083 2144
2084 void WindowTree::PerformOnDragDropDone() { 2145 void WindowTree::PerformOnDragDropDone() {
2085 client()->OnDragDropDone(); 2146 client()->OnDragDropDone();
2086 } 2147 }
2087 2148
2088 } // namespace ws 2149 } // namespace ws
2089 } // namespace ui 2150 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698