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

Unified Diff: components/mus/ws/window_tree_host_impl.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WindowTreeAppTest.SetCursor. Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: components/mus/ws/window_tree_host_impl.cc
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc
index 16c3176d6373d07d4b5a8b3993a1d8cf6dc461b1..703df8bee2ef358e5d7f61a086f94c888dfde363 100644
--- a/components/mus/ws/window_tree_host_impl.cc
+++ b/components/mus/ws/window_tree_host_impl.cc
@@ -7,6 +7,7 @@
#include "base/debug/debugger.h"
#include "base/strings/utf_string_conversions.h"
#include "components/mus/common/types.h"
+#include "components/mus/public/interfaces/input_event_constants.mojom.h"
#include "components/mus/ws/connection_manager.h"
#include "components/mus/ws/display_manager.h"
#include "components/mus/ws/focus_controller.h"
@@ -43,7 +44,8 @@ WindowTreeHostImpl::WindowTreeHostImpl(
display_manager_(
DisplayManager::Create(app_impl, gpu_state, surfaces_state)),
window_manager_(window_manager.Pass()),
- tree_awaiting_input_ack_(nullptr) {
+ tree_awaiting_input_ack_(nullptr),
+ last_cursor_(0) {
display_manager_->Init(this);
if (client_) {
client_.set_connection_error_handler(base::Bind(
@@ -131,6 +133,11 @@ void WindowTreeHostImpl::SetImeVisibility(ServerWindow* window, bool visible) {
display_manager_->SetImeVisibility(visible);
}
+void WindowTreeHostImpl::OnCursorUpdated(ServerWindow* window) {
+ if (window == event_dispatcher_.last_targeted_window())
+ UpdateNativeCursor(window->cursor());
+}
+
void WindowTreeHostImpl::SetSize(mojo::SizePtr size) {
display_manager_->SetViewportSize(size.To<gfx::Size>());
}
@@ -214,6 +221,13 @@ void WindowTreeHostImpl::DispatchNextEventFromQueue() {
event_dispatcher_.OnEvent(next_event.Pass());
}
+void WindowTreeHostImpl::UpdateNativeCursor(int32_t cursor_id) {
+ if (cursor_id != last_cursor_) {
+ display_manager_->SetCursorById(cursor_id);
+ last_cursor_ = cursor_id;
+ }
+}
+
ServerWindow* WindowTreeHostImpl::GetRootWindow() {
return root_.get();
}
@@ -363,6 +377,15 @@ void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target,
bool in_nonclient_area,
mojom::EventPtr event) {
DCHECK(!event_ack_timer_.IsRunning());
+ if ((event->action == mojom::EventType::EVENT_TYPE_POINTER_CANCEL ||
+ event->action == mojom::EventType::EVENT_TYPE_POINTER_DOWN ||
+ event->action == mojom::EventType::EVENT_TYPE_POINTER_MOVE ||
+ event->action == mojom::EventType::EVENT_TYPE_POINTER_UP) &&
+ (event->pointer_data &&
+ event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE)) {
+ UpdateNativeCursor(target->cursor());
+ }
+
// If the event is in the non-client area the event goes to the owner of
// the window. Otherwise if the window is an embed root, forward to the
// embedded window.

Powered by Google App Engine
This is Rietveld 408576698