Commit bad44662 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

make widget stay visible when root window is minimized

This was a regression caused by crrev.com/c/1326621, which
showed/hid the root window on Restore/Minimize. In turn this caused
DesktopNativeWidgetAura::IsVisible() to return false for minimized
widgets, because |content_window_| was not visible. Fix is to
use TargetVisibility() instead of IsVisible().

Bug: 813093, 927489
Change-Id: I7cb97ccae6452320ee4a906875535f618e1ab013
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1406069Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638715}
parent 91d93e8f
......@@ -792,8 +792,8 @@ bool DesktopNativeWidgetAura::IsVisible() const {
// platform code might show the desktop window tree host early, meaning we
// aren't fully visible as we haven't shown the content window. Callers may
// short-circuit a call to show this widget if they think its already visible.
return content_window_ && content_window_->IsVisible() &&
desktop_window_tree_host_->IsVisible();
return content_window_ && content_window_->TargetVisibility() &&
desktop_window_tree_host_->IsVisible();
}
void DesktopNativeWidgetAura::Activate() {
......
......@@ -16,6 +16,7 @@
#include "base/timer/timer.h"
#include "base/win/windows_version.h"
#include "build/build_config.h"
#include "ui/aura/window.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/base/resource/resource_bundle.h"
......@@ -41,7 +42,6 @@
#include "ui/wm/public/activation_client.h"
#if defined(OS_WIN)
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/win/hwnd_util.h"
......@@ -1419,38 +1419,32 @@ TEST_F(DesktopWidgetTestInteractive, RestoreAfterMinimize) {
}
#if defined(OS_WIN)
// Tests that widget visibility toggles correctly when minimized and maximized
// on Windows. Test using both the widget API as well as native win32 functions
// that operate directly on the underlying HWND. Behavior should be the same.
// TODO(davidbienvenu): Get this test to pass on Linux and ChromeOS by hiding
// the root window when desktop widget is minimized.
// Tests that root window visibility toggles correctly when the desktop widget
// is minimized and maximized on Windows, and the Widget remains visible.
TEST_F(DesktopWidgetTestInteractive, RestoreAndMinimizeVisibility) {
Widget* widget = CreateWidget();
aura::Window* root_window = GetRootWindow(widget);
ShowSync(widget);
ASSERT_FALSE(widget->IsMinimized());
EXPECT_TRUE(root_window->IsVisible());
PropertyWaiter minimize_widget_waiter(
base::Bind(&Widget::IsMinimized, base::Unretained(widget)), true);
base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
true);
widget->Minimize();
EXPECT_TRUE(minimize_widget_waiter.Wait());
EXPECT_FALSE(widget->IsVisible());
EXPECT_TRUE(widget->IsVisible());
EXPECT_FALSE(root_window->IsVisible());
PropertyWaiter restore_widget_waiter(
base::Bind(&Widget::IsMinimized, base::Unretained(widget)), false);
base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
false);
widget->Restore();
EXPECT_TRUE(restore_widget_waiter.Wait());
EXPECT_TRUE(widget->IsVisible());
PropertyWaiter minimize_hwnd_waiter(
base::Bind(&Widget::IsMinimized, base::Unretained(widget)), true);
CloseWindow(HWNDForWidget(widget));
EXPECT_TRUE(minimize_hwnd_waiter.Wait());
EXPECT_FALSE(widget->IsVisible());
PropertyWaiter restore_hwnd_waiter(
base::Bind(&Widget::IsMinimized, base::Unretained(widget)), false);
OpenIcon(HWNDForWidget(widget));
EXPECT_TRUE(restore_hwnd_waiter.Wait());
EXPECT_TRUE(widget->IsVisible());
EXPECT_TRUE(root_window->IsVisible());
widget->CloseNow();
}
#endif // defined(OS_WIN)
......
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