Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: views/widget/widget_win.cc

Issue 199106: Fix focus bug with shell dialogs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/widget/widget_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget_win.cc
===================================================================
--- views/widget/widget_win.cc (revision 26112)
+++ views/widget/widget_win.cc (working copy)
@@ -52,7 +52,8 @@
can_update_layered_window_(true),
last_mouse_event_was_move_(false),
is_mouse_down_(false),
- is_window_(false) {
+ is_window_(false),
+ restore_focus_when_enabled_(false) {
}
WidgetWin::~WidgetWin() {
@@ -926,6 +927,10 @@
OnFinalMessage(window);
if (message == WM_ACTIVATE)
PostProcessActivateMessage(this, LOWORD(w_param));
+ if (message == WM_ENABLE && restore_focus_when_enabled_) {
+ restore_focus_when_enabled_ = false;
+ focus_manager_->RestoreFocusedView();
+ }
return result;
}
@@ -941,6 +946,17 @@
} else {
// We must restore the focus after the message has been DefProc'ed as it
// does set the focus to the last focused HWND.
+ // Note that if the window is not enabled, we cannot restore the focus as
+ // calling ::SetFocus on a child of the non-enabled top-window would fail.
+ // This is the case when showing a modal dialog (such as 'open file',
+ // 'print'...) from a different thread.
+ // In that case we delay the focus restoration to when the window is enabled
+ // again.
+ if (!IsWindowEnabled(widget->GetNativeView())) {
+ DCHECK(!widget->restore_focus_when_enabled_);
+ widget->restore_focus_when_enabled_ = true;
+ return;
+ }
widget->focus_manager_->RestoreFocusedView();
}
}
« no previous file with comments | « views/widget/widget_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698