Commit de261add authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Pass widget to ShouldAutoHideTitlebars

This is less likely an issue because I'm no aware of an app that can't
be maximized/snapped in chrome (arc will use different code path)
but this is right thing anyway.

Bug: None
Change-Id: Ia7f49fd99000574b9431218b3be873baed9afdd0
Reviewed-on: https://chromium-review.googlesource.com/987542
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547488}
parent 3a713ddb
......@@ -89,9 +89,10 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
void OnTabletModeStarted() override {
if (window_state_->IsFullscreen())
return;
views::Widget* widget =
views::Widget::GetWidgetForNativeWindow(window_state_->window());
if (Shell::Get()->tablet_mode_controller()->ShouldAutoHideTitlebars(
nullptr)) {
widget)) {
immersive_fullscreen_controller_->SetEnabled(
ImmersiveFullscreenController::WINDOW_TYPE_OTHER, true);
}
......@@ -132,9 +133,11 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
// wm::WindowStateObserver:
void OnPostWindowStateTypeChange(wm::WindowState* window_state,
mojom::WindowStateType old_type) override {
views::Widget* widget =
views::Widget::GetWidgetForNativeWindow(window_state->window());
if (Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->ShouldAutoHideTitlebars(
nullptr)) {
widget)) {
DCHECK(immersive_fullscreen_controller_);
if (window_state->IsMinimized() &&
immersive_fullscreen_controller_->IsEnabled()) {
......
......@@ -167,7 +167,7 @@ void HeaderView::OnTabletModeStarted() {
caption_button_container_->UpdateCaptionButtonState(true /*=animate*/);
parent()->Layout();
if (Shell::Get()->tablet_mode_controller()->ShouldAutoHideTitlebars(
nullptr)) {
target_widget_)) {
target_widget_->non_client_view()->Layout();
}
}
......
......@@ -223,9 +223,10 @@ void TabletModeController::RemoveObserver(TabletModeObserver* observer) {
}
bool TabletModeController::ShouldAutoHideTitlebars(views::Widget* widget) {
DCHECK(widget);
const bool tablet_mode = IsTabletModeWindowManagerEnabled();
if (!tablet_mode || !widget)
return tablet_mode;
if (!tablet_mode)
return false;
return widget->IsMaximized() ||
wm::GetWindowState(widget->GetNativeWindow())->IsSnapped();
......
......@@ -103,9 +103,7 @@ class ASH_EXPORT TabletModeController
void AddObserver(TabletModeObserver* observer);
void RemoveObserver(TabletModeObserver* observer);
// Checks if we should auto hide title bars in tablet mode. If |widget| is not
// null this also checks if the window associated with |widget| is in an auto
// hide state.
// Checks if we should auto hide title bars for the |widget| in tablet mode.
bool ShouldAutoHideTitlebars(views::Widget* widget);
// Flushes the mojo message pipe to chrome.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment