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

Unified Diff: ui/views/mus/native_widget_mus.cc

Issue 1945423002: views/mus: Connect cursor events to the mus window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add temporary if check. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus.cc
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc
index a90785684134fb8ecb0db57b5a202658c20403cb..7bcc4ac7a17206250df694f2adab5f9ba3fdd336 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -11,6 +11,7 @@
#include "components/mus/public/cpp/window_observer.h"
#include "components/mus/public/cpp/window_property.h"
#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/interfaces/cursor.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "ui/aura/client/default_capture_client.h"
#include "ui/aura/client/window_tree_client.h"
@@ -32,8 +33,10 @@
#include "ui/views/window/custom_frame_view.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/capture_controller.h"
+#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/default_screen_position_client.h"
#include "ui/wm/core/focus_controller.h"
+#include "ui/wm/core/native_cursor_manager.h"
DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*);
@@ -135,6 +138,61 @@ class ScreenPositionClientMus : public wm::DefaultScreenPositionClient {
DISALLOW_COPY_AND_ASSIGN(ScreenPositionClientMus);
};
+class NativeCursorManagerMus : public wm::NativeCursorManager {
+ public:
+ explicit NativeCursorManagerMus(mus::Window* mus_window)
+ : mus_window_(mus_window) {}
+ ~NativeCursorManagerMus() override {}
+
+ // wm::NativeCursorManager:
+ void SetDisplay(const display::Display& display,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ // We ignore this entirely, as cursor are set on the client.
+ }
+
+ void SetCursor(gfx::NativeCursor cursor,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ mus_window_->SetPredefinedCursor(mus::mojom::Cursor(cursor.native_type()));
+ delegate->CommitCursor(cursor);
+ }
+
+ void SetVisibility(bool visible,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ delegate->CommitVisibility(visible);
+
+ if (visible)
+ SetCursor(delegate->GetCursor(), delegate);
+ else
+ mus_window_->SetPredefinedCursor(mus::mojom::Cursor::NONE);
+ }
+
+ void SetCursorSet(ui::CursorSetType cursor_set,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ // TODO(erg): For now, ignore the difference between SET_NORMAL and
+ // SET_LARGE here. This feels like a thing that mus should decide instead.
+ //
+ // Also, it's NOTIMPLEMENTED() in the desktop version!? Including not
+ // acknowledging the call in the delegate.
+ NOTIMPLEMENTED();
+ }
+
+ void SetMouseEventsEnabled(
+ bool enabled,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ // TODO(erg): How do we actually implement this?
+ //
+ // Mouse event dispatch is potentially done in a different process,
+ // definitely in a different mojo service. Each app is fairly locked down.
+ delegate->CommitMouseEventsEnabled(enabled);
+ NOTIMPLEMENTED();
+ }
+
+ private:
+ mus::Window* mus_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeCursorManagerMus);
+};
+
// As the window manager renderers the non-client decorations this class does
// very little but honor the client area insets from the window manager.
class ClientSideNonClientFrameView : public NonClientFrameView {
@@ -329,6 +387,8 @@ void NativeWidgetMus::OnPlatformWindowClosed() {
window_tree_client_.reset(); // Uses |content_|.
capture_client_.reset(); // Uses |content_|.
+ cursor_manager_.reset(); // Uses |window_|.
+
window_tree_host_->RemoveObserver(this);
window_tree_host_.reset();
@@ -428,6 +488,16 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) {
aura::client::SetScreenPositionClient(window_tree_host_->window(),
screen_position_client_.get());
+ // TODO(erg): Remove this check when mash/wm/frame/move_event_handler.cc's
+ // direct usage of mus::Window::SetPredefinedCursor() is switched to a
+ // private method on WindowManagerClient.
+ if (surface_type_ == mus::mojom::SurfaceType::DEFAULT) {
+ cursor_manager_.reset(new wm::CursorManager(
+ base::WrapUnique(new NativeCursorManagerMus(window_))));
+ aura::client::SetCursorClient(window_tree_host_->window(),
+ cursor_manager_.get());
+ }
+
window_tree_client_.reset(
new NativeWidgetMusWindowTreeClient(window_tree_host_->window()));
window_tree_host_->window()->AddPreTargetHandler(focus_client_.get());
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698