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

Unified Diff: views/widget/widget_win.cc

Issue 206004: Merge 26135 - The focus is not restored properly when a Windows modal dialog... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/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 26159)
+++ views/widget/widget_win.cc (working copy)
@@ -147,7 +147,8 @@
is_mouse_down_(false),
is_window_(false),
class_style_(CS_DBLCLKS),
- hwnd_(NULL) {
+ hwnd_(NULL),
+ restore_focus_when_enabled_(false) {
}
WidgetWin::~WidgetWin() {
@@ -1070,6 +1071,10 @@
widget->OnFinalMessage(window);
if (message == WM_ACTIVATE)
PostProcessActivateMessage(widget, LOWORD(w_param));
+ if (message == WM_ENABLE && restore_focus_when_enabled_) {
+ restore_focus_when_enabled_ = false;
+ focus_manager_->RestoreFocusedView();
+ }
return result;
}
@@ -1085,6 +1090,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();
}
}
Property changes on: views\widget\widget_win.cc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/views/widget/widget_win.cc:r26135
« 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