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

Side by Side Diff: services/ui/public/cpp/window_tree_client.cc

Issue 2183163002: mus: Change PointerWatcher to observe all pointer events, with moves optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 "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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // We raced initialization. Return (0, 0). 619 // We raced initialization. Return (0, 0).
620 if (!cursor_location_memory()) 620 if (!cursor_location_memory())
621 return gfx::Point(); 621 return gfx::Point();
622 622
623 base::subtle::Atomic32 location = 623 base::subtle::Atomic32 location =
624 base::subtle::NoBarrier_Load(cursor_location_memory()); 624 base::subtle::NoBarrier_Load(cursor_location_memory());
625 return gfx::Point(static_cast<int16_t>(location >> 16), 625 return gfx::Point(static_cast<int16_t>(location >> 16),
626 static_cast<int16_t>(location & 0xFFFF)); 626 static_cast<int16_t>(location & 0xFFFF));
627 } 627 }
628 628
629 void WindowTreeClient::SetEventObserver(mojom::EventMatcherPtr matcher) { 629 void WindowTreeClient::StartPointerWatcher(bool want_moves) {
630 if (matcher.is_null()) { 630 if (has_pointer_watcher_)
631 has_event_observer_ = false; 631 StopPointerWatcher();
632 tree_->SetEventObserver(nullptr, 0u); 632 has_pointer_watcher_ = true;
633 } else { 633 pointer_watcher_id_++;
634 has_event_observer_ = true; 634 if (pointer_watcher_id_ == 0)
635 event_observer_id_++; 635 pointer_watcher_id_++;
636 tree_->SetEventObserver(std::move(matcher), event_observer_id_); 636 tree_->StartPointerWatcher(want_moves, pointer_watcher_id_);
637 } 637 }
638
639 void WindowTreeClient::StopPointerWatcher() {
640 DCHECK(has_pointer_watcher_);
641 tree_->StopPointerWatcher();
642 has_pointer_watcher_ = false;
638 } 643 }
639 644
640 void WindowTreeClient::PerformWindowMove( 645 void WindowTreeClient::PerformWindowMove(
641 Window* window, 646 Window* window,
642 ui::mojom::MoveLoopSource source, 647 ui::mojom::MoveLoopSource source,
643 const gfx::Point& cursor_location, 648 const gfx::Point& cursor_location,
644 const base::Callback<void(bool)>& callback) { 649 const base::Callback<void(bool)>& callback) {
645 DCHECK(on_current_move_finished_.is_null()); 650 DCHECK(on_current_move_finished_.is_null());
646 on_current_move_finished_ = callback; 651 on_current_move_finished_ = callback;
647 652
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 InFlightPropertyChange new_change(window, name, new_data); 970 InFlightPropertyChange new_change(window, name, new_data);
966 if (ApplyServerChangeToExistingInFlightChange(new_change)) 971 if (ApplyServerChangeToExistingInFlightChange(new_change))
967 return; 972 return;
968 973
969 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); 974 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data));
970 } 975 }
971 976
972 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, 977 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
973 Id window_id, 978 Id window_id,
974 std::unique_ptr<ui::Event> event, 979 std::unique_ptr<ui::Event> event,
975 uint32_t event_observer_id) { 980 uint32_t pointer_watcher_id) {
976 DCHECK(event); 981 DCHECK(event);
977 Window* window = GetWindowByServerId(window_id); // May be null. 982 Window* window = GetWindowByServerId(window_id); // May be null.
978 983
979 // Non-zero event_observer_id means it matched an event observer on the 984 // Non-zero pointer_watcher_id means it matched a pointer watcher on the
980 // server. 985 // server.
981 if (event_observer_id != 0 && has_event_observer_ && 986 if (pointer_watcher_id_ != 0 && has_pointer_watcher_ &&
982 event_observer_id == event_observer_id_) 987 pointer_watcher_id == pointer_watcher_id_) {
983 delegate_->OnEventObserved(*event.get(), window); 988 DCHECK(event->IsPointerEvent());
989 delegate_->OnPointerEventObserved(*event->AsPointerEvent(), window);
990 }
984 991
985 if (!window || !window->input_event_handler_) { 992 if (!window || !window->input_event_handler_) {
986 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); 993 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED);
987 return; 994 return;
988 } 995 }
989 996
990 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( 997 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback(
991 new base::Callback<void(mojom::EventResult)>( 998 new base::Callback<void(mojom::EventResult)>(
992 base::Bind(&mojom::WindowTree::OnWindowInputEventAck, 999 base::Bind(&mojom::WindowTree::OnWindowInputEventAck,
993 base::Unretained(tree_), event_id))); 1000 base::Unretained(tree_), event_id)));
(...skipping 10 matching lines...) Expand all
1004 window->input_event_handler_->OnWindowInputEvent(window, *event.get(), 1011 window->input_event_handler_->OnWindowInputEvent(window, *event.get(),
1005 &ack_callback); 1012 &ack_callback);
1006 } 1013 }
1007 1014
1008 // 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,
1009 // marking the event as not consumed. 1016 // marking the event as not consumed.
1010 if (ack_callback) 1017 if (ack_callback)
1011 ack_callback->Run(mojom::EventResult::UNHANDLED); 1018 ack_callback->Run(mojom::EventResult::UNHANDLED);
1012 } 1019 }
1013 1020
1014 void WindowTreeClient::OnEventObserved(std::unique_ptr<ui::Event> event, 1021 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event,
1015 uint32_t event_observer_id) { 1022 uint32_t pointer_watcher_id) {
1016 DCHECK(event); 1023 DCHECK(event);
1017 if (has_event_observer_ && event_observer_id == event_observer_id_) 1024 DCHECK(event->IsPointerEvent());
1018 delegate_->OnEventObserved(*event.get(), nullptr /* target */); 1025 if (has_pointer_watcher_ && pointer_watcher_id == pointer_watcher_id_)
1026 delegate_->OnPointerEventObserved(*event->AsPointerEvent(),
1027 nullptr /* target */);
1019 } 1028 }
1020 1029
1021 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { 1030 void WindowTreeClient::OnWindowFocused(Id focused_window_id) {
1022 Window* focused_window = GetWindowByServerId(focused_window_id); 1031 Window* focused_window = GetWindowByServerId(focused_window_id);
1023 InFlightFocusChange new_change(this, focused_window); 1032 InFlightFocusChange new_change(this, focused_window);
1024 if (ApplyServerChangeToExistingInFlightChange(new_change)) 1033 if (ApplyServerChangeToExistingInFlightChange(new_change))
1025 return; 1034 return;
1026 1035
1027 LocalSetFocus(focused_window); 1036 LocalSetFocus(focused_window);
1028 } 1037 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 Window* window, 1259 Window* window,
1251 const gfx::Vector2d& offset, 1260 const gfx::Vector2d& offset,
1252 const gfx::Insets& hit_area) { 1261 const gfx::Insets& hit_area) {
1253 if (window_manager_internal_client_) { 1262 if (window_manager_internal_client_) {
1254 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( 1263 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea(
1255 server_id(window), offset.x(), offset.y(), hit_area); 1264 server_id(window), offset.x(), offset.y(), hit_area);
1256 } 1265 }
1257 } 1266 }
1258 1267
1259 } // namespace ui 1268 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/window_tree_client.h ('k') | services/ui/public/cpp/window_tree_client_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698