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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
11 #include "components/mus/public/cpp/window_observer.h" 11 #include "components/mus/public/cpp/window_observer.h"
12 #include "components/mus/public/cpp/window_property.h" 12 #include "components/mus/public/cpp/window_property.h"
13 #include "components/mus/public/cpp/window_tree_connection.h" 13 #include "components/mus/public/cpp/window_tree_connection.h"
14 #include "components/mus/public/interfaces/cursor.mojom.h"
14 #include "mojo/converters/geometry/geometry_type_converters.h" 15 #include "mojo/converters/geometry/geometry_type_converters.h"
15 #include "ui/aura/client/default_capture_client.h" 16 #include "ui/aura/client/default_capture_client.h"
16 #include "ui/aura/client/window_tree_client.h" 17 #include "ui/aura/client/window_tree_client.h"
17 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
18 #include "ui/aura/layout_manager.h" 19 #include "ui/aura/layout_manager.h"
19 #include "ui/aura/mus/mus_util.h" 20 #include "ui/aura/mus/mus_util.h"
20 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
21 #include "ui/aura/window_property.h" 22 #include "ui/aura/window_property.h"
22 #include "ui/base/hit_test.h" 23 #include "ui/base/hit_test.h"
23 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
24 #include "ui/native_theme/native_theme_aura.h" 25 #include "ui/native_theme/native_theme_aura.h"
25 #include "ui/views/mus/platform_window_mus.h" 26 #include "ui/views/mus/platform_window_mus.h"
26 #include "ui/views/mus/surface_context_factory.h" 27 #include "ui/views/mus/surface_context_factory.h"
27 #include "ui/views/mus/window_manager_constants_converters.h" 28 #include "ui/views/mus/window_manager_constants_converters.h"
28 #include "ui/views/mus/window_manager_frame_values.h" 29 #include "ui/views/mus/window_manager_frame_values.h"
29 #include "ui/views/mus/window_tree_host_mus.h" 30 #include "ui/views/mus/window_tree_host_mus.h"
30 #include "ui/views/widget/native_widget_aura.h" 31 #include "ui/views/widget/native_widget_aura.h"
31 #include "ui/views/widget/widget_delegate.h" 32 #include "ui/views/widget/widget_delegate.h"
32 #include "ui/views/window/custom_frame_view.h" 33 #include "ui/views/window/custom_frame_view.h"
33 #include "ui/wm/core/base_focus_rules.h" 34 #include "ui/wm/core/base_focus_rules.h"
34 #include "ui/wm/core/capture_controller.h" 35 #include "ui/wm/core/capture_controller.h"
36 #include "ui/wm/core/cursor_manager.h"
35 #include "ui/wm/core/default_screen_position_client.h" 37 #include "ui/wm/core/default_screen_position_client.h"
36 #include "ui/wm/core/focus_controller.h" 38 #include "ui/wm/core/focus_controller.h"
39 #include "ui/wm/core/native_cursor_manager.h"
37 40
38 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*); 41 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*);
39 42
40 namespace views { 43 namespace views {
41 namespace { 44 namespace {
42 45
43 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr); 46 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr);
44 47
45 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr); 48 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr);
46 49
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 point->Offset(mus_bounds.x(), mus_bounds.y()); 131 point->Offset(mus_bounds.x(), mus_bounds.y());
129 wm::DefaultScreenPositionClient::ConvertPointFromScreen(window, point); 132 wm::DefaultScreenPositionClient::ConvertPointFromScreen(window, point);
130 } 133 }
131 134
132 private: 135 private:
133 mus::Window* mus_window_; 136 mus::Window* mus_window_;
134 137
135 DISALLOW_COPY_AND_ASSIGN(ScreenPositionClientMus); 138 DISALLOW_COPY_AND_ASSIGN(ScreenPositionClientMus);
136 }; 139 };
137 140
141 class NativeCursorManagerMus : public wm::NativeCursorManager {
142 public:
143 explicit NativeCursorManagerMus(mus::Window* mus_window)
144 : mus_window_(mus_window) {}
145 ~NativeCursorManagerMus() override {}
146
147 // wm::NativeCursorManager:
148 void SetDisplay(const display::Display& display,
149 wm::NativeCursorManagerDelegate* delegate) override {
150 // We ignore this entirely, as cursor are set on the client.
151 }
152
153 void SetCursor(gfx::NativeCursor cursor,
154 wm::NativeCursorManagerDelegate* delegate) override {
155 mus_window_->SetPredefinedCursor(mus::mojom::Cursor(cursor.native_type()));
156 delegate->CommitCursor(cursor);
157 }
158
159 void SetVisibility(bool visible,
160 wm::NativeCursorManagerDelegate* delegate) override {
161 delegate->CommitVisibility(visible);
162
163 if (visible)
164 SetCursor(delegate->GetCursor(), delegate);
165 else
166 mus_window_->SetPredefinedCursor(mus::mojom::Cursor::NONE);
167 }
168
169 void SetCursorSet(ui::CursorSetType cursor_set,
170 wm::NativeCursorManagerDelegate* delegate) override {
171 // TODO(erg): For now, ignore the difference between SET_NORMAL and
172 // SET_LARGE here. This feels like a thing that mus should decide instead.
173 //
174 // Also, it's NOTIMPLEMENTED() in the desktop version!? Including not
175 // acknowledging the call in the delegate.
176 NOTIMPLEMENTED();
177 }
178
179 void SetMouseEventsEnabled(
180 bool enabled,
181 wm::NativeCursorManagerDelegate* delegate) override {
182 // TODO(erg): How do we actually implement this?
183 //
184 // Mouse event dispatch is potentially done in a different process,
185 // definitely in a different mojo service. Each app is fairly locked down.
186 delegate->CommitMouseEventsEnabled(enabled);
187 NOTIMPLEMENTED();
188 }
189
190 private:
191 mus::Window* mus_window_;
192
193 DISALLOW_COPY_AND_ASSIGN(NativeCursorManagerMus);
194 };
195
138 // As the window manager renderers the non-client decorations this class does 196 // As the window manager renderers the non-client decorations this class does
139 // very little but honor the client area insets from the window manager. 197 // very little but honor the client area insets from the window manager.
140 class ClientSideNonClientFrameView : public NonClientFrameView { 198 class ClientSideNonClientFrameView : public NonClientFrameView {
141 public: 199 public:
142 explicit ClientSideNonClientFrameView(views::Widget* widget) 200 explicit ClientSideNonClientFrameView(views::Widget* widget)
143 : widget_(widget) {} 201 : widget_(widget) {}
144 ~ClientSideNonClientFrameView() override {} 202 ~ClientSideNonClientFrameView() override {}
145 203
146 private: 204 private:
147 // Returns the default values of client area insets from the window manager. 205 // Returns the default values of client area insets from the window manager.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 aura::Window* NativeWidgetMus::GetRootWindow() { 380 aura::Window* NativeWidgetMus::GetRootWindow() {
323 return window_tree_host_->window(); 381 return window_tree_host_->window();
324 } 382 }
325 383
326 void NativeWidgetMus::OnPlatformWindowClosed() { 384 void NativeWidgetMus::OnPlatformWindowClosed() {
327 native_widget_delegate_->OnNativeWidgetDestroying(); 385 native_widget_delegate_->OnNativeWidgetDestroying();
328 386
329 window_tree_client_.reset(); // Uses |content_|. 387 window_tree_client_.reset(); // Uses |content_|.
330 capture_client_.reset(); // Uses |content_|. 388 capture_client_.reset(); // Uses |content_|.
331 389
390 cursor_manager_.reset(); // Uses |window_|.
391
332 window_tree_host_->RemoveObserver(this); 392 window_tree_host_->RemoveObserver(this);
333 window_tree_host_.reset(); 393 window_tree_host_.reset();
334 394
335 mus_window_observer_.reset(nullptr); 395 mus_window_observer_.reset(nullptr);
336 396
337 window_ = nullptr; 397 window_ = nullptr;
338 content_ = nullptr; 398 content_ = nullptr;
339 399
340 native_widget_delegate_->OnNativeWidgetDestroyed(); 400 native_widget_delegate_->OnNativeWidgetDestroyed();
341 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 401 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); 481 focus_client_.reset(new wm::FocusController(new FocusRulesImpl));
422 482
423 aura::client::SetFocusClient(window_tree_host_->window(), 483 aura::client::SetFocusClient(window_tree_host_->window(),
424 focus_client_.get()); 484 focus_client_.get());
425 aura::client::SetActivationClient(window_tree_host_->window(), 485 aura::client::SetActivationClient(window_tree_host_->window(),
426 focus_client_.get()); 486 focus_client_.get());
427 screen_position_client_.reset(new ScreenPositionClientMus(window_)); 487 screen_position_client_.reset(new ScreenPositionClientMus(window_));
428 aura::client::SetScreenPositionClient(window_tree_host_->window(), 488 aura::client::SetScreenPositionClient(window_tree_host_->window(),
429 screen_position_client_.get()); 489 screen_position_client_.get());
430 490
491 // TODO(erg): Remove this check when mash/wm/frame/move_event_handler.cc's
492 // direct usage of mus::Window::SetPredefinedCursor() is switched to a
493 // private method on WindowManagerClient.
494 if (surface_type_ == mus::mojom::SurfaceType::DEFAULT) {
495 cursor_manager_.reset(new wm::CursorManager(
496 base::WrapUnique(new NativeCursorManagerMus(window_))));
497 aura::client::SetCursorClient(window_tree_host_->window(),
498 cursor_manager_.get());
499 }
500
431 window_tree_client_.reset( 501 window_tree_client_.reset(
432 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); 502 new NativeWidgetMusWindowTreeClient(window_tree_host_->window()));
433 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); 503 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get());
434 window_tree_host_->window()->SetLayoutManager( 504 window_tree_host_->window()->SetLayoutManager(
435 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); 505 new ContentWindowLayoutManager(window_tree_host_->window(), content_));
436 capture_client_.reset( 506 capture_client_.reset(
437 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 507 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
438 508
439 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 509 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL);
440 content_->Init(ui::LAYER_TEXTURED); 510 content_->Init(ui::LAYER_TEXTURED);
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 window_tree_host_->Show(); 1121 window_tree_host_->Show();
1052 GetNativeWindow()->Show(); 1122 GetNativeWindow()->Show();
1053 } else { 1123 } else {
1054 window_tree_host_->Hide(); 1124 window_tree_host_->Hide();
1055 GetNativeWindow()->Hide(); 1125 GetNativeWindow()->Hide();
1056 } 1126 }
1057 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1127 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
1058 } 1128 }
1059 1129
1060 } // namespace views 1130 } // namespace views
OLDNEW
« 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