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

Side by Side Diff: ui/views/mus/desktop_window_tree_host_mus.cc

Issue 2541163006: Wire up CursorManager for DesktopWindowTreeHostMus (Closed)
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/desktop_window_tree_host_mus.h" 5 #include "ui/views/mus/desktop_window_tree_host_mus.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/aura/client/aura_constants.h" 8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/cursor_client.h"
9 #include "ui/aura/client/drag_drop_client.h" 10 #include "ui/aura/client/drag_drop_client.h"
10 #include "ui/aura/client/focus_client.h" 11 #include "ui/aura/client/focus_client.h"
11 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
13 #include "ui/aura/mus/window_port_mus.h"
12 #include "ui/aura/mus/window_tree_host_mus.h" 14 #include "ui/aura/mus/window_tree_host_mus.h"
13 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
14 #include "ui/base/hit_test.h" 16 #include "ui/base/hit_test.h"
15 #include "ui/display/screen.h" 17 #include "ui/display/screen.h"
16 #include "ui/gfx/geometry/dip_util.h" 18 #include "ui/gfx/geometry/dip_util.h"
17 #include "ui/views/corewm/tooltip_aura.h" 19 #include "ui/views/corewm/tooltip_aura.h"
18 #include "ui/views/mus/mus_client.h" 20 #include "ui/views/mus/mus_client.h"
19 #include "ui/views/mus/window_manager_frame_values.h" 21 #include "ui/views/mus/window_manager_frame_values.h"
20 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 22 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
21 #include "ui/views/widget/native_widget_aura.h" 23 #include "ui/views/widget/native_widget_aura.h"
22 #include "ui/views/widget/widget_delegate.h" 24 #include "ui/views/widget/widget_delegate.h"
25 #include "ui/wm/core/cursor_manager.h"
26 #include "ui/wm/core/native_cursor_manager.h"
23 #include "ui/wm/core/window_util.h" 27 #include "ui/wm/core/window_util.h"
24 #include "ui/wm/public/activation_client.h" 28 #include "ui/wm/public/activation_client.h"
25 29
26 namespace views { 30 namespace views {
27 31
28 namespace { 32 namespace {
29 33
30 // As the window manager renderers the non-client decorations this class does 34 // As the window manager renderers the non-client decorations this class does
31 // very little but honor the client area insets from the window manager. 35 // very little but honor the client area insets from the window manager.
32 class ClientSideNonClientFrameView : public NonClientFrameView { 36 class ClientSideNonClientFrameView : public NonClientFrameView {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 .size(); 103 .size();
100 return gfx::Size(max_size.width() == 0 ? 0 : converted_size.width(), 104 return gfx::Size(max_size.width() == 0 ? 0 : converted_size.width(),
101 max_size.height() == 0 ? 0 : converted_size.height()); 105 max_size.height() == 0 ? 0 : converted_size.height());
102 } 106 }
103 107
104 views::Widget* widget_; 108 views::Widget* widget_;
105 109
106 DISALLOW_COPY_AND_ASSIGN(ClientSideNonClientFrameView); 110 DISALLOW_COPY_AND_ASSIGN(ClientSideNonClientFrameView);
107 }; 111 };
108 112
113 class NativeCursorManagerMus : public wm::NativeCursorManager {
114 public:
115 explicit NativeCursorManagerMus(aura::Window* window) : window_(window) {}
116 ~NativeCursorManagerMus() override {}
117
118 // wm::NativeCursorManager:
119 void SetDisplay(const display::Display& display,
120 wm::NativeCursorManagerDelegate* delegate) override {
121 // We ignore this entirely, as cursor are set on the client.
122 }
123
124 void SetCursor(gfx::NativeCursor cursor,
125 wm::NativeCursorManagerDelegate* delegate) override {
126 aura::WindowPortMus::Get(window_)->SetPredefinedCursor(
127 ui::mojom::Cursor(cursor.native_type()));
128 delegate->CommitCursor(cursor);
129 }
130
131 void SetVisibility(bool visible,
132 wm::NativeCursorManagerDelegate* delegate) override {
133 delegate->CommitVisibility(visible);
134
135 if (visible) {
136 SetCursor(delegate->GetCursor(), delegate);
137 } else {
138 aura::WindowPortMus::Get(window_)->SetPredefinedCursor(
139 ui::mojom::Cursor::NONE);
140 }
141 }
142
143 void SetCursorSet(ui::CursorSetType cursor_set,
144 wm::NativeCursorManagerDelegate* delegate) override {
145 // TODO(erg): For now, ignore the difference between SET_NORMAL and
146 // SET_LARGE here. This feels like a thing that mus should decide instead.
147 //
148 // Also, it's NOTIMPLEMENTED() in the desktop version!? Including not
149 // acknowledging the call in the delegate.
150 NOTIMPLEMENTED();
151 }
152
153 void SetMouseEventsEnabled(
154 bool enabled,
155 wm::NativeCursorManagerDelegate* delegate) override {
156 // TODO(erg): How do we actually implement this?
157 //
158 // Mouse event dispatch is potentially done in a different process,
159 // definitely in a different mojo service. Each app is fairly locked down.
160 delegate->CommitMouseEventsEnabled(enabled);
161 NOTIMPLEMENTED();
162 }
163
164 private:
165 aura::Window* window_;
166
167 DISALLOW_COPY_AND_ASSIGN(NativeCursorManagerMus);
168 };
109 } // namespace 169 } // namespace
110 170
111 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus( 171 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus(
112 internal::NativeWidgetDelegate* native_widget_delegate, 172 internal::NativeWidgetDelegate* native_widget_delegate,
113 DesktopNativeWidgetAura* desktop_native_widget_aura, 173 DesktopNativeWidgetAura* desktop_native_widget_aura,
114 const std::map<std::string, std::vector<uint8_t>>* mus_properties) 174 const std::map<std::string, std::vector<uint8_t>>* mus_properties)
115 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), 175 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(),
116 mus_properties), 176 mus_properties),
117 native_widget_delegate_(native_widget_delegate), 177 native_widget_delegate_(native_widget_delegate),
118 desktop_native_widget_aura_(desktop_native_widget_aura), 178 desktop_native_widget_aura_(desktop_native_widget_aura),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip)); 233 SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip));
174 } 234 }
175 235
176 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 236 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
177 const Widget::InitParams& params) { 237 const Widget::InitParams& params) {
178 // Needed so we don't render over the non-client area the window manager 238 // Needed so we don't render over the non-client area the window manager
179 // renders to. 239 // renders to.
180 content_window->layer()->SetFillsBoundsOpaquely(false); 240 content_window->layer()->SetFillsBoundsOpaquely(false);
181 if (!params.bounds.IsEmpty()) 241 if (!params.bounds.IsEmpty())
182 SetBoundsInDIP(params.bounds); 242 SetBoundsInDIP(params.bounds);
243
244 cursor_manager_ = base::MakeUnique<wm::CursorManager>(
245 base::MakeUnique<NativeCursorManagerMus>(window()));
246 aura::client::SetCursorClient(window(), cursor_manager_.get());
183 } 247 }
184 248
185 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 249 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
186 const Widget::InitParams& params) { 250 const Widget::InitParams& params) {
187 if (params.parent && params.parent->GetHost()) { 251 if (params.parent && params.parent->GetHost()) {
188 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); 252 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost());
189 parent_->children_.insert(this); 253 parent_->children_.insert(this);
190 } 254 }
191 native_widget_delegate_->OnNativeWidgetCreated(true); 255 native_widget_delegate_->OnNativeWidgetCreated(true);
192 } 256 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 if (widget->widget_delegate()) 603 if (widget->widget_delegate())
540 behavior = widget->widget_delegate()->GetResizeBehavior(); 604 behavior = widget->widget_delegate()->GetResizeBehavior();
541 window()->SetProperty(aura::client::kResizeBehaviorKey, behavior); 605 window()->SetProperty(aura::client::kResizeBehaviorKey, behavior);
542 } 606 }
543 607
544 bool DesktopWindowTreeHostMus::ShouldUpdateWindowTransparency() const { 608 bool DesktopWindowTreeHostMus::ShouldUpdateWindowTransparency() const {
545 // Needed so the window manager can render the client decorations. 609 // Needed so the window manager can render the client decorations.
546 return false; 610 return false;
547 } 611 }
548 612
613 bool DesktopWindowTreeHostMus::ShouldUseDesktopNativeCursorManager() const {
614 // We manage the cursor ourself.
615 return false;
616 }
617
549 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() { 618 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() {
550 NonClientView* non_client_view = 619 NonClientView* non_client_view =
551 native_widget_delegate_->AsWidget()->non_client_view(); 620 native_widget_delegate_->AsWidget()->non_client_view();
552 if (non_client_view) { 621 if (non_client_view) {
553 non_client_view->Layout(); 622 non_client_view->Layout();
554 non_client_view->SchedulePaint(); 623 non_client_view->SchedulePaint();
555 } 624 }
556 625
557 SendClientAreaToServer(); 626 SendClientAreaToServer();
558 SendHitTestMaskToServer(); 627 SendHitTestMaskToServer();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if (window == this->window()) { 670 if (window == this->window()) {
602 is_active_ = true; 671 is_active_ = true;
603 desktop_native_widget_aura_->HandleActivationChanged(true); 672 desktop_native_widget_aura_->HandleActivationChanged(true);
604 } else if (is_active_) { 673 } else if (is_active_) {
605 is_active_ = false; 674 is_active_ = false;
606 desktop_native_widget_aura_->HandleActivationChanged(false); 675 desktop_native_widget_aura_->HandleActivationChanged(false);
607 } 676 }
608 } 677 }
609 678
610 } // namespace views 679 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698