| OLD | NEW |
| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 // If the client created this window, then do not route it through the WM. | 817 // If the client created this window, then do not route it through the WM. |
| 818 if (window->id().client_id == id_) | 818 if (window->id().client_id == id_) |
| 819 return false; | 819 return false; |
| 820 | 820 |
| 821 // If the client did not create the window, then it must be the root of the | 821 // If the client did not create the window, then it must be the root of the |
| 822 // client. If not, that means the client should not know about this window, | 822 // client. If not, that means the client should not know about this window, |
| 823 // and so do not route the request to the WM. | 823 // and so do not route the request to the WM. |
| 824 if (roots_.count(window) == 0) | 824 if (roots_.count(window) == 0) |
| 825 return false; | 825 return false; |
| 826 | 826 |
| 827 // The WindowManager is attached to the root of the Display, if there isn't a | 827 return IsWindowCreatedByWindowManager(window); |
| 828 // WindowManager attached no need to route to it. | |
| 829 const WindowManagerDisplayRoot* display_root = | |
| 830 GetWindowManagerDisplayRoot(window); | |
| 831 if (!display_root) | |
| 832 return false; | |
| 833 | |
| 834 // Route to the windowmanager if the windowmanager created the window. | |
| 835 return display_root->window_manager_state()->window_tree()->id() == | |
| 836 window->id().client_id; | |
| 837 } | 828 } |
| 838 | 829 |
| 839 void WindowTree::ProcessCaptureChanged(const ServerWindow* new_capture, | 830 void WindowTree::ProcessCaptureChanged(const ServerWindow* new_capture, |
| 840 const ServerWindow* old_capture, | 831 const ServerWindow* old_capture, |
| 841 bool originated_change) { | 832 bool originated_change) { |
| 842 ClientWindowId new_capture_window_client_id; | 833 ClientWindowId new_capture_window_client_id; |
| 843 ClientWindowId old_capture_window_client_id; | 834 ClientWindowId old_capture_window_client_id; |
| 844 const bool new_capture_window_known = | 835 const bool new_capture_window_known = |
| 845 IsWindowKnown(new_capture, &new_capture_window_client_id); | 836 IsWindowKnown(new_capture, &new_capture_window_client_id); |
| 846 const bool old_capture_window_known = | 837 const bool old_capture_window_known = |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 // The window isn't parented. There's nothing to do. | 1589 // The window isn't parented. There's nothing to do. |
| 1599 DVLOG(1) << "DeactivateWindow failed (window unparented)"; | 1590 DVLOG(1) << "DeactivateWindow failed (window unparented)"; |
| 1600 return; | 1591 return; |
| 1601 } | 1592 } |
| 1602 | 1593 |
| 1603 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); | 1594 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); |
| 1604 wm_tree->window_manager_internal_->WmDeactivateWindow( | 1595 wm_tree->window_manager_internal_->WmDeactivateWindow( |
| 1605 wm_tree->ClientWindowIdForWindow(window).id); | 1596 wm_tree->ClientWindowIdForWindow(window).id); |
| 1606 } | 1597 } |
| 1607 | 1598 |
| 1599 void WindowTree::StackAtTop(uint32_t change_id, Id window_id) { |
| 1600 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1601 if (!window) { |
| 1602 DVLOG(1) << "StackAtTop failed (invalid id)"; |
| 1603 client()->OnChangeCompleted(change_id, false); |
| 1604 return; |
| 1605 } |
| 1606 |
| 1607 if (!access_policy_->CanStackAtTop(window)) { |
| 1608 DVLOG(1) << "StackAtTop failed (access denied)"; |
| 1609 client()->OnChangeCompleted(change_id, false); |
| 1610 return; |
| 1611 } |
| 1612 |
| 1613 ServerWindow* parent = window->parent(); |
| 1614 if (!parent) { |
| 1615 DVLOG(1) << "StackAtTop failed (window unparented)"; |
| 1616 client()->OnChangeCompleted(change_id, false); |
| 1617 return; |
| 1618 } |
| 1619 |
| 1620 DCHECK(!parent->children().empty()); |
| 1621 if (parent->children().back() == window) { |
| 1622 // Ignore this call; the client didn't know they were already at the top. |
| 1623 DVLOG(3) << "StackAtTop ignored (already at top)"; |
| 1624 client()->OnChangeCompleted(change_id, true); |
| 1625 return; |
| 1626 } |
| 1627 |
| 1628 ServerWindow* relative_window = parent->children().back(); |
| 1629 Operation op(this, window_server_, OperationType::REORDER_WINDOW); |
| 1630 window->Reorder(relative_window, mojom::OrderDirection::ABOVE); |
| 1631 window_server_->ProcessWindowReorder(window, relative_window, |
| 1632 mojom::OrderDirection::ABOVE); |
| 1633 |
| 1634 client()->OnChangeCompleted(change_id, true); |
| 1635 } |
| 1636 |
| 1608 void WindowTree::GetWindowManagerClient( | 1637 void WindowTree::GetWindowManagerClient( |
| 1609 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) { | 1638 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) { |
| 1610 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ || | 1639 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ || |
| 1611 window_manager_internal_client_binding_) { | 1640 window_manager_internal_client_binding_) { |
| 1612 return; | 1641 return; |
| 1613 } | 1642 } |
| 1614 window_manager_internal_client_binding_.reset( | 1643 window_manager_internal_client_binding_.reset( |
| 1615 new mojo::AssociatedBinding<mojom::WindowManagerClient>( | 1644 new mojo::AssociatedBinding<mojom::WindowManagerClient>( |
| 1616 this, std::move(internal))); | 1645 this, std::move(internal))); |
| 1617 } | 1646 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 const ServerWindow* window) const { | 1958 const ServerWindow* window) const { |
| 1930 return IsWindowKnown(window); | 1959 return IsWindowKnown(window); |
| 1931 } | 1960 } |
| 1932 | 1961 |
| 1933 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1962 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1934 const ServerWindow* window) const { | 1963 const ServerWindow* window) const { |
| 1935 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1964 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
| 1936 return tree && tree != this; | 1965 return tree && tree != this; |
| 1937 } | 1966 } |
| 1938 | 1967 |
| 1968 bool WindowTree::IsWindowCreatedByWindowManager( |
| 1969 const ServerWindow* window) const { |
| 1970 // The WindowManager is attached to the root of the Display, if there isn't a |
| 1971 // WindowManager attached, the window manager didn't create this window. |
| 1972 const WindowManagerDisplayRoot* display_root = |
| 1973 GetWindowManagerDisplayRoot(window); |
| 1974 if (!display_root) |
| 1975 return false; |
| 1976 |
| 1977 return display_root->window_manager_state()->window_tree()->id() == |
| 1978 window->id().client_id; |
| 1979 } |
| 1980 |
| 1939 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) { | 1981 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) { |
| 1940 DCHECK(window_server_->in_drag_loop()); | 1982 DCHECK(window_server_->in_drag_loop()); |
| 1941 | 1983 |
| 1942 if (window_server_->GetCurrentDragLoopInitiator() != this) | 1984 if (window_server_->GetCurrentDragLoopInitiator() != this) |
| 1943 return; | 1985 return; |
| 1944 | 1986 |
| 1945 uint32_t change_id = window_server_->GetCurrentDragLoopChangeId(); | 1987 uint32_t change_id = window_server_->GetCurrentDragLoopChangeId(); |
| 1946 ServerWindow* window = window_server_->GetCurrentDragLoopWindow(); | 1988 ServerWindow* window = window_server_->GetCurrentDragLoopWindow(); |
| 1947 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); | 1989 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1948 if (!display_root) | 1990 if (!display_root) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2072 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 2031 effect_bitmask, callback); | 2073 effect_bitmask, callback); |
| 2032 } | 2074 } |
| 2033 | 2075 |
| 2034 void WindowTree::PerformOnDragDropDone() { | 2076 void WindowTree::PerformOnDragDropDone() { |
| 2035 client()->OnDragDropDone(); | 2077 client()->OnDragDropDone(); |
| 2036 } | 2078 } |
| 2037 | 2079 |
| 2038 } // namespace ws | 2080 } // namespace ws |
| 2039 } // namespace ui | 2081 } // namespace ui |
| OLD | NEW |