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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/widget_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/views/widget/widget_win.cc:r26135
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/widget/widget_win.h" 5 #include "views/widget/widget_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/path.h" 8 #include "app/gfx/path.h"
9 #include "app/win_util.h" 9 #include "app/win_util.h"
10 #include "base/gfx/native_theme.h" 10 #include "base/gfx/native_theme.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 window_style_(0), 140 window_style_(0),
141 window_ex_style_(kWindowDefaultExStyle), 141 window_ex_style_(kWindowDefaultExStyle),
142 use_layered_buffer_(true), 142 use_layered_buffer_(true),
143 layered_alpha_(255), 143 layered_alpha_(255),
144 delete_on_destroy_(true), 144 delete_on_destroy_(true),
145 can_update_layered_window_(true), 145 can_update_layered_window_(true),
146 last_mouse_event_was_move_(false), 146 last_mouse_event_was_move_(false),
147 is_mouse_down_(false), 147 is_mouse_down_(false),
148 is_window_(false), 148 is_window_(false),
149 class_style_(CS_DBLCLKS), 149 class_style_(CS_DBLCLKS),
150 hwnd_(NULL) { 150 hwnd_(NULL),
151 restore_focus_when_enabled_(false) {
151 } 152 }
152 153
153 WidgetWin::~WidgetWin() { 154 WidgetWin::~WidgetWin() {
154 MessageLoopForUI::current()->RemoveObserver(this); 155 MessageLoopForUI::current()->RemoveObserver(this);
155 } 156 }
156 157
157 void WidgetWin::Init(HWND parent, const gfx::Rect& bounds) { 158 void WidgetWin::Init(HWND parent, const gfx::Rect& bounds) {
158 if (window_style_ == 0) 159 if (window_style_ == 0)
159 window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle; 160 window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle;
160 161
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 if (ProcessNativeControlMessage(message, w_param, l_param, &result)) 1064 if (ProcessNativeControlMessage(message, w_param, l_param, &result))
1064 return result; 1065 return result;
1065 1066
1066 // Otherwise we handle everything else. 1067 // Otherwise we handle everything else.
1067 if (!widget->ProcessWindowMessage(window, message, w_param, l_param, result)) 1068 if (!widget->ProcessWindowMessage(window, message, w_param, l_param, result))
1068 result = DefWindowProc(window, message, w_param, l_param); 1069 result = DefWindowProc(window, message, w_param, l_param);
1069 if (message == WM_NCDESTROY) 1070 if (message == WM_NCDESTROY)
1070 widget->OnFinalMessage(window); 1071 widget->OnFinalMessage(window);
1071 if (message == WM_ACTIVATE) 1072 if (message == WM_ACTIVATE)
1072 PostProcessActivateMessage(widget, LOWORD(w_param)); 1073 PostProcessActivateMessage(widget, LOWORD(w_param));
1074 if (message == WM_ENABLE && restore_focus_when_enabled_) {
1075 restore_focus_when_enabled_ = false;
1076 focus_manager_->RestoreFocusedView();
1077 }
1073 return result; 1078 return result;
1074 } 1079 }
1075 1080
1076 // static 1081 // static
1077 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, 1082 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget,
1078 int activation_state) { 1083 int activation_state) {
1079 if (!widget->focus_manager_.get()) { 1084 if (!widget->focus_manager_.get()) {
1080 NOTREACHED(); 1085 NOTREACHED();
1081 return; 1086 return;
1082 } 1087 }
1083 if (WA_INACTIVE == activation_state) { 1088 if (WA_INACTIVE == activation_state) {
1084 widget->focus_manager_->StoreFocusedView(); 1089 widget->focus_manager_->StoreFocusedView();
1085 } else { 1090 } else {
1086 // We must restore the focus after the message has been DefProc'ed as it 1091 // We must restore the focus after the message has been DefProc'ed as it
1087 // does set the focus to the last focused HWND. 1092 // does set the focus to the last focused HWND.
1093 // Note that if the window is not enabled, we cannot restore the focus as
1094 // calling ::SetFocus on a child of the non-enabled top-window would fail.
1095 // This is the case when showing a modal dialog (such as 'open file',
1096 // 'print'...) from a different thread.
1097 // In that case we delay the focus restoration to when the window is enabled
1098 // again.
1099 if (!IsWindowEnabled(widget->GetNativeView())) {
1100 DCHECK(!widget->restore_focus_when_enabled_);
1101 widget->restore_focus_when_enabled_ = true;
1102 return;
1103 }
1088 widget->focus_manager_->RestoreFocusedView(); 1104 widget->focus_manager_->RestoreFocusedView();
1089 } 1105 }
1090 } 1106 }
1091 } // namespace views 1107 } // namespace views
OLDNEW
« 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