| 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 17 matching lines...) Expand all Loading... |
| 28 #include "services/ui/ws/window_manager_state.h" | 28 #include "services/ui/ws/window_manager_state.h" |
| 29 #include "services/ui/ws/window_server.h" | 29 #include "services/ui/ws/window_server.h" |
| 30 #include "services/ui/ws/window_tree_binding.h" | 30 #include "services/ui/ws/window_tree_binding.h" |
| 31 #include "ui/display/display.h" | 31 #include "ui/display/display.h" |
| 32 #include "ui/display/types/display_constants.h" | 32 #include "ui/display/types/display_constants.h" |
| 33 #include "ui/platform_window/mojo/ime_type_converters.h" | 33 #include "ui/platform_window/mojo/ime_type_converters.h" |
| 34 #include "ui/platform_window/text_input_state.h" | 34 #include "ui/platform_window/text_input_state.h" |
| 35 | 35 |
| 36 using mojo::InterfaceRequest; | 36 using mojo::InterfaceRequest; |
| 37 | 37 |
| 38 using EventProperties = std::unordered_map<std::string, std::vector<uint8_t>>; |
| 39 |
| 38 namespace ui { | 40 namespace ui { |
| 39 namespace ws { | 41 namespace ws { |
| 40 | 42 |
| 41 class TargetedEvent : public ServerWindowObserver { | 43 class TargetedEvent : public ServerWindowObserver { |
| 42 public: | 44 public: |
| 43 TargetedEvent(ServerWindow* target, const ui::Event& event) | 45 TargetedEvent(ServerWindow* target, const ui::Event& event) |
| 44 : target_(target), event_(ui::Event::Clone(event)) { | 46 : target_(target), event_(ui::Event::Clone(event)) { |
| 45 target_->AddObserver(this); | 47 target_->AddObserver(this); |
| 46 } | 48 } |
| 47 ~TargetedEvent() override { | 49 ~TargetedEvent() override { |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 550 } |
| 549 } | 551 } |
| 550 | 552 |
| 551 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { | 553 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { |
| 552 client()->OnChangeCompleted(change_id, success); | 554 client()->OnChangeCompleted(change_id, success); |
| 553 } | 555 } |
| 554 | 556 |
| 555 void WindowTree::OnAccelerator(uint32_t accelerator_id, | 557 void WindowTree::OnAccelerator(uint32_t accelerator_id, |
| 556 const ui::Event& event, | 558 const ui::Event& event, |
| 557 bool needs_ack) { | 559 bool needs_ack) { |
| 560 DVLOG(3) << "OnAccelerator client=" << id_; |
| 558 DCHECK(window_manager_internal_); | 561 DCHECK(window_manager_internal_); |
| 559 if (needs_ack) | 562 if (needs_ack) |
| 560 GenerateEventAckId(); | 563 GenerateEventAckId(); |
| 561 else | 564 else |
| 562 DCHECK_EQ(0u, event_ack_id_); | 565 DCHECK_EQ(0u, event_ack_id_); |
| 563 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map | 566 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map |
| 564 // mojom::Event directly to ui::Event. | 567 // mojom::Event directly to ui::Event. |
| 565 window_manager_internal_->OnAccelerator(event_ack_id_, accelerator_id, | 568 window_manager_internal_->OnAccelerator(event_ack_id_, accelerator_id, |
| 566 ui::Event::Clone(event)); | 569 ui::Event::Clone(event)); |
| 567 } | 570 } |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 DCHECK(!event_ack_id_); | 1173 DCHECK(!event_ack_id_); |
| 1171 // We do not want to create a sequential id for each event, because that can | 1174 // We do not want to create a sequential id for each event, because that can |
| 1172 // leak some information to the client. So instead, manufacture the id | 1175 // leak some information to the client. So instead, manufacture the id |
| 1173 // randomly. | 1176 // randomly. |
| 1174 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); | 1177 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); |
| 1175 return event_ack_id_; | 1178 return event_ack_id_; |
| 1176 } | 1179 } |
| 1177 | 1180 |
| 1178 void WindowTree::DispatchInputEventImpl(ServerWindow* target, | 1181 void WindowTree::DispatchInputEventImpl(ServerWindow* target, |
| 1179 const ui::Event& event) { | 1182 const ui::Event& event) { |
| 1183 DVLOG(3) << "DispatchInputEventImpl client=" << id_; |
| 1180 GenerateEventAckId(); | 1184 GenerateEventAckId(); |
| 1181 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); | 1185 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); |
| 1182 DCHECK(display_root); | 1186 DCHECK(display_root); |
| 1183 event_source_wms_ = display_root->window_manager_state(); | 1187 event_source_wms_ = display_root->window_manager_state(); |
| 1184 // Should only get events from windows attached to a host. | 1188 // Should only get events from windows attached to a host. |
| 1185 DCHECK(event_source_wms_); | 1189 DCHECK(event_source_wms_); |
| 1186 bool matched_pointer_watcher = EventMatchesPointerWatcher(event); | 1190 bool matched_pointer_watcher = EventMatchesPointerWatcher(event); |
| 1187 Display* display = GetDisplay(target); | 1191 Display* display = GetDisplay(target); |
| 1188 DCHECK(display); | 1192 DCHECK(display); |
| 1189 client()->OnWindowInputEvent( | 1193 client()->OnWindowInputEvent( |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 window->SetTextInputState(state.To<ui::TextInputState>()); | 1497 window->SetTextInputState(state.To<ui::TextInputState>()); |
| 1494 | 1498 |
| 1495 Display* display = GetDisplay(window); | 1499 Display* display = GetDisplay(window); |
| 1496 if (display) | 1500 if (display) |
| 1497 display->SetImeVisibility(window, visible); | 1501 display->SetImeVisibility(window, visible); |
| 1498 } | 1502 } |
| 1499 } | 1503 } |
| 1500 | 1504 |
| 1501 void WindowTree::OnWindowInputEventAck(uint32_t event_id, | 1505 void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
| 1502 mojom::EventResult result) { | 1506 mojom::EventResult result) { |
| 1507 DVLOG(3) << "OnWindowInputEventAck client=" << id_; |
| 1503 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | 1508 if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
| 1504 // TODO(sad): Something bad happened. Kill the client? | 1509 // TODO(sad): Something bad happened. Kill the client? |
| 1505 NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id | 1510 NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id |
| 1506 << ", event_ack_id_=" << event_ack_id_; | 1511 << ", event_ack_id_=" << event_ack_id_; |
| 1507 DVLOG(1) << "OnWindowInputEventAck supplied unexpected event_id"; | 1512 DVLOG(1) << "OnWindowInputEventAck supplied unexpected event_id"; |
| 1508 } | 1513 } |
| 1509 event_ack_id_ = 0; | 1514 event_ack_id_ = 0; |
| 1510 | 1515 |
| 1511 if (janky_) | 1516 if (janky_) |
| 1512 event_source_wms_->window_tree()->ClientJankinessChanged(this); | 1517 event_source_wms_->window_tree()->ClientJankinessChanged(this); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 GetWindowByClientId(ClientWindowId(transport_window_id)); | 2071 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 2067 if (window && window->id().client_id != id_) { | 2072 if (window && window->id().client_id != id_) { |
| 2068 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; | 2073 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; |
| 2069 window_server_->WindowManagerSentBogusMessage(); | 2074 window_server_->WindowManagerSentBogusMessage(); |
| 2070 window = nullptr; | 2075 window = nullptr; |
| 2071 } | 2076 } |
| 2072 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); | 2077 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
| 2073 } | 2078 } |
| 2074 | 2079 |
| 2075 void WindowTree::OnAcceleratorAck(uint32_t event_id, | 2080 void WindowTree::OnAcceleratorAck(uint32_t event_id, |
| 2076 mojom::EventResult result) { | 2081 mojom::EventResult result, |
| 2082 const EventProperties& properties) { |
| 2083 DVLOG(3) << "OnAcceleratorAck client=" << id_; |
| 2077 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | 2084 if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
| 2078 DVLOG(1) << "OnAcceleratorAck supplied invalid event_id"; | 2085 DVLOG(1) << "OnAcceleratorAck supplied invalid event_id"; |
| 2079 window_server_->WindowManagerSentBogusMessage(); | 2086 window_server_->WindowManagerSentBogusMessage(); |
| 2080 return; | 2087 return; |
| 2081 } | 2088 } |
| 2082 event_ack_id_ = 0; | 2089 event_ack_id_ = 0; |
| 2083 DCHECK(window_manager_state_); | 2090 DCHECK(window_manager_state_); |
| 2084 window_manager_state_->OnAcceleratorAck(result); | 2091 window_manager_state_->OnAcceleratorAck(result, properties); |
| 2085 } | 2092 } |
| 2086 | 2093 |
| 2087 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { | 2094 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
| 2088 return HasRoot(window); | 2095 return HasRoot(window); |
| 2089 } | 2096 } |
| 2090 | 2097 |
| 2091 bool WindowTree::IsWindowKnownForAccessPolicy( | 2098 bool WindowTree::IsWindowKnownForAccessPolicy( |
| 2092 const ServerWindow* window) const { | 2099 const ServerWindow* window) const { |
| 2093 return IsWindowKnown(window); | 2100 return IsWindowKnown(window); |
| 2094 } | 2101 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2213 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 2207 effect_bitmask, callback); | 2214 effect_bitmask, callback); |
| 2208 } | 2215 } |
| 2209 | 2216 |
| 2210 void WindowTree::PerformOnDragDropDone() { | 2217 void WindowTree::PerformOnDragDropDone() { |
| 2211 client()->OnDragDropDone(); | 2218 client()->OnDragDropDone(); |
| 2212 } | 2219 } |
| 2213 | 2220 |
| 2214 } // namespace ws | 2221 } // namespace ws |
| 2215 } // namespace ui | 2222 } // namespace ui |
| OLD | NEW |