| 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 "components/mus/ws/window_tree.h" | 5 #include "components/mus/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "components/mus/ws/default_access_policy.h" | 13 #include "components/mus/ws/default_access_policy.h" |
| 14 #include "components/mus/ws/display.h" | 14 #include "components/mus/ws/display.h" |
| 15 #include "components/mus/ws/display_manager.h" | 15 #include "components/mus/ws/display_manager.h" |
| 16 #include "components/mus/ws/event_matcher.h" |
| 16 #include "components/mus/ws/focus_controller.h" | 17 #include "components/mus/ws/focus_controller.h" |
| 17 #include "components/mus/ws/operation.h" | 18 #include "components/mus/ws/operation.h" |
| 18 #include "components/mus/ws/platform_display.h" | 19 #include "components/mus/ws/platform_display.h" |
| 19 #include "components/mus/ws/server_window.h" | 20 #include "components/mus/ws/server_window.h" |
| 20 #include "components/mus/ws/server_window_observer.h" | 21 #include "components/mus/ws/server_window_observer.h" |
| 21 #include "components/mus/ws/window_manager_state.h" | 22 #include "components/mus/ws/window_manager_state.h" |
| 22 #include "components/mus/ws/window_server.h" | 23 #include "components/mus/ws/window_server.h" |
| 23 #include "components/mus/ws/window_tree_binding.h" | 24 #include "components/mus/ws/window_tree_binding.h" |
| 24 #include "mojo/converters/geometry/geometry_type_converters.h" | 25 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 25 #include "mojo/converters/ime/ime_type_converters.h" | 26 #include "mojo/converters/ime/ime_type_converters.h" |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 const ui::Event& event) { | 945 const ui::Event& event) { |
| 945 DCHECK(!event_ack_id_); | 946 DCHECK(!event_ack_id_); |
| 946 // We do not want to create a sequential id for each event, because that can | 947 // We do not want to create a sequential id for each event, because that can |
| 947 // leak some information to the client. So instead, manufacture the id | 948 // leak some information to the client. So instead, manufacture the id |
| 948 // randomly. | 949 // randomly. |
| 949 // TODO(moshayedi): Find a faster way to generate ids. | 950 // TODO(moshayedi): Find a faster way to generate ids. |
| 950 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); | 951 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); |
| 951 event_source_wms_ = GetWindowManagerState(target); | 952 event_source_wms_ = GetWindowManagerState(target); |
| 952 // Should only get events from windows attached to a host. | 953 // Should only get events from windows attached to a host. |
| 953 DCHECK(event_source_wms_); | 954 DCHECK(event_source_wms_); |
| 955 bool matched_observer = |
| 956 event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event); |
| 954 client()->OnWindowInputEvent(event_ack_id_, | 957 client()->OnWindowInputEvent(event_ack_id_, |
| 955 ClientWindowIdForWindow(target).id, | 958 ClientWindowIdForWindow(target).id, |
| 956 mojom::Event::From(event)); | 959 mojom::Event::From(event), matched_observer); |
| 960 } |
| 961 |
| 962 void WindowTree::SendToEventObserver(const ui::Event& event) { |
| 963 if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event)) |
| 964 client()->OnEventObserved(mojom::Event::From(event)); |
| 957 } | 965 } |
| 958 | 966 |
| 959 void WindowTree::NewWindow( | 967 void WindowTree::NewWindow( |
| 960 uint32_t change_id, | 968 uint32_t change_id, |
| 961 Id transport_window_id, | 969 Id transport_window_id, |
| 962 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { | 970 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { |
| 963 std::map<std::string, std::vector<uint8_t>> properties; | 971 std::map<std::string, std::vector<uint8_t>> properties; |
| 964 if (!transport_properties.is_null()) { | 972 if (!transport_properties.is_null()) { |
| 965 properties = | 973 properties = |
| 966 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); | 974 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 (!current_capture_window || | 1110 (!current_capture_window || |
| 1103 access_policy_->CanSetCapture(current_capture_window)) && | 1111 access_policy_->CanSetCapture(current_capture_window)) && |
| 1104 window == current_capture_window; | 1112 window == current_capture_window; |
| 1105 if (success) { | 1113 if (success) { |
| 1106 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE); | 1114 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE); |
| 1107 success = wms->SetCapture(nullptr, false); | 1115 success = wms->SetCapture(nullptr, false); |
| 1108 } | 1116 } |
| 1109 client()->OnChangeCompleted(change_id, success); | 1117 client()->OnChangeCompleted(change_id, success); |
| 1110 } | 1118 } |
| 1111 | 1119 |
| 1120 void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher) { |
| 1121 if (!matcher.is_null()) |
| 1122 event_observer_matcher_.reset(new EventMatcher(*matcher)); |
| 1123 else |
| 1124 event_observer_matcher_.reset(); |
| 1125 } |
| 1126 |
| 1112 void WindowTree::SetWindowBounds(uint32_t change_id, | 1127 void WindowTree::SetWindowBounds(uint32_t change_id, |
| 1113 Id window_id, | 1128 Id window_id, |
| 1114 mojo::RectPtr bounds) { | 1129 mojo::RectPtr bounds) { |
| 1115 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1130 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1116 if (window && ShouldRouteToWindowManager(window)) { | 1131 if (window && ShouldRouteToWindowManager(window)) { |
| 1117 const uint32_t wm_change_id = | 1132 const uint32_t wm_change_id = |
| 1118 window_server_->GenerateWindowManagerChangeId(this, change_id); | 1133 window_server_->GenerateWindowManagerChangeId(this, change_id); |
| 1119 // |window_id| may be a client id, use the id from the window to ensure | 1134 // |window_id| may be a client id, use the id from the window to ensure |
| 1120 // the windowmanager doesn't get an id it doesn't know about. | 1135 // the windowmanager doesn't get an id it doesn't know about. |
| 1121 WindowManagerState* wms = display_manager() | 1136 WindowManagerState* wms = display_manager() |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 } | 1424 } |
| 1410 | 1425 |
| 1411 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1426 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1412 const ServerWindow* window) const { | 1427 const ServerWindow* window) const { |
| 1413 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1428 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
| 1414 return tree && tree != this; | 1429 return tree && tree != this; |
| 1415 } | 1430 } |
| 1416 | 1431 |
| 1417 } // namespace ws | 1432 } // namespace ws |
| 1418 } // namespace mus | 1433 } // namespace mus |
| OLD | NEW |