Chromium Code Reviews| Index: ash/mus/non_client_frame_controller.cc |
| diff --git a/ash/mus/non_client_frame_controller.cc b/ash/mus/non_client_frame_controller.cc |
| index efdbb42f5929d8177f0e91dbfa363f8373316034..bac38441f7a28248a216fff859954521f75005d4 100644 |
| --- a/ash/mus/non_client_frame_controller.cc |
| +++ b/ash/mus/non_client_frame_controller.cc |
| @@ -20,75 +20,35 @@ |
| #include "ash/mus/move_event_handler.h" |
| #include "ash/mus/property_util.h" |
| #include "ash/mus/shadow.h" |
| +#include "ash/mus/window_manager.h" |
| +#include "ash/mus/window_properties.h" |
| #include "ash/shared/immersive_fullscreen_controller_delegate.h" |
| #include "base/macros.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| -#include "services/ui/public/cpp/property_type_converters.h" |
| -#include "services/ui/public/cpp/window.h" |
| -#include "services/ui/public/cpp/window_manager_delegate.h" |
| -#include "services/ui/public/cpp/window_property.h" |
| -#include "services/ui/public/cpp/window_tree_client.h" |
| #include "services/ui/public/interfaces/window_manager.mojom.h" |
| -#include "ui/aura/layout_manager.h" |
| +#include "ui/aura/client/aura_constants.h" |
| +#include "ui/aura/mus/property_converter.h" |
| +#include "ui/aura/mus/property_utils.h" |
| +#include "ui/aura/mus/window_manager_delegate.h" |
| +#include "ui/aura/mus/window_port_mus.h" |
| #include "ui/aura/window.h" |
| -#include "ui/aura/window_tree_host.h" |
| +#include "ui/aura/window_property.h" |
| #include "ui/base/hit_test.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/gfx/geometry/vector2d.h" |
| -#include "ui/views/mus/native_widget_mus.h" |
| +#include "ui/views/widget/native_widget_aura.h" |
| #include "ui/views/widget/widget.h" |
| +DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::NonClientFrameController*); |
| + |
| namespace ash { |
| namespace mus { |
| namespace { |
| -// LayoutManager associated with the window created by WindowTreeHost. Resizes |
| -// all children of the parent to match the bounds of the parent. Additionally |
| -// handles sizing of a Shadow. |
| -class ContentWindowLayoutManager : public aura::LayoutManager { |
| - public: |
| - ContentWindowLayoutManager(aura::Window* window, Shadow* shadow) |
| - : window_(window), shadow_(shadow) { |
| - OnWindowResized(); |
| - } |
| - ~ContentWindowLayoutManager() override {} |
| - |
| - private: |
| - // Bounds for child windows. |
| - gfx::Rect child_bounds() const { |
| - return gfx::Rect(0, 0, window_->bounds().size().width(), |
| - window_->bounds().size().height()); |
| - } |
| - |
| - void UpdateChildBounds(aura::Window* child) { |
| - child->SetBounds(child_bounds()); |
| - } |
| - |
| - // aura::LayoutManager: |
| - void OnWindowResized() override { |
| - for (aura::Window* child : window_->children()) |
| - UpdateChildBounds(child); |
| - // Shadow takes care of resizing the layer appropriately. |
| - if (shadow_) |
| - shadow_->SetContentBounds(child_bounds()); |
| - } |
| - void OnWindowAddedToLayout(aura::Window* child) override { |
| - UpdateChildBounds(child); |
| - } |
| - void OnWillRemoveWindowFromLayout(aura::Window* child) override {} |
| - void OnWindowRemovedFromLayout(aura::Window* child) override {} |
| - void OnChildWindowVisibilityChanged(aura::Window* child, |
| - bool visible) override {} |
| - void SetChildBounds(aura::Window* child, |
| - const gfx::Rect& requested_bounds) override { |
| - SetChildBoundsDirect(child, requested_bounds); |
| - } |
| - |
| - aura::Window* window_; |
| - Shadow* shadow_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); |
| -}; |
| +DEFINE_WINDOW_PROPERTY_KEY(NonClientFrameController*, |
| + kNonClientFrameControllerKey, |
| + nullptr); |
| // This class supports draggable app windows that paint their own custom frames. |
| // It uses empty insets, doesn't paint anything, and hit tests return HTCAPTION. |
| @@ -114,7 +74,7 @@ class EmptyDraggableNonClientFrameView : public views::NonClientFrameView { |
| DISALLOW_COPY_AND_ASSIGN(EmptyDraggableNonClientFrameView); |
| }; |
| -// Creates a ui::Window to host the top container when in immersive mode. The |
| +// Creates a Window to host the top container when in immersive mode. The |
| // top container contains a DetachedTitleAreaRenderer, which handles drawing and |
| // events. |
| class ImmersiveFullscreenControllerDelegateMus |
| @@ -122,7 +82,7 @@ class ImmersiveFullscreenControllerDelegateMus |
| public DetachedTitleAreaRendererHost { |
| public: |
| ImmersiveFullscreenControllerDelegateMus(views::Widget* frame, |
| - ui::Window* frame_window) |
| + aura::Window* frame_window) |
| : frame_(frame), frame_window_(frame_window) {} |
| ~ImmersiveFullscreenControllerDelegateMus() override { |
| DestroyTitleAreaWindow(); |
| @@ -136,29 +96,31 @@ class ImmersiveFullscreenControllerDelegateMus |
| void OnImmersiveRevealEnded() override { DestroyTitleAreaWindow(); } |
| void OnImmersiveFullscreenExited() override { DestroyTitleAreaWindow(); } |
| void SetVisibleFraction(double visible_fraction) override { |
| - if (!title_area_window_) |
| + aura::Window* title_area_window = GetTitleAreaWindow(); |
| + if (!title_area_window) |
| return; |
| - gfx::Rect bounds = title_area_window_->bounds(); |
| + gfx::Rect bounds = title_area_window->bounds(); |
| bounds.set_y(frame_window_->bounds().y() - bounds.height() + |
| visible_fraction * bounds.height()); |
| - title_area_window_->SetBounds(bounds); |
| + title_area_window->SetBounds(bounds); |
| } |
| std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override { |
| std::vector<gfx::Rect> result; |
| - if (!title_area_window_) |
| + const aura::Window* title_area_window = GetTitleAreaWindow(); |
| + if (!title_area_window) |
| return result; |
| // Clip the bounds of the title area to that of the |frame_window_|. |
| - gfx::Rect visible_bounds = title_area_window_->bounds(); |
| + gfx::Rect visible_bounds = title_area_window->bounds(); |
| visible_bounds.Intersect(frame_window_->bounds()); |
| - // The intersection is in the coordinates of |title_area_window_|'s parent, |
| - // convert to be in |title_area_window_| and then to screen. |
| - visible_bounds -= title_area_window_->bounds().origin().OffsetFromOrigin(); |
| + // The intersection is in the coordinates of |title_area_window|'s parent, |
| + // convert to be in |title_area_window| and then to screen. |
| + visible_bounds -= title_area_window->bounds().origin().OffsetFromOrigin(); |
| // TODO: this needs updating when parent of |title_area_window| is changed, |
| // DCHECK is to ensure when parent changes this code is updated. |
| // http://crbug.com/640392. |
| - DCHECK_EQ(frame_window_->parent(), title_area_window_->parent()); |
| - result.push_back(WmWindowMus::Get(title_area_window_) |
| + DCHECK_EQ(frame_window_->parent(), title_area_window->parent()); |
| + result.push_back(WmWindowMus::Get(title_area_window) |
| ->ConvertRectToScreen(visible_bounds)); |
| return result; |
| } |
| @@ -167,15 +129,13 @@ class ImmersiveFullscreenControllerDelegateMus |
| void OnDetachedTitleAreaRendererDestroyed( |
| DetachedTitleAreaRenderer* renderer) override { |
| title_area_renderer_ = nullptr; |
| - title_area_window_ = nullptr; |
| } |
| private: |
| void CreateTitleAreaWindow() { |
| - if (title_area_window_) |
| + if (GetTitleAreaWindow()) |
| return; |
| - title_area_window_ = frame_window_->window_tree()->NewWindow(); |
| // TODO(sky): bounds aren't right here. Need to convert to display. |
| gfx::Rect bounds = frame_window_->bounds(); |
| // Use the preferred size as when fullscreen the client area is generally |
| @@ -183,97 +143,100 @@ class ImmersiveFullscreenControllerDelegateMus |
| bounds.set_height( |
| NonClientFrameController::GetPreferredClientAreaInsets().top()); |
| bounds.set_y(bounds.y() - bounds.height()); |
| - title_area_window_->SetBounds(bounds); |
| - // TODO: making the reveal window a sibling is likely problematic. |
| - // http://crbug.com/640392, see also comment in GetVisibleBoundsInScreen(). |
| - frame_window_->parent()->AddChild(title_area_window_); |
| - title_area_window_->Reorder(frame_window_, |
| - ui::mojom::OrderDirection::ABOVE); |
| - title_area_renderer_ = |
| - new DetachedTitleAreaRenderer(this, frame_, title_area_window_, |
| - DetachedTitleAreaRenderer::Source::MASH); |
| + title_area_renderer_ = new DetachedTitleAreaRenderer( |
| + this, frame_, bounds, DetachedTitleAreaRenderer::Source::MASH); |
| } |
| void DestroyTitleAreaWindow() { |
| - if (!title_area_window_) |
| + if (!GetTitleAreaWindow()) |
| return; |
| title_area_renderer_->Destroy(); |
| title_area_renderer_ = nullptr; |
| - // TitleAreaRevealer ends up owning window. |
| - title_area_window_ = nullptr; |
| + } |
| + |
| + aura::Window* GetTitleAreaWindow() { |
| + return const_cast<aura::Window*>( |
| + const_cast<const ImmersiveFullscreenControllerDelegateMus*>(this) |
| + ->GetTitleAreaWindow()); |
| + } |
| + const aura::Window* GetTitleAreaWindow() const { |
| + return title_area_renderer_ |
| + ? title_area_renderer_->widget()->GetNativeView() |
| + : nullptr; |
| } |
| // The Widget immersive mode is operating on. |
| views::Widget* frame_; |
| // The ui::Window associated with |frame_|. |
| - ui::Window* frame_window_; |
| - |
| - // The window hosting the title area. |
| - ui::Window* title_area_window_ = nullptr; |
| + aura::Window* frame_window_; |
| DetachedTitleAreaRenderer* title_area_renderer_ = nullptr; |
| DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenControllerDelegateMus); |
| }; |
| -class WmNativeWidgetMus : public views::NativeWidgetMus { |
| +class WmNativeWidgetAura : public views::NativeWidgetAura { |
| public: |
| - WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, |
| - ui::Window* window, |
| - ui::WindowManagerClient* window_manager_client) |
| - : NativeWidgetMus(delegate, |
| - window, |
| - ui::mojom::CompositorFrameSinkType::UNDERLAY), |
| + WmNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate, |
| + aura::WindowManagerClient* window_manager_client, |
| + bool remove_standard_frame, |
| + bool enable_immersive) |
| + : views::NativeWidgetAura(delegate, true), |
|
James Cook
2016/12/05 19:21:44
The "true" here for is_parallel_widget_in_window_m
sky
2016/12/05 21:39:19
Done.
|
| + remove_standard_frame_(remove_standard_frame), |
| + enable_immersive_(enable_immersive), |
| window_manager_client_(window_manager_client) {} |
| - ~WmNativeWidgetMus() override {} |
| + ~WmNativeWidgetAura() override {} |
| - // NativeWidgetMus: |
| + // views::NativeWidgetAura: |
| views::NonClientFrameView* CreateNonClientFrameView() override { |
| - move_event_handler_.reset(new MoveEventHandler( |
| - window(), window_manager_client_, GetNativeView())); |
| - if (ShouldRemoveStandardFrame(window())) |
| + move_event_handler_ = base::MakeUnique<MoveEventHandler>( |
| + window_manager_client_, GetNativeView()); |
| + // TODO(sky): investigate why we have this. Seems this should be the same |
| + // as not specifying client area insets. |
| + if (remove_standard_frame_) |
| return new EmptyDraggableNonClientFrameView(); |
| - if (GetWindowType(window()) == ui::mojom::WindowType::PANEL) |
| + aura::Window* window = GetNativeView(); |
| + if (window->GetProperty(aura::client::kWindowTypeKey) == |
| + ui::mojom::WindowType::PANEL) |
| return new PanelFrameView(GetWidget(), PanelFrameView::FRAME_ASH); |
| - immersive_delegate_.reset( |
| - new ImmersiveFullscreenControllerDelegateMus(GetWidget(), window())); |
| - const bool enable_immersive = |
| - !window()->HasSharedProperty( |
| - ui::mojom::WindowManager::kDisableImmersive_Property) || |
| - !window()->GetSharedProperty<bool>( |
| - ui::mojom::WindowManager::kDisableImmersive_Property); |
| + immersive_delegate_ = |
| + base::MakeUnique<ImmersiveFullscreenControllerDelegateMus>(GetWidget(), |
| + window); |
| return new CustomFrameViewMus(GetWidget(), immersive_delegate_.get(), |
| - enable_immersive); |
| + enable_immersive_); |
| } |
| void InitNativeWidget(const views::Widget::InitParams& params) override { |
| - views::NativeWidgetMus::InitNativeWidget(params); |
| - aura::WindowTreeHost* window_tree_host = GetNativeView()->GetHost(); |
| + views::NativeWidgetAura::InitNativeWidget(params); |
| // TODO(sky): shadow should be determined by window type and shadow type. |
| - shadow_.reset(new Shadow); |
| + shadow_ = base::MakeUnique<Shadow>(); |
| shadow_->Init(Shadow::STYLE_INACTIVE); |
| - shadow_->Install(window()); |
| - ContentWindowLayoutManager* layout_manager = new ContentWindowLayoutManager( |
| - window_tree_host->window(), shadow_.get()); |
| - window_tree_host->window()->SetLayoutManager(layout_manager); |
| - const int inset = Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| - window_tree_host->SetOutputSurfacePaddingInPixels( |
| - gfx::Insets(inset, inset, inset, inset)); |
| - window_tree_host->window()->layer()->Add(shadow_->layer()); |
| + aura::Window* window = GetNativeWindow(); |
| + shadow_->Install(window); |
| + window->layer()->Add(shadow_->layer()); |
| shadow_->layer()->parent()->StackAtBottom(shadow_->layer()); |
| } |
| + void OnBoundsChanged(const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) override { |
| + views::NativeWidgetAura::OnBoundsChanged(old_bounds, new_bounds); |
| + if (shadow_) |
| + shadow_->SetContentBounds(gfx::Rect(new_bounds.size())); |
| + } |
| private: |
| + const bool remove_standard_frame_; |
| + const bool enable_immersive_; |
| + |
| // The shadow, may be null. |
| std::unique_ptr<Shadow> shadow_; |
| std::unique_ptr<MoveEventHandler> move_event_handler_; |
| - ui::WindowManagerClient* window_manager_client_; |
| + aura::WindowManagerClient* window_manager_client_; |
| std::unique_ptr<ImmersiveFullscreenControllerDelegateMus> immersive_delegate_; |
| - DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetMus); |
| + DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetAura); |
| }; |
| class ClientViewMus : public views::ClientView { |
| @@ -290,7 +253,8 @@ class ClientViewMus : public views::ClientView { |
| if (!frame_controller_->window()) |
| return true; |
| - frame_controller_->window()->RequestClose(); |
| + frame_controller_->window_manager_client()->RequestClose( |
| + frame_controller_->window()); |
| return false; |
| } |
| @@ -309,12 +273,66 @@ gfx::Insets GetExtendedHitRegion() { |
| } // namespace |
| +NonClientFrameController::NonClientFrameController( |
| + aura::Window* parent, |
| + aura::Window* context, |
| + const gfx::Rect& bounds, |
| + ui::mojom::WindowType window_type, |
| + std::map<std::string, std::vector<uint8_t>>* properties, |
| + WindowManager* window_manager) |
| + : window_manager_client_(window_manager->window_manager_client()), |
| + widget_(new views::Widget), |
| + window_(nullptr) { |
| + // To simplify things this code creates a Widget. While a Widget is created |
| + // we need to ensure we don't inadvertently change random properties of the |
| + // underlying ui::Window. For example, showing the Widget shouldn't change |
| + // the bounds of the ui::Window in anyway. |
| + // |
| + // Assertions around these type matching exist in MusClient. |
| + views::Widget::InitParams params( |
| + static_cast<views::Widget::InitParams::Type>(window_type)); |
| + params.parent = parent; |
| + params.context = context; |
|
James Cook
2016/12/05 19:21:44
nit: If either |parent| or |context| must be non-n
sky
2016/12/05 21:39:19
Done.
|
| + // TODO: properly set |params.activatable|. Should key off whether underlying |
| + // (mus) window can have focus. |
| + params.delegate = this; |
| + params.bounds = bounds; |
| + WmNativeWidgetAura* native_widget = new WmNativeWidgetAura( |
| + widget_, window_manager_client_, ShouldRemoveStandardFrame(*properties), |
| + ShouldEnableImmersive(*properties)); |
| + window_ = native_widget->GetNativeView(); |
| + WmWindowMus* wm_window = WmWindowMus::Get(window_); |
| + wm_window->set_widget(widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT); |
| + window_->AddObserver(this); |
| + params.native_widget = native_widget; |
| + aura::SetWindowType(window_, window_type); |
| + aura::PropertyConverter* property_converter = |
| + window_manager->property_converter(); |
| + for (auto& property_pair : *properties) { |
| + property_converter->SetPropertyFromTransportValue( |
| + window_, property_pair.first, &property_pair.second); |
| + } |
| + // Applying properties will have set the show state if specified. |
| + // NativeWidgetAura resets the show state from |params|, so we need to update |
| + // |params|. |
| + params.show_state = window_->GetProperty(aura::client::kShowStateKey); |
| + widget_->Init(params); |
| + did_init_native_widget_ = true; |
| + |
| + widget_->ShowInactive(); |
| + |
| + const int shadow_inset = |
| + Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| + const gfx::Insets extended_hit_region = |
| + wm_window->ShouldUseExtendedHitRegion() ? GetExtendedHitRegion() |
| + : gfx::Insets(); |
| + window_manager_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| + window_, gfx::Vector2d(shadow_inset, shadow_inset), extended_hit_region); |
| +} |
| + |
| // static |
| -void NonClientFrameController::Create( |
| - ui::Window* parent, |
| - ui::Window* window, |
| - ui::WindowManagerClient* window_manager_client) { |
| - new NonClientFrameController(parent, window, window_manager_client); |
| +NonClientFrameController* NonClientFrameController::Get(aura::Window* window) { |
| + return window->GetProperty(kNonClientFrameControllerKey); |
| } |
| // static |
| @@ -335,38 +353,11 @@ int NonClientFrameController::GetMaxTitleBarButtonWidth() { |
| 3; |
| } |
| -NonClientFrameController::NonClientFrameController( |
| - ui::Window* parent, |
| - ui::Window* window, |
| - ui::WindowManagerClient* window_manager_client) |
| - : widget_(new views::Widget), window_(window) { |
| - WmWindowMus* wm_window = WmWindowMus::Get(window); |
| - wm_window->set_widget(widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT); |
| - window_->AddObserver(this); |
| - |
| - // To simplify things this code creates a Widget. While a Widget is created |
| - // we need to ensure we don't inadvertently change random properties of the |
| - // underlying ui::Window. For example, showing the Widget shouldn't change |
| - // the bounds of the ui::Window in anyway. |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - // We initiate focus at the mus level, not at the views level. |
| - params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| - params.delegate = this; |
| - params.native_widget = |
| - new WmNativeWidgetMus(widget_, window, window_manager_client); |
| - widget_->Init(params); |
| - |
| - parent->AddChild(window); |
| - |
| - widget_->ShowInactive(); |
| - |
| - const int shadow_inset = |
| - Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| - const gfx::Insets extended_hit_region = |
| - wm_window->ShouldUseExtendedHitRegion() ? GetExtendedHitRegion() |
| - : gfx::Insets(); |
| - window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| - window, gfx::Vector2d(shadow_inset, shadow_inset), extended_hit_region); |
| +void NonClientFrameController::SetClientArea( |
| + const gfx::Insets& insets, |
| + const std::vector<gfx::Rect>& additional_client_areas) { |
| + client_area_insets_ = insets; |
| + additional_client_areas_ = additional_client_areas; |
| } |
| NonClientFrameController::~NonClientFrameController() { |
| @@ -383,39 +374,33 @@ void NonClientFrameController::OnDetachedTitleAreaRendererDestroyed( |
| } |
| base::string16 NonClientFrameController::GetWindowTitle() const { |
| - if (!window_->HasSharedProperty( |
| - ui::mojom::WindowManager::kWindowTitle_Property)) { |
| + if (!window_ || !window_->GetProperty(aura::client::kTitleKey)) |
| return base::string16(); |
| - } |
| - base::string16 title = window_->GetSharedProperty<base::string16>( |
| - ui::mojom::WindowManager::kWindowTitle_Property); |
| + base::string16 title = *window_->GetProperty(aura::client::kTitleKey); |
| - if (IsWindowJanky(window_)) |
| + if (window_->GetProperty(kWindowIsJanky)) |
| title += base::ASCIIToUTF16(" !! Not responding !!"); |
| return title; |
| } |
| bool NonClientFrameController::CanResize() const { |
| - return window_ && (::ash::mus::GetResizeBehavior(window_) & |
| - ui::mojom::kResizeBehaviorCanResize); |
| + return window_ && WmWindowMus::Get(window_)->CanResize(); |
| } |
| bool NonClientFrameController::CanMaximize() const { |
| - return window_ && (::ash::mus::GetResizeBehavior(window_) & |
| - ui::mojom::kResizeBehaviorCanMaximize); |
| + return window_ && WmWindowMus::Get(window_)->CanMaximize(); |
| } |
| bool NonClientFrameController::CanMinimize() const { |
| - return window_ && (::ash::mus::GetResizeBehavior(window_) & |
| - ui::mojom::kResizeBehaviorCanMinimize); |
| + return window_ && WmWindowMus::Get(window_)->CanMinimize(); |
| } |
| bool NonClientFrameController::ShouldShowWindowTitle() const { |
| // Only draw the title if the client hasn't declared any additional client |
| // areas which might conflict with it. |
| - return window_ && window_->additional_client_areas().empty(); |
| + return window_ && additional_client_areas_.empty(); |
| } |
| views::ClientView* NonClientFrameController::CreateClientView( |
| @@ -423,40 +408,41 @@ views::ClientView* NonClientFrameController::CreateClientView( |
| return new ClientViewMus(widget, GetContentsView(), this); |
| } |
| -void NonClientFrameController::OnTreeChanged(const TreeChangeParams& params) { |
| +void NonClientFrameController::OnWindowHierarchyChanged( |
| + const HierarchyChangeParams& params) { |
| if (params.new_parent != window_ || |
| - !ShouldRenderParentTitleArea(params.target)) { |
| + !params.target->GetProperty(kRenderTitleAreaProperty)) { |
| return; |
| } |
| if (detached_title_area_renderer_) { |
| detached_title_area_renderer_->Destroy(); |
| detached_title_area_renderer_ = nullptr; |
| } |
| - detached_title_area_renderer_ = new DetachedTitleAreaRenderer( |
| - this, widget_, params.target, DetachedTitleAreaRenderer::Source::CLIENT); |
| + detached_title_area_renderer_ = |
| + new DetachedTitleAreaRenderer(this, widget_, params.target->bounds(), |
| + DetachedTitleAreaRenderer::Source::CLIENT); |
| } |
| -void NonClientFrameController::OnWindowSharedPropertyChanged( |
| - ui::Window* window, |
| - const std::string& name, |
| - const std::vector<uint8_t>* old_data, |
| - const std::vector<uint8_t>* new_data) { |
| - if (name == ui::mojom::WindowManager::kResizeBehavior_Property) |
| - widget_->OnSizeConstraintsChanged(); |
| - else if (name == ui::mojom::WindowManager::kWindowTitle_Property) |
| - widget_->UpdateWindowTitle(); |
| -} |
| +void NonClientFrameController::OnWindowPropertyChanged(aura::Window* window, |
| + const void* key, |
| + intptr_t old) { |
| + // Properties are applied before the call to InitNativeWidget(). Ignore |
| + // processing changes in this case as the Widget is not in a state where we |
| + // can use it yet. |
| + if (!did_init_native_widget_) |
| + return; |
| -void NonClientFrameController::OnWindowLocalPropertyChanged(ui::Window* window, |
| - const void* key, |
| - intptr_t old) { |
| - if (IsWindowJankyProperty(key)) { |
| + if (key == kWindowIsJanky) { |
| widget_->UpdateWindowTitle(); |
| widget_->non_client_view()->frame_view()->SchedulePaint(); |
| + } else if (key == aura::client::kResizeBehaviorKey) { |
| + widget_->OnSizeConstraintsChanged(); |
| + } else if (key == aura::client::kTitleKey) { |
| + widget_->UpdateWindowTitle(); |
| } |
| } |
| -void NonClientFrameController::OnWindowDestroyed(ui::Window* window) { |
| +void NonClientFrameController::OnWindowDestroyed(aura::Window* window) { |
| window_->RemoveObserver(this); |
| window_ = nullptr; |
| } |