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

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

Issue 2180683003: NOSUBMIT: PointerWatcher observes all pointer events, with moves optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 has_pointer_watcher_ = true;
631 has_event_observer_ = false; 631 pointer_watcher_id_++;
632 tree_->SetEventObserver(nullptr, 0u); 632 tree_->StartPointerWatcher(want_moves, pointer_watcher_id_);
633 } else { 633 }
634 has_event_observer_ = true; 634
635 event_observer_id_++; 635 void WindowTreeClient::StopPointerWatcher() {
636 tree_->SetEventObserver(std::move(matcher), event_observer_id_); 636 tree_->StopPointerWatcher();
637 } 637 has_pointer_watcher_ = false;
638 } 638 }
639 639
640 void WindowTreeClient::PerformWindowMove( 640 void WindowTreeClient::PerformWindowMove(
641 Window* window, 641 Window* window,
642 ui::mojom::MoveLoopSource source, 642 ui::mojom::MoveLoopSource source,
643 const gfx::Point& cursor_location, 643 const gfx::Point& cursor_location,
644 const base::Callback<void(bool)>& callback) { 644 const base::Callback<void(bool)>& callback) {
645 DCHECK(on_current_move_finished_.is_null()); 645 DCHECK(on_current_move_finished_.is_null());
646 on_current_move_finished_ = callback; 646 on_current_move_finished_ = callback;
647 647
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 InFlightPropertyChange new_change(window, name, new_data); 965 InFlightPropertyChange new_change(window, name, new_data);
966 if (ApplyServerChangeToExistingInFlightChange(new_change)) 966 if (ApplyServerChangeToExistingInFlightChange(new_change))
967 return; 967 return;
968 968
969 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); 969 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data));
970 } 970 }
971 971
972 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, 972 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
973 Id window_id, 973 Id window_id,
974 std::unique_ptr<ui::Event> event, 974 std::unique_ptr<ui::Event> event,
975 uint32_t event_observer_id) { 975 uint32_t pointer_watcher_id) {
976 DCHECK(event); 976 DCHECK(event);
977 Window* window = GetWindowByServerId(window_id); // May be null. 977 Window* window = GetWindowByServerId(window_id); // May be null.
978 978
979 // Non-zero event_observer_id means it matched an event observer on the 979 // Non-zero pointer_watcher_id means it matched an event observer on the
980 // server. 980 // server.
981 if (event_observer_id != 0 && has_event_observer_ && 981 if (pointer_watcher_id_ != 0 && has_pointer_watcher_ &&
982 event_observer_id == event_observer_id_) 982 pointer_watcher_id == pointer_watcher_id_)
983 delegate_->OnEventObserved(*event.get(), window); 983 delegate_->OnEventObserved(*event.get(), window);
984 984
985 if (!window || !window->input_event_handler_) { 985 if (!window || !window->input_event_handler_) {
986 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); 986 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED);
987 return; 987 return;
988 } 988 }
989 989
990 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( 990 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback(
991 new base::Callback<void(mojom::EventResult)>( 991 new base::Callback<void(mojom::EventResult)>(
992 base::Bind(&mojom::WindowTree::OnWindowInputEventAck, 992 base::Bind(&mojom::WindowTree::OnWindowInputEventAck,
(...skipping 12 matching lines...) Expand all
1005 &ack_callback); 1005 &ack_callback);
1006 } 1006 }
1007 1007
1008 // The handler did not take ownership of the callback, so we send the ack, 1008 // The handler did not take ownership of the callback, so we send the ack,
1009 // marking the event as not consumed. 1009 // marking the event as not consumed.
1010 if (ack_callback) 1010 if (ack_callback)
1011 ack_callback->Run(mojom::EventResult::UNHANDLED); 1011 ack_callback->Run(mojom::EventResult::UNHANDLED);
1012 } 1012 }
1013 1013
1014 void WindowTreeClient::OnEventObserved(std::unique_ptr<ui::Event> event, 1014 void WindowTreeClient::OnEventObserved(std::unique_ptr<ui::Event> event,
1015 uint32_t event_observer_id) { 1015 uint32_t pointer_watcher_id) {
1016 DCHECK(event); 1016 DCHECK(event);
1017 if (has_event_observer_ && event_observer_id == event_observer_id_) 1017 if (has_pointer_watcher_ && pointer_watcher_id == pointer_watcher_id_)
1018 delegate_->OnEventObserved(*event.get(), nullptr /* target */); 1018 delegate_->OnEventObserved(*event.get(), nullptr /* target */);
1019 } 1019 }
1020 1020
1021 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { 1021 void WindowTreeClient::OnWindowFocused(Id focused_window_id) {
1022 Window* focused_window = GetWindowByServerId(focused_window_id); 1022 Window* focused_window = GetWindowByServerId(focused_window_id);
1023 InFlightFocusChange new_change(this, focused_window); 1023 InFlightFocusChange new_change(this, focused_window);
1024 if (ApplyServerChangeToExistingInFlightChange(new_change)) 1024 if (ApplyServerChangeToExistingInFlightChange(new_change))
1025 return; 1025 return;
1026 1026
1027 LocalSetFocus(focused_window); 1027 LocalSetFocus(focused_window);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 Window* window, 1250 Window* window,
1251 const gfx::Vector2d& offset, 1251 const gfx::Vector2d& offset,
1252 const gfx::Insets& hit_area) { 1252 const gfx::Insets& hit_area) {
1253 if (window_manager_internal_client_) { 1253 if (window_manager_internal_client_) {
1254 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( 1254 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea(
1255 server_id(window), offset.x(), offset.y(), hit_area); 1255 server_id(window), offset.x(), offset.y(), hit_area);
1256 } 1256 }
1257 } 1257 }
1258 1258
1259 } // namespace ui 1259 } // namespace ui
OLDNEW
« no previous file with comments | « ash/touch_hud/mus/touch_hud_application.cc ('k') | services/ui/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698