summaryrefslogtreecommitdiffstats
path: root/ui/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 15:59:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 15:59:42 +0000
commit3561df348f6ef02bb1cde6317a89bdb0c8c54bad (patch)
tree331d8928305b75b666d055c897670ed7d5a6aad6 /ui/views/widget
parent62e863791fc10b4ed31d4e21d4b565af0d609f7a (diff)
downloadchromium_src-3561df348f6ef02bb1cde6317a89bdb0c8c54bad.zip
chromium_src-3561df348f6ef02bb1cde6317a89bdb0c8c54bad.tar.gz
chromium_src-3561df348f6ef02bb1cde6317a89bdb0c8c54bad.tar.bz2
Adds back focus restoration hack that Mike recently nuked. The hack
is needed for exactly the case that is documented there. I've added a test case for it to make sure we don't regress it again. Since test is focus based I'm putting the test code in chrome, even though it only needs views types. To get Mikes tests to work I also made it so that changing the focused view also sets the stored focus view. This way if the window is hidden at the time the focus request we'll restore the focused view correctly when the window is shown. Lastly I disabled a couple of tests that rely on focus and aren't in interactive_ui_tests. BUG=125976, 131660, 224591 TEST=covered by tests, in chrome can verify by way of selecting text on page, minimizing chrome, restoring chrome (click on taskbar) and make sure page is still focused. Windows specific. R=ben@chomium.org, msw@chromium.org Review URL: https://chromiumcodereview.appspot.com/14520013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget')
-rw-r--r--ui/views/widget/native_widget_win.cc11
-rw-r--r--ui/views/widget/widget.cc3
-rw-r--r--ui/views/widget/widget_unittest.cc4
3 files changed, 16 insertions, 2 deletions
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 6e8c4f4..53cc385 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -500,6 +500,17 @@ void NativeWidgetWin::SaveFocusOnDeactivate() {
}
void NativeWidgetWin::RestoreFocusOnActivate() {
+ // Mysteriously, this only appears to be needed support restoration of focus
+ // to a child hwnd when restoring its top level window from the minimized
+ // state. If we don't do this, then ::SetFocus() to that child HWND returns
+ // ERROR_INVALID_PARAMETER, despite both HWNDs being of the same thread.
+ // See http://crbug.com/125976 and
+ // chrome/browser/ui/views/native_widget_win_interactive_uitest.cc .
+ {
+ // Since this is a synthetic reset, we don't need to tell anyone about it.
+ AutoNativeNotificationDisabler disabler;
+ GetWidget()->GetFocusManager()->ClearFocus();
+ }
RestoreFocusOnEnable();
}
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index f14cbcd..1d7333a 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -944,7 +944,8 @@ bool Widget::SetInitialFocus() {
if (!focus_on_creation_) {
// If not focusing the window now, tell the focus manager which view to
// focus when the window is restored.
- focus_manager_->SetStoredFocusView(v);
+ if (v)
+ focus_manager_->SetStoredFocusView(v);
return true;
}
if (v)
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index de7fd52..419485d 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -1187,7 +1187,9 @@ TEST_F(WidgetTest, KeyboardInputEvent) {
}
// Verifies bubbles result in a focus lost when shown.
-TEST_F(WidgetTest, FocusChangesOnBubble) {
+// TODO(msw): this tests relies on focus, it needs to be in
+// interactive_ui_tests.
+TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) {
// Create a widget, show and activate it and focus the contents view.
View* contents_view = new View;
contents_view->set_focusable(true);