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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 726 |
727 void WindowTree::SendToPointerWatcher(const ui::Event& event, | 727 void WindowTree::SendToPointerWatcher(const ui::Event& event, |
728 ServerWindow* target_window) { | 728 ServerWindow* target_window) { |
729 if (!EventMatchesPointerWatcher(event)) | 729 if (!EventMatchesPointerWatcher(event)) |
730 return; | 730 return; |
731 | 731 |
732 ClientWindowId client_window_id; | 732 ClientWindowId client_window_id; |
733 // Ignore the return value from IsWindowKnown() as in the case of the client | 733 // Ignore the return value from IsWindowKnown() as in the case of the client |
734 // not knowing the window we'll send 0, which corresponds to no window. | 734 // not knowing the window we'll send 0, which corresponds to no window. |
735 IsWindowKnown(target_window, &client_window_id); | 735 IsWindowKnown(target_window, &client_window_id); |
736 client()->OnPointerEventObserved(ui::Event::Clone(event), pointer_watcher_id_, | 736 client()->OnPointerEventObserved(ui::Event::Clone(event), |
737 client_window_id.id); | 737 client_window_id.id); |
738 } | 738 } |
739 | 739 |
740 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { | 740 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { |
741 if (window_manager_state_) | 741 if (window_manager_state_) |
742 return false; // We are the window manager, don't route to ourself. | 742 return false; // We are the window manager, don't route to ourself. |
743 | 743 |
744 // If the client created this window, then do not route it through the WM. | 744 // If the client created this window, then do not route it through the WM. |
745 if (window->id().client_id == id_) | 745 if (window->id().client_id == id_) |
746 return false; | 746 return false; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 const ui::Event& event) { | 1032 const ui::Event& event) { |
1033 GenerateEventAckId(); | 1033 GenerateEventAckId(); |
1034 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); | 1034 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); |
1035 DCHECK(display_root); | 1035 DCHECK(display_root); |
1036 event_source_wms_ = display_root->window_manager_state(); | 1036 event_source_wms_ = display_root->window_manager_state(); |
1037 // Should only get events from windows attached to a host. | 1037 // Should only get events from windows attached to a host. |
1038 DCHECK(event_source_wms_); | 1038 DCHECK(event_source_wms_); |
1039 bool matched_pointer_watcher = EventMatchesPointerWatcher(event); | 1039 bool matched_pointer_watcher = EventMatchesPointerWatcher(event); |
1040 client()->OnWindowInputEvent( | 1040 client()->OnWindowInputEvent( |
1041 event_ack_id_, ClientWindowIdForWindow(target).id, | 1041 event_ack_id_, ClientWindowIdForWindow(target).id, |
1042 ui::Event::Clone(event), | 1042 ui::Event::Clone(event), matched_pointer_watcher); |
1043 matched_pointer_watcher ? pointer_watcher_id_ : 0); | |
1044 } | 1043 } |
1045 | 1044 |
1046 bool WindowTree::EventMatchesPointerWatcher(const ui::Event& event) const { | 1045 bool WindowTree::EventMatchesPointerWatcher(const ui::Event& event) const { |
1047 if (pointer_watcher_id_ == 0) | 1046 if (!has_pointer_watcher_) |
1048 return false; | 1047 return false; |
1049 if (!event.IsPointerEvent()) | 1048 if (!event.IsPointerEvent()) |
1050 return false; | 1049 return false; |
1051 if (pointer_watcher_want_moves_ && event.type() == ui::ET_POINTER_MOVED) | 1050 if (pointer_watcher_want_moves_ && event.type() == ui::ET_POINTER_MOVED) |
1052 return true; | 1051 return true; |
1053 return event.type() == ui::ET_POINTER_DOWN || | 1052 return event.type() == ui::ET_POINTER_DOWN || |
1054 event.type() == ui::ET_POINTER_UP; | 1053 event.type() == ui::ET_POINTER_UP; |
1055 } | 1054 } |
1056 | 1055 |
1057 void WindowTree::NewWindow( | 1056 void WindowTree::NewWindow( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1195 |
1197 void WindowTree::SetCapture(uint32_t change_id, Id window_id) { | 1196 void WindowTree::SetCapture(uint32_t change_id, Id window_id) { |
1198 client()->OnChangeCompleted(change_id, SetCapture(ClientWindowId(window_id))); | 1197 client()->OnChangeCompleted(change_id, SetCapture(ClientWindowId(window_id))); |
1199 } | 1198 } |
1200 | 1199 |
1201 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { | 1200 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { |
1202 client()->OnChangeCompleted(change_id, | 1201 client()->OnChangeCompleted(change_id, |
1203 ReleaseCapture(ClientWindowId(window_id))); | 1202 ReleaseCapture(ClientWindowId(window_id))); |
1204 } | 1203 } |
1205 | 1204 |
1206 void WindowTree::StartPointerWatcher(bool want_moves, | 1205 void WindowTree::StartPointerWatcher(bool want_moves) { |
1207 uint32_t pointer_watcher_id) { | 1206 has_pointer_watcher_ = true; |
1208 if (pointer_watcher_id == 0) { | |
1209 DVLOG(1) << "StartPointerWatcher called with 0."; | |
1210 StopPointerWatcher(); | |
1211 return; | |
1212 } | |
1213 pointer_watcher_want_moves_ = want_moves; | 1207 pointer_watcher_want_moves_ = want_moves; |
1214 pointer_watcher_id_ = pointer_watcher_id; | |
1215 } | 1208 } |
1216 | 1209 |
1217 void WindowTree::StopPointerWatcher() { | 1210 void WindowTree::StopPointerWatcher() { |
| 1211 has_pointer_watcher_ = false; |
1218 pointer_watcher_want_moves_ = false; | 1212 pointer_watcher_want_moves_ = false; |
1219 pointer_watcher_id_ = 0; | |
1220 } | 1213 } |
1221 | 1214 |
1222 void WindowTree::SetWindowBounds(uint32_t change_id, | 1215 void WindowTree::SetWindowBounds(uint32_t change_id, |
1223 Id window_id, | 1216 Id window_id, |
1224 const gfx::Rect& bounds) { | 1217 const gfx::Rect& bounds) { |
1225 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1218 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
1226 if (window && ShouldRouteToWindowManager(window)) { | 1219 if (window && ShouldRouteToWindowManager(window)) { |
1227 const uint32_t wm_change_id = | 1220 const uint32_t wm_change_id = |
1228 window_server_->GenerateWindowManagerChangeId(this, change_id); | 1221 window_server_->GenerateWindowManagerChangeId(this, change_id); |
1229 // |window_id| may be a client id, use the id from the window to ensure | 1222 // |window_id| may be a client id, use the id from the window to ensure |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 } | 1674 } |
1682 | 1675 |
1683 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1676 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1684 const ServerWindow* window) const { | 1677 const ServerWindow* window) const { |
1685 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1678 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1686 return tree && tree != this; | 1679 return tree && tree != this; |
1687 } | 1680 } |
1688 | 1681 |
1689 } // namespace ws | 1682 } // namespace ws |
1690 } // namespace ui | 1683 } // namespace ui |
OLD | NEW |