Commit 129abeac authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: fix restoring minimized windows

This change:
1) Has BridgedNativeWidgetHostImpl notify the owning Widget when it becomes
   minimized
2) Has session restore not activate minimized browser windows when selecting
   a restored tab
3) Has session restore not show a newly created browser window if it's
   minimized

restore save; without this change, the widget will not get saved as minimized.
window. On Mac, showing/activating a window implies de-minimizing it, so this
is required to avoid de-minimizing saved minimized windows, but I think it is
necessary on other platforms as well.

Test steps:
1) Start Chromium
2) Create a second browser window (cmd-n) and minimize it
3) In the first window, chrome://restart

Before this change, both browser windows appear after restart; after this
change, the first window appears and the second stays minimized.

Note that there is a graphical glitch when first restoring a window that is
minimized this way: the window paints as blank for a few frames while running
the deminiaturize animation.

Bug: 888218
Change-Id: I8ac121408336a7d6aeedd2b27cd2c9c9d20a18f2
Reviewed-on: https://chromium-review.googlesource.com/c/1268396Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599961}
parent b5110af2
...@@ -201,5 +201,5 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMinimized) { ...@@ -201,5 +201,5 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMinimized) {
// Chrome OS always activates the last browser windows on login to remind // Chrome OS always activates the last browser windows on login to remind
// users they have a browser running instead of just showing them an empty // users they have a browser running instead of just showing them an empty
// desktop. // desktop.
EXPECT_EQ(0u, minimized_count); EXPECT_NE(2u, minimized_count);
} }
...@@ -124,6 +124,7 @@ WebContents* AddRestoredTab( ...@@ -124,6 +124,7 @@ WebContents* AddRestoredTab(
browser->tab_strip_model()->InsertWebContentsAt( browser->tab_strip_model()->InsertWebContentsAt(
tab_index, std::move(web_contents), add_types); tab_index, std::move(web_contents), add_types);
if (select) { if (select) {
if (!browser->window()->IsMinimized())
browser->window()->Activate(); browser->window()->Activate();
} else { } else {
// We set the size of the view here, before Blink does its initial layout. // We set the size of the view here, before Blink does its initial layout.
......
...@@ -707,6 +707,8 @@ void BridgedNativeWidgetHostImpl::OnWindowFullscreenTransitionComplete( ...@@ -707,6 +707,8 @@ void BridgedNativeWidgetHostImpl::OnWindowFullscreenTransitionComplete(
void BridgedNativeWidgetHostImpl::OnWindowMiniaturizedChanged( void BridgedNativeWidgetHostImpl::OnWindowMiniaturizedChanged(
bool miniaturized) { bool miniaturized) {
is_miniaturized_ = miniaturized; is_miniaturized_ = miniaturized;
if (native_widget_mac_)
native_widget_mac_->GetWidget()->OnNativeWidgetWindowShowStateChanged();
} }
void BridgedNativeWidgetHostImpl::OnWindowDisplayChanged( void BridgedNativeWidgetHostImpl::OnWindowDisplayChanged(
......
...@@ -377,8 +377,8 @@ void NativeWidgetMac::Show(ui::WindowShowState show_state, ...@@ -377,8 +377,8 @@ void NativeWidgetMac::Show(ui::WindowShowState show_state,
case ui::SHOW_STATE_DEFAULT: case ui::SHOW_STATE_DEFAULT:
case ui::SHOW_STATE_NORMAL: case ui::SHOW_STATE_NORMAL:
case ui::SHOW_STATE_INACTIVE: case ui::SHOW_STATE_INACTIVE:
break;
case ui::SHOW_STATE_MINIMIZED: case ui::SHOW_STATE_MINIMIZED:
break;
case ui::SHOW_STATE_MAXIMIZED: case ui::SHOW_STATE_MAXIMIZED:
case ui::SHOW_STATE_FULLSCREEN: case ui::SHOW_STATE_FULLSCREEN:
NOTIMPLEMENTED(); NOTIMPLEMENTED();
...@@ -387,10 +387,12 @@ void NativeWidgetMac::Show(ui::WindowShowState show_state, ...@@ -387,10 +387,12 @@ void NativeWidgetMac::Show(ui::WindowShowState show_state,
NOTREACHED(); NOTREACHED();
break; break;
} }
bridge()->SetVisibilityState( auto window_state = WindowVisibilityState::kShowAndActivateWindow;
show_state == ui::SHOW_STATE_INACTIVE if (show_state == ui::SHOW_STATE_INACTIVE)
? WindowVisibilityState::kShowInactive window_state = WindowVisibilityState::kShowInactive;
: WindowVisibilityState::kShowAndActivateWindow); else if (show_state == ui::SHOW_STATE_MINIMIZED)
window_state = WindowVisibilityState::kHideWindow;
bridge()->SetVisibilityState(window_state);
// Ignore the SetInitialFocus() result. BridgedContentView should get // Ignore the SetInitialFocus() result. BridgedContentView should get
// firstResponder status regardless. // firstResponder status regardless.
......
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