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