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

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

Issue 2507963002: Implement hit tests/client area. (Closed)
Patch Set: Merge with tot 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
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"
(...skipping 15 matching lines...) Expand all
26 internal::NativeWidgetDelegate* native_widget_delegate, 26 internal::NativeWidgetDelegate* native_widget_delegate,
27 DesktopNativeWidgetAura* desktop_native_widget_aura, 27 DesktopNativeWidgetAura* desktop_native_widget_aura,
28 const Widget::InitParams& init_params) 28 const Widget::InitParams& init_params)
29 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), 29 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(),
30 &init_params.mus_properties), 30 &init_params.mus_properties),
31 native_widget_delegate_(native_widget_delegate), 31 native_widget_delegate_(native_widget_delegate),
32 desktop_native_widget_aura_(desktop_native_widget_aura), 32 desktop_native_widget_aura_(desktop_native_widget_aura),
33 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), 33 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT),
34 close_widget_factory_(this) { 34 close_widget_factory_(this) {
35 aura::Env::GetInstance()->AddObserver(this); 35 aura::Env::GetInstance()->AddObserver(this);
36 MusClient::Get()->AddObserver(this);
36 // TODO: use display id and bounds if available, likely need to pass in 37 // TODO: use display id and bounds if available, likely need to pass in
37 // InitParams for that. 38 // InitParams for that.
38 } 39 }
39 40
40 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { 41 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() {
42 MusClient::Get()->RemoveObserver(this);
41 aura::Env::GetInstance()->RemoveObserver(this); 43 aura::Env::GetInstance()->RemoveObserver(this);
42 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); 44 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
43 } 45 }
44 46
45 bool DesktopWindowTreeHostMus::IsDocked() const { 47 bool DesktopWindowTreeHostMus::IsDocked() const {
46 return window()->GetProperty(aura::client::kShowStateKey) == 48 return window()->GetProperty(aura::client::kShowStateKey) ==
47 ui::SHOW_STATE_DOCKED; 49 ui::SHOW_STATE_DOCKED;
48 } 50 }
49 51
52 // TODO(erg): In addition to being called on system events, this also needs to
53 // be called after window size changed.
54 void DesktopWindowTreeHostMus::UpdateClientArea() {
55 NonClientView* non_client_view =
56 native_widget_delegate_->AsWidget()->non_client_view();
57 if (!non_client_view || !non_client_view->client_view())
58 return;
59
60 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds());
61 SetClientArea(gfx::Insets(
62 client_area_rect.y(), client_area_rect.x(),
63 non_client_view->bounds().height() - client_area_rect.bottom(),
64 non_client_view->bounds().width() - client_area_rect.right()));
65 }
66
67 void DesktopWindowTreeHostMus::UpdateHitTestMask() {
68 if (!native_widget_delegate_->HasHitTestMask()) {
69 ClearHitTestMask();
70 return;
71 }
72
73 gfx::Path mask_path;
74 native_widget_delegate_->GetHitTestMask(&mask_path);
75 // TODO(jamescook): Use the full path for the mask.
76 gfx::Rect mask_rect =
77 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
78 SetHitTestMask(mask_rect);
79 }
80
50 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 81 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
51 const Widget::InitParams& params) { 82 const Widget::InitParams& params) {
52 // TODO: handle device scale, http://crbug.com/663524. 83 // TODO: handle device scale, http://crbug.com/663524.
53 if (!params.bounds.IsEmpty()) 84 if (!params.bounds.IsEmpty())
54 SetBounds(params.bounds); 85 SetBounds(params.bounds);
55 } 86 }
56 87
57 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 88 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
58 const Widget::InitParams& params) { 89 const Widget::InitParams& params) {
59 if (params.parent && params.parent->GetHost()) { 90 if (params.parent && params.parent->GetHost()) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { 442 void DesktopWindowTreeHostMus::SizeConstraintsChanged() {
412 Widget* widget = native_widget_delegate_->AsWidget(); 443 Widget* widget = native_widget_delegate_->AsWidget();
413 window()->SetProperty(aura::client::kCanMaximizeKey, 444 window()->SetProperty(aura::client::kCanMaximizeKey,
414 widget->widget_delegate()->CanMaximize()); 445 widget->widget_delegate()->CanMaximize());
415 window()->SetProperty(aura::client::kCanMinimizeKey, 446 window()->SetProperty(aura::client::kCanMinimizeKey,
416 widget->widget_delegate()->CanMinimize()); 447 widget->widget_delegate()->CanMinimize());
417 window()->SetProperty(aura::client::kCanResizeKey, 448 window()->SetProperty(aura::client::kCanResizeKey,
418 widget->widget_delegate()->CanResize()); 449 widget->widget_delegate()->CanResize());
419 } 450 }
420 451
452 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() {
453 NonClientView* non_client_view =
454 native_widget_delegate_->AsWidget()->non_client_view();
455 if (non_client_view) {
456 non_client_view->Layout();
457 non_client_view->SchedulePaint();
458 }
459
460 UpdateClientArea();
461 UpdateHitTestMask();
462 }
463
421 void DesktopWindowTreeHostMus::ShowImpl() { 464 void DesktopWindowTreeHostMus::ShowImpl() {
422 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); 465 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true);
423 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. 466 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11.
424 ShowWindowWithState(ui::SHOW_STATE_NORMAL); 467 ShowWindowWithState(ui::SHOW_STATE_NORMAL);
425 WindowTreeHostMus::ShowImpl(); 468 WindowTreeHostMus::ShowImpl();
426 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); 469 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true);
427 } 470 }
428 471
429 void DesktopWindowTreeHostMus::HideImpl() { 472 void DesktopWindowTreeHostMus::HideImpl() {
430 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); 473 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false);
(...skipping 23 matching lines...) Expand all
454 if (window == this->window()) { 497 if (window == this->window()) {
455 is_active_ = true; 498 is_active_ = true;
456 desktop_native_widget_aura_->HandleActivationChanged(true); 499 desktop_native_widget_aura_->HandleActivationChanged(true);
457 } else if (is_active_) { 500 } else if (is_active_) {
458 is_active_ = false; 501 is_active_ = false;
459 desktop_native_widget_aura_->HandleActivationChanged(false); 502 desktop_native_widget_aura_->HandleActivationChanged(false);
460 } 503 }
461 } 504 }
462 505
463 } // namespace views 506 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698