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

Side by Side Diff: components/mus/ws/window_tree.cc

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 "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_tester.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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_);
954 client()->OnWindowInputEvent(event_ack_id_, 955 client()->OnWindowInputEvent(event_ack_id_,
955 ClientWindowIdForWindow(target).id, 956 ClientWindowIdForWindow(target).id,
956 mojom::Event::From(event)); 957 mojom::Event::From(event));
957 } 958 }
958 959
960 void WindowTree::SendToEventObserver(const ui::Event& event) {
961 if (event_observer_tester_ && event_observer_tester_->MatchesEvent(event))
962 client()->OnEventObserved(mojom::Event::From(event));
sky 2016/04/21 17:23:04 If the event was targetted at this client, then I
James Cook 2016/04/22 18:22:55 Done.
963 }
964
959 void WindowTree::NewWindow( 965 void WindowTree::NewWindow(
960 uint32_t change_id, 966 uint32_t change_id,
961 Id transport_window_id, 967 Id transport_window_id,
962 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 968 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
963 std::map<std::string, std::vector<uint8_t>> properties; 969 std::map<std::string, std::vector<uint8_t>> properties;
964 if (!transport_properties.is_null()) { 970 if (!transport_properties.is_null()) {
965 properties = 971 properties =
966 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 972 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
967 } 973 }
968 client()->OnChangeCompleted( 974 client()->OnChangeCompleted(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 (!current_capture_window || 1108 (!current_capture_window ||
1103 access_policy_->CanSetCapture(current_capture_window)) && 1109 access_policy_->CanSetCapture(current_capture_window)) &&
1104 window == current_capture_window; 1110 window == current_capture_window;
1105 if (success) { 1111 if (success) {
1106 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE); 1112 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE);
1107 success = wms->SetCapture(nullptr, false); 1113 success = wms->SetCapture(nullptr, false);
1108 } 1114 }
1109 client()->OnChangeCompleted(change_id, success); 1115 client()->OnChangeCompleted(change_id, success);
1110 } 1116 }
1111 1117
1118 void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher) {
1119 event_observer_tester_.reset(new EventTester(*matcher));
1120 }
1121
1122 void WindowTree::ClearEventObserver() {
1123 event_observer_tester_.reset();
1124 }
1125
1112 void WindowTree::SetWindowBounds(uint32_t change_id, 1126 void WindowTree::SetWindowBounds(uint32_t change_id,
1113 Id window_id, 1127 Id window_id,
1114 mojo::RectPtr bounds) { 1128 mojo::RectPtr bounds) {
1115 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1129 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1116 if (window && ShouldRouteToWindowManager(window)) { 1130 if (window && ShouldRouteToWindowManager(window)) {
1117 const uint32_t wm_change_id = 1131 const uint32_t wm_change_id =
1118 window_server_->GenerateWindowManagerChangeId(this, change_id); 1132 window_server_->GenerateWindowManagerChangeId(this, change_id);
1119 // |window_id| may be a client id, use the id from the window to ensure 1133 // |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. 1134 // the windowmanager doesn't get an id it doesn't know about.
1121 WindowManagerState* wms = display_manager() 1135 WindowManagerState* wms = display_manager()
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 } 1423 }
1410 1424
1411 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1425 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1412 const ServerWindow* window) const { 1426 const ServerWindow* window) const {
1413 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1427 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1414 return tree && tree != this; 1428 return tree && tree != this;
1415 } 1429 }
1416 1430
1417 } // namespace ws 1431 } // namespace ws
1418 } // namespace mus 1432 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698