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

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

Issue 2092343002: Touch HUD app for mustash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change window manager connection unittest to original Created 4 years, 5 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') | ui/views/controls/touch/touch_hud_drawer.h » ('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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // Should only get events from windows attached to a host. 974 // Should only get events from windows attached to a host.
975 DCHECK(event_source_wms_); 975 DCHECK(event_source_wms_);
976 bool matched_observer = 976 bool matched_observer =
977 event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event); 977 event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event);
978 client()->OnWindowInputEvent( 978 client()->OnWindowInputEvent(
979 event_ack_id_, ClientWindowIdForWindow(target).id, 979 event_ack_id_, ClientWindowIdForWindow(target).id,
980 ui::Event::Clone(event), matched_observer ? event_observer_id_ : 0); 980 ui::Event::Clone(event), matched_observer ? event_observer_id_ : 0);
981 } 981 }
982 982
983 void WindowTree::SendToEventObserver(const ui::Event& event) { 983 void WindowTree::SendToEventObserver(const ui::Event& event) {
984 if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event)) 984 if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event)) {
985 client()->OnEventObserved(ui::Event::Clone(event), event_observer_id_); 985 client()->OnEventObserved(ui::Event::Clone(event), event_observer_id_);
986 }
986 } 987 }
987 988
988 void WindowTree::NewWindow( 989 void WindowTree::NewWindow(
989 uint32_t change_id, 990 uint32_t change_id,
990 Id transport_window_id, 991 Id transport_window_id,
991 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 992 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
992 std::map<std::string, std::vector<uint8_t>> properties; 993 std::map<std::string, std::vector<uint8_t>> properties;
993 if (!transport_properties.is_null()) { 994 if (!transport_properties.is_null()) {
994 properties = 995 properties =
995 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 996 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 uint32_t observer_id) { 1151 uint32_t observer_id) {
1151 if (matcher.is_null() || observer_id == 0) { 1152 if (matcher.is_null() || observer_id == 0) {
1152 // Clear any existing event observer. 1153 // Clear any existing event observer.
1153 event_observer_matcher_.reset(); 1154 event_observer_matcher_.reset();
1154 event_observer_id_ = 0; 1155 event_observer_id_ = 0;
1155 return; 1156 return;
1156 } 1157 }
1157 1158
1158 // Do not allow key events to be observed, as a compromised app could register 1159 // Do not allow key events to be observed, as a compromised app could register
1159 // itself as an event observer and spy on keystrokes to another app. 1160 // itself as an event observer and spy on keystrokes to another app.
1160 if (!matcher->type_matcher) { 1161 if (!matcher->type_matcher && !matcher->pointer_kind_matcher) {
1161 DVLOG(1) << "SetEventObserver must specify an event type."; 1162 DVLOG(1) << "SetEventObserver must specify an event type.";
1162 return; 1163 return;
1163 } 1164 }
1165
1164 const ui::mojom::EventType event_type_whitelist[] = { 1166 const ui::mojom::EventType event_type_whitelist[] = {
1165 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, 1167 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN,
1166 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, 1168 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP,
1167 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, 1169 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL,
1168 }; 1170 };
1171 const ui::mojom::PointerKind pointer_kind_whitelist[] = {
1172 ui::mojom::PointerKind::MOUSE, ui::mojom::PointerKind::TOUCH,
1173 };
1174
1169 bool allowed = false; 1175 bool allowed = false;
1170 for (ui::mojom::EventType event_type : event_type_whitelist) { 1176 if (matcher->type_matcher) {
1171 if (matcher->type_matcher->type == event_type) { 1177 for (ui::mojom::EventType event_type : event_type_whitelist) {
1172 allowed = true; 1178 if (matcher->type_matcher->type == event_type) {
1173 break; 1179 allowed = true;
1180 break;
1181 }
1182 }
1183 } else if (matcher->pointer_kind_matcher) {
1184 for (ui::mojom::PointerKind pointer : pointer_kind_whitelist) {
1185 if (matcher->pointer_kind_matcher->pointer_kind == pointer) {
1186 allowed = true;
1187 break;
1188 }
1174 } 1189 }
1175 } 1190 }
1176 if (!allowed) { 1191 if (!allowed) {
1177 DVLOG(1) << "SetEventObserver event type not allowed"; 1192 DVLOG(1) << "SetEventObserver event type not allowed";
1178 return; 1193 return;
1179 } 1194 }
1180 1195
1181 event_observer_matcher_.reset(new EventMatcher(*matcher)); 1196 event_observer_matcher_.reset(new EventMatcher(*matcher));
1182 event_observer_id_ = observer_id; 1197 event_observer_id_ = observer_id;
1183 } 1198 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 this, std::move(internal))); 1416 this, std::move(internal)));
1402 } 1417 }
1403 1418
1404 void WindowTree::GetCursorLocationMemory( 1419 void WindowTree::GetCursorLocationMemory(
1405 const GetCursorLocationMemoryCallback& callback) { 1420 const GetCursorLocationMemoryCallback& callback) {
1406 callback.Run( 1421 callback.Run(
1407 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> 1422 window_server_->display_manager()->GetUserDisplayManager(user_id_)->
1408 GetCursorLocationMemory()); 1423 GetCursorLocationMemory());
1409 } 1424 }
1410 1425
1426 void WindowTree::SetAcceptEvents(Id transport_window_id, bool accept_events) {
1427 ServerWindow* window =
1428 GetWindowByClientId(ClientWindowId(transport_window_id));
1429 if (window)
1430 window->SetAcceptEvents(accept_events);
1431 }
1432
1411 void WindowTree::AddAccelerator(uint32_t id, 1433 void WindowTree::AddAccelerator(uint32_t id,
1412 mojom::EventMatcherPtr event_matcher, 1434 mojom::EventMatcherPtr event_matcher,
1413 const AddAcceleratorCallback& callback) { 1435 const AddAcceleratorCallback& callback) {
1414 DCHECK(window_manager_state_); 1436 DCHECK(window_manager_state_);
1415 const bool success = 1437 const bool success =
1416 window_manager_state_->event_dispatcher()->AddAccelerator( 1438 window_manager_state_->event_dispatcher()->AddAccelerator(
1417 id, std::move(event_matcher)); 1439 id, std::move(event_matcher));
1418 callback.Run(success); 1440 callback.Run(success);
1419 } 1441 }
1420 1442
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 } 1552 }
1531 1553
1532 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1554 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1533 const ServerWindow* window) const { 1555 const ServerWindow* window) const {
1534 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1556 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1535 return tree && tree != this; 1557 return tree && tree != this;
1536 } 1558 }
1537 1559
1538 } // namespace ws 1560 } // namespace ws
1539 } // namespace ui 1561 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | ui/views/controls/touch/touch_hud_drawer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698