Chromium Code Reviews| 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/public/cpp/window_tree_client.h" | 5 #include "services/ui/public/cpp/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 base::subtle::Atomic32 location = | 625 base::subtle::Atomic32 location = |
| 626 base::subtle::NoBarrier_Load(cursor_location_memory()); | 626 base::subtle::NoBarrier_Load(cursor_location_memory()); |
| 627 return gfx::Point(static_cast<int16_t>(location >> 16), | 627 return gfx::Point(static_cast<int16_t>(location >> 16), |
| 628 static_cast<int16_t>(location & 0xFFFF)); | 628 static_cast<int16_t>(location & 0xFFFF)); |
| 629 } | 629 } |
| 630 | 630 |
| 631 void WindowTreeClient::StartPointerWatcher(bool want_moves) { | 631 void WindowTreeClient::StartPointerWatcher(bool want_moves) { |
| 632 if (has_pointer_watcher_) | 632 if (has_pointer_watcher_) |
| 633 StopPointerWatcher(); | 633 StopPointerWatcher(); |
| 634 has_pointer_watcher_ = true; | 634 has_pointer_watcher_ = true; |
| 635 pointer_watcher_id_++; | 635 tree_->StartPointerWatcher(want_moves); |
| 636 if (pointer_watcher_id_ == 0) | |
| 637 pointer_watcher_id_++; | |
| 638 tree_->StartPointerWatcher(want_moves, pointer_watcher_id_); | |
| 639 } | 636 } |
| 640 | 637 |
| 641 void WindowTreeClient::StopPointerWatcher() { | 638 void WindowTreeClient::StopPointerWatcher() { |
| 642 DCHECK(has_pointer_watcher_); | 639 DCHECK(has_pointer_watcher_); |
| 643 tree_->StopPointerWatcher(); | 640 tree_->StopPointerWatcher(); |
| 644 has_pointer_watcher_ = false; | 641 has_pointer_watcher_ = false; |
| 645 } | 642 } |
| 646 | 643 |
| 647 void WindowTreeClient::PerformWindowMove( | 644 void WindowTreeClient::PerformWindowMove( |
| 648 Window* window, | 645 Window* window, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 InFlightPropertyChange new_change(window, name, new_data); | 971 InFlightPropertyChange new_change(window, name, new_data); |
| 975 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 972 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
| 976 return; | 973 return; |
| 977 | 974 |
| 978 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); | 975 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); |
| 979 } | 976 } |
| 980 | 977 |
| 981 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, | 978 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, |
| 982 Id window_id, | 979 Id window_id, |
| 983 std::unique_ptr<ui::Event> event, | 980 std::unique_ptr<ui::Event> event, |
| 984 uint32_t pointer_watcher_id) { | 981 bool matches_pointer_watcher) { |
| 985 DCHECK(event); | 982 DCHECK(event); |
| 986 Window* window = GetWindowByServerId(window_id); // May be null. | 983 Window* window = GetWindowByServerId(window_id); // May be null. |
| 987 | 984 |
| 988 // Non-zero pointer_watcher_id means it matched a pointer watcher on the | 985 // Non-zero pointer_watcher_id means it matched a pointer watcher on the |
|
msw
2016/08/18 22:45:23
nit: update comment
sky
2016/08/18 23:17:14
I just removed the comment as the code isn't parti
| |
| 989 // server. | 986 // server. |
| 990 if (pointer_watcher_id_ != 0 && has_pointer_watcher_ && | 987 if (matches_pointer_watcher && has_pointer_watcher_) { |
| 991 pointer_watcher_id == pointer_watcher_id_) { | |
| 992 DCHECK(event->IsPointerEvent()); | 988 DCHECK(event->IsPointerEvent()); |
| 993 delegate_->OnPointerEventObserved(*event->AsPointerEvent(), window); | 989 delegate_->OnPointerEventObserved(*event->AsPointerEvent(), window); |
| 994 } | 990 } |
| 995 | 991 |
| 996 if (!window || !window->input_event_handler_) { | 992 if (!window || !window->input_event_handler_) { |
| 997 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); | 993 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); |
| 998 return; | 994 return; |
| 999 } | 995 } |
| 1000 | 996 |
| 1001 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( | 997 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1016 &ack_callback); | 1012 &ack_callback); |
| 1017 } | 1013 } |
| 1018 | 1014 |
| 1019 // The handler did not take ownership of the callback, so we send the ack, | 1015 // The handler did not take ownership of the callback, so we send the ack, |
| 1020 // marking the event as not consumed. | 1016 // marking the event as not consumed. |
| 1021 if (ack_callback) | 1017 if (ack_callback) |
| 1022 ack_callback->Run(mojom::EventResult::UNHANDLED); | 1018 ack_callback->Run(mojom::EventResult::UNHANDLED); |
| 1023 } | 1019 } |
| 1024 | 1020 |
| 1025 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1021 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
| 1026 uint32_t pointer_watcher_id, | |
| 1027 uint32_t window_id) { | 1022 uint32_t window_id) { |
| 1028 DCHECK(event); | 1023 DCHECK(event); |
| 1029 DCHECK(event->IsPointerEvent()); | 1024 DCHECK(event->IsPointerEvent()); |
| 1030 if (has_pointer_watcher_ && pointer_watcher_id == pointer_watcher_id_) { | 1025 if (has_pointer_watcher_) { |
| 1031 Window* target_window = GetWindowByServerId(window_id); | 1026 Window* target_window = GetWindowByServerId(window_id); |
| 1032 delegate_->OnPointerEventObserved(*event->AsPointerEvent(), target_window); | 1027 delegate_->OnPointerEventObserved(*event->AsPointerEvent(), target_window); |
| 1033 } | 1028 } |
| 1034 } | 1029 } |
| 1035 | 1030 |
| 1036 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { | 1031 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { |
| 1037 Window* focused_window = GetWindowByServerId(focused_window_id); | 1032 Window* focused_window = GetWindowByServerId(focused_window_id); |
| 1038 InFlightFocusChange new_change(this, focused_window); | 1033 InFlightFocusChange new_change(this, focused_window); |
| 1039 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 1034 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
| 1040 return; | 1035 return; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 Window* window, | 1260 Window* window, |
| 1266 const gfx::Vector2d& offset, | 1261 const gfx::Vector2d& offset, |
| 1267 const gfx::Insets& hit_area) { | 1262 const gfx::Insets& hit_area) { |
| 1268 if (window_manager_internal_client_) { | 1263 if (window_manager_internal_client_) { |
| 1269 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1264 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1270 server_id(window), offset.x(), offset.y(), hit_area); | 1265 server_id(window), offset.x(), offset.y(), hit_area); |
| 1271 } | 1266 } |
| 1272 } | 1267 } |
| 1273 | 1268 |
| 1274 } // namespace ui | 1269 } // namespace ui |
| OLD | NEW |