Commit 44bf3f8f authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Make Widget::Show() creates active windows.

It is actually what this is doing in practice but only because
SHOW_STATE_INACTIVE implementation is broken and usually creates active
windows.

BUG=None

Review URL: https://codereview.chromium.org/118283003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243590 0039d316-1c4b-4281-b951-d872f2087c98
parent 0b15c8c3
......@@ -227,7 +227,7 @@ void AutofillPopupViewViews::Show() {
set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor));
UpdateBoundsAndRedrawPopup();
GetWidget()->Show();
GetWidget()->ShowInactive();
if (controller_->hide_on_outside_click())
GetWidget()->SetCapture(this);
......
......@@ -293,7 +293,7 @@ FullscreenExitBubbleViews::FullscreenExitBubbleViews(
// that it is sliding off the top of the screen.
popup_->GetRootView()->SetLayoutManager(NULL);
view_->SetBounds(0, 0, size.width(), size.height());
popup_->Show(); // This does not activate the popup.
popup_->ShowInactive(); // This does not activate the popup.
popup_->AddObserver(this);
......
......@@ -226,7 +226,7 @@ void OmniboxPopupContentsView::UpdatePopupAppearance() {
// window showing.
return;
}
popup_->Show();
popup_->ShowInactive();
} else {
// Animate the popup shrinking, but don't animate growing larger since that
// would make the popup feel less responsive.
......
......@@ -211,7 +211,7 @@ void StatusBubbleViews::StatusView::Show() {
Stop();
CancelTimer();
SetOpacity(1.0);
popup_->Show();
popup_->ShowInactive();
state_ = BUBBLE_SHOWN;
}
......@@ -295,7 +295,7 @@ void StatusBubbleViews::StatusView::StartHiding() {
void StatusBubbleViews::StatusView::StartShowing() {
if (state_ == BUBBLE_HIDDEN) {
popup_->Show();
popup_->ShowInactive();
state_ = BUBBLE_SHOWING_TIMER;
StartTimer(base::TimeDelta::FromMilliseconds(kShowDelay));
} else if (state_ == BUBBLE_HIDING_TIMER) {
......
......@@ -76,7 +76,7 @@ void MenuHost::ShowMenuHost(bool do_capture) {
// Doing a capture may make us get capture lost. Ignore it while we're in the
// process of showing.
base::AutoReset<bool> reseter(&ignore_capture_lost_, true);
Show();
ShowInactive();
if (do_capture) {
#if defined(USE_AURA)
// Cancel existing touches, so we don't miss some touch release/cancel
......
......@@ -462,7 +462,7 @@ void NativeWidgetAura::CloseNow() {
}
void NativeWidgetAura::Show() {
ShowWithWindowState(ui::SHOW_STATE_INACTIVE);
ShowWithWindowState(ui::SHOW_STATE_NORMAL);
}
void NativeWidgetAura::Hide() {
......
......@@ -430,8 +430,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
// set to true after Close() has been invoked on the NativeWidget.
bool IsClosed() const;
// Shows or hides the widget, without changing activation state.
// Shows the widget and activates it.
virtual void Show();
// Hides the widget.
void Hide();
// Like Show(), but does not activate the window.
......
......@@ -167,7 +167,8 @@ ui::WindowShowState GetWidgetShowState(const Widget* widget) {
return widget->IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN :
widget->IsMaximized() ? ui::SHOW_STATE_MAXIMIZED :
widget->IsMinimized() ? ui::SHOW_STATE_MINIMIZED :
ui::SHOW_STATE_NORMAL;
widget->IsActive() ? ui::SHOW_STATE_NORMAL :
ui::SHOW_STATE_INACTIVE;
}
TEST_F(WidgetTest, WidgetInitParams) {
......@@ -2259,5 +2260,43 @@ TEST_F(WidgetTest, WindowModalityActivationTest) {
#endif
#endif
TEST_F(WidgetTest, ShowCreatesActiveWindow) {
Widget* widget = CreateTopLevelPlatformWidget();
widget->Show();
EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
widget->CloseNow();
}
TEST_F(WidgetTest, ShowInactive) {
Widget* widget = CreateTopLevelPlatformWidget();
widget->ShowInactive();
EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_INACTIVE);
widget->CloseNow();
}
TEST_F(WidgetTest, ShowInactiveAfterShow) {
Widget* widget = CreateTopLevelPlatformWidget();
widget->Show();
widget->ShowInactive();
EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
widget->CloseNow();
}
TEST_F(WidgetTest, ShowAfterShowInactive) {
Widget* widget = CreateTopLevelPlatformWidget();
widget->ShowInactive();
widget->Show();
EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
widget->CloseNow();
}
} // namespace test
} // namespace views
......@@ -560,7 +560,7 @@ void HWNDMessageHandler::StackAtTop() {
void HWNDMessageHandler::Show() {
if (IsWindow(hwnd()))
ShowWindowWithState(ui::SHOW_STATE_INACTIVE);
ShowWindowWithState(ui::SHOW_STATE_NORMAL);
}
void HWNDMessageHandler::ShowWindowWithState(ui::WindowShowState show_state) {
......
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