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

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

Issue 2488723002: Reland of Improves focus/activation for aura-mus and DesktopNativeWidgetAura (Closed)
Patch Set: Created 4 years, 1 month 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/desktop_window_tree_host_mus.h ('k') | ui/views/mus/mus_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/drag_drop_client.h" 9 #include "ui/aura/client/drag_drop_client.h"
10 #include "ui/aura/client/focus_client.h" 10 #include "ui/aura/client/focus_client.h"
11 #include "ui/aura/env.h"
11 #include "ui/aura/mus/window_tree_host_mus.h" 12 #include "ui/aura/mus/window_tree_host_mus.h"
12 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
13 #include "ui/display/screen.h" 14 #include "ui/display/screen.h"
14 #include "ui/views/corewm/tooltip_aura.h" 15 #include "ui/views/corewm/tooltip_aura.h"
15 #include "ui/views/mus/mus_client.h" 16 #include "ui/views/mus/mus_client.h"
16 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 17 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
17 #include "ui/views/widget/native_widget_aura.h" 18 #include "ui/views/widget/native_widget_aura.h"
18 #include "ui/views/widget/widget_delegate.h" 19 #include "ui/views/widget/widget_delegate.h"
19 #include "ui/wm/core/window_util.h" 20 #include "ui/wm/core/window_util.h"
20 #include "ui/wm/public/activation_client.h" 21 #include "ui/wm/public/activation_client.h"
21 22
22 namespace views { 23 namespace views {
23 24
24 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus( 25 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus(
25 internal::NativeWidgetDelegate* native_widget_delegate, 26 internal::NativeWidgetDelegate* native_widget_delegate,
26 DesktopNativeWidgetAura* desktop_native_widget_aura) 27 DesktopNativeWidgetAura* desktop_native_widget_aura)
27 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client()), 28 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client()),
28 native_widget_delegate_(native_widget_delegate), 29 native_widget_delegate_(native_widget_delegate),
29 desktop_native_widget_aura_(desktop_native_widget_aura), 30 desktop_native_widget_aura_(desktop_native_widget_aura),
30 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), 31 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT),
31 close_widget_factory_(this) { 32 close_widget_factory_(this) {
33 aura::Env::GetInstance()->AddObserver(this);
32 // TODO: use display id and bounds if available, likely need to pass in 34 // TODO: use display id and bounds if available, likely need to pass in
33 // InitParams for that. 35 // InitParams for that.
34 } 36 }
35 37
36 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { 38 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() {
39 aura::Env::GetInstance()->RemoveObserver(this);
37 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); 40 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
38 } 41 }
39 42
40 bool DesktopWindowTreeHostMus::IsDocked() const { 43 bool DesktopWindowTreeHostMus::IsDocked() const {
41 return window()->GetProperty(aura::client::kShowStateKey) == 44 return window()->GetProperty(aura::client::kShowStateKey) ==
42 ui::SHOW_STATE_DOCKED; 45 ui::SHOW_STATE_DOCKED;
43 } 46 }
44 47
45 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 48 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
46 const Widget::InitParams& params) {} 49 const Widget::InitParams& params) {}
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window())) 195 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window()))
193 .work_area(); 196 .work_area();
194 } 197 }
195 198
196 void DesktopWindowTreeHostMus::SetShape( 199 void DesktopWindowTreeHostMus::SetShape(
197 std::unique_ptr<SkRegion> native_region) { 200 std::unique_ptr<SkRegion> native_region) {
198 NOTIMPLEMENTED(); 201 NOTIMPLEMENTED();
199 } 202 }
200 203
201 void DesktopWindowTreeHostMus::Activate() { 204 void DesktopWindowTreeHostMus::Activate() {
202 window()->Focus(); 205 aura::Env::GetInstance()->SetActiveFocusClient(
203 if (window()->GetProperty(aura::client::kDrawAttentionKey)) 206 aura::client::GetFocusClient(window()), window());
204 window()->SetProperty(aura::client::kDrawAttentionKey, false); 207 if (is_active_) {
208 window()->Focus();
209 if (window()->GetProperty(aura::client::kDrawAttentionKey))
210 window()->SetProperty(aura::client::kDrawAttentionKey, false);
211 }
205 } 212 }
206 213
207 void DesktopWindowTreeHostMus::Deactivate() { 214 void DesktopWindowTreeHostMus::Deactivate() {
208 aura::client::GetActivationClient(window()->GetRootWindow()) 215 // TODO: Deactivate() means focus next window, that needs to go to mus.
209 ->DeactivateWindow(window()); 216 NOTIMPLEMENTED();
210 } 217 }
211 218
212 bool DesktopWindowTreeHostMus::IsActive() const { 219 bool DesktopWindowTreeHostMus::IsActive() const {
213 return wm::IsActiveWindow(const_cast<aura::Window*>(window())); 220 return is_active_;
214 } 221 }
215 222
216 void DesktopWindowTreeHostMus::Maximize() { 223 void DesktopWindowTreeHostMus::Maximize() {
217 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 224 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
218 } 225 }
219 void DesktopWindowTreeHostMus::Minimize() { 226 void DesktopWindowTreeHostMus::Minimize() {
220 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 227 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
221 } 228 }
222 229
223 void DesktopWindowTreeHostMus::Restore() { 230 void DesktopWindowTreeHostMus::Restore() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { 353 void DesktopWindowTreeHostMus::SizeConstraintsChanged() {
347 Widget* widget = native_widget_delegate_->AsWidget(); 354 Widget* widget = native_widget_delegate_->AsWidget();
348 window()->SetProperty(aura::client::kCanMaximizeKey, 355 window()->SetProperty(aura::client::kCanMaximizeKey,
349 widget->widget_delegate()->CanMaximize()); 356 widget->widget_delegate()->CanMaximize());
350 window()->SetProperty(aura::client::kCanMinimizeKey, 357 window()->SetProperty(aura::client::kCanMinimizeKey,
351 widget->widget_delegate()->CanMinimize()); 358 widget->widget_delegate()->CanMinimize());
352 window()->SetProperty(aura::client::kCanResizeKey, 359 window()->SetProperty(aura::client::kCanResizeKey,
353 widget->widget_delegate()->CanResize()); 360 widget->widget_delegate()->CanResize());
354 } 361 }
355 362
363 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {}
364
365 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged(
366 aura::client::FocusClient* focus_client,
367 aura::Window* window) {
368 if (window == this->window()) {
369 is_active_ = true;
370 desktop_native_widget_aura_->HandleActivationChanged(true);
371 } else if (is_active_) {
372 is_active_ = false;
373 desktop_native_widget_aura_->HandleActivationChanged(false);
374 }
375 }
376
356 } // namespace views 377 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/mus_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698