diff options
author | jackhou <jackhou@chromium.org> | 2015-01-18 19:45:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-19 03:46:13 +0000 |
commit | 3d1fd029975c325129474b9d4e262940d99ab375 (patch) | |
tree | c4ba3e2db13563d8b3d78e9435e52d6b3a166f9e | |
parent | fc73480148a774e367c6667b0844f5e6cf6735cb (diff) | |
download | chromium_src-3d1fd029975c325129474b9d4e262940d99ab375.zip chromium_src-3d1fd029975c325129474b9d4e262940d99ab375.tar.gz chromium_src-3d1fd029975c325129474b9d4e262940d99ab375.tar.bz2 |
[Win] Fix black screen when min/maximizing hidden app window.
On Windows, an app window that is initialized with hidden:true and
state:'maximized' will start visible and maximized, but its content is
all black. This is because maximizing a hidden window on Windows causes
the window to be shown, but this path does not also trigger the content
to show.
This CL is a temporary fix to prevent the above state without changing
the current behavior. App windows that are initially hidden will not
also be maximized, minimized, or fullscreen. On Windows, maximizing or
minimizing hidden app windows will cause them to be shown.
In the long term, we want the behavior on Windows to match CrOS where
calling maximize() on a hidden window does nothing, and the next show()
will show the window maximized.
BUG=436867
Review URL: https://codereview.chromium.org/851233002
Cr-Commit-Position: refs/heads/master@{#312061}
3 files changed, 41 insertions, 9 deletions
diff --git a/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.cc b/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.cc index 0762f29..1782078 100644 --- a/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.cc +++ b/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.cc @@ -7,6 +7,7 @@ #include "chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.h" #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" #include "ui/aura/window.h" +#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" AppWindowDesktopNativeWidgetAuraWin::AppWindowDesktopNativeWidgetAuraWin( ChromeNativeAppWindowViewsWin* app_window) @@ -21,7 +22,27 @@ AppWindowDesktopNativeWidgetAuraWin::~AppWindowDesktopNativeWidgetAuraWin() { void AppWindowDesktopNativeWidgetAuraWin::InitNativeWidget( const views::Widget::InitParams& params) { views::Widget::InitParams modified_params = params; - modified_params.desktop_window_tree_host = - new AppWindowDesktopWindowTreeHostWin(app_window_, this); + tree_host_ = new AppWindowDesktopWindowTreeHostWin(app_window_, this); + modified_params.desktop_window_tree_host = tree_host_; DesktopNativeWidgetAura::InitNativeWidget(modified_params); } + +void AppWindowDesktopNativeWidgetAuraWin::Maximize() { + // Maximizing on Windows causes the window to be shown. Call Show() first to + // ensure the content view is also made visible. See http://crbug.com/436867. + // TODO(jackhou): Make this behavior the same as other platforms, i.e. calling + // Maximize() does not also show the window. + if (!tree_host_->IsVisible()) + DesktopNativeWidgetAura::Show(); + DesktopNativeWidgetAura::Maximize(); +} + +void AppWindowDesktopNativeWidgetAuraWin::Minimize() { + // Minimizing on Windows causes the window to be shown. Call Show() first to + // ensure the content view is also made visible. See http://crbug.com/436867. + // TODO(jackhou): Make this behavior the same as other platforms, i.e. calling + // Minimize() does not also show the window. + if (!tree_host_->IsVisible()) + DesktopNativeWidgetAura::Show(); + DesktopNativeWidgetAura::Minimize(); +} diff --git a/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.h b/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.h index 43bc8a7..75f3464 100644 --- a/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.h +++ b/chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.h @@ -12,6 +12,10 @@ class BrowserFrame; class BrowserView; class ChromeNativeAppWindowViewsWin; +namespace views { +class DesktopWindowTreeHost; +} + namespace wm { class VisibilityController; } @@ -30,11 +34,16 @@ class AppWindowDesktopNativeWidgetAuraWin // Overridden from views::DesktopNativeWidgetAura: virtual void InitNativeWidget( const views::Widget::InitParams& params) override; + void Maximize() override; + void Minimize() override; private: // Ownership managed by the views system. ChromeNativeAppWindowViewsWin* app_window_; + // Owned by superclass DesktopNativeWidgetAura. + views::DesktopWindowTreeHost* tree_host_; + DISALLOW_COPY_AND_ASSIGN(AppWindowDesktopNativeWidgetAuraWin); }; diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc index 1b2b3b2..fe9b758 100644 --- a/extensions/browser/app_window/app_window.cc +++ b/extensions/browser/app_window/app_window.cc @@ -299,14 +299,16 @@ void AppWindow::Init(const GURL& url, // Panels are not activated by default. Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE : SHOW_ACTIVE); - } - if (new_params.state == ui::SHOW_STATE_FULLSCREEN) - Fullscreen(); - else if (new_params.state == ui::SHOW_STATE_MAXIMIZED) - Maximize(); - else if (new_params.state == ui::SHOW_STATE_MINIMIZED) - Minimize(); + // These states may cause the window to show, so they are ignored if the + // window is initially hidden. + if (new_params.state == ui::SHOW_STATE_FULLSCREEN) + Fullscreen(); + else if (new_params.state == ui::SHOW_STATE_MAXIMIZED) + Maximize(); + else if (new_params.state == ui::SHOW_STATE_MINIMIZED) + Minimize(); + } OnNativeWindowChanged(); |