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

Unified Diff: views/widget/widget_win.cc

Issue 140023: Reverting 18872. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 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') | views/window/window_win.cc » ('j') | 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 18872)
+++ views/widget/widget_win.cc (working copy)
@@ -154,7 +154,8 @@
MessageLoopForUI::current()->RemoveObserver(this);
}
-void WidgetWin::Init(HWND parent, const gfx::Rect& bounds) {
+void WidgetWin::Init(HWND parent, const gfx::Rect& bounds,
+ bool has_own_focus_manager) {
if (window_style_ == 0)
window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle;
@@ -186,9 +187,8 @@
root_view_->OnWidgetCreated();
- if ((window_style_ & WS_CHILD) == 0) {
- // Top-level widgets get a FocusManager.
- focus_manager_.reset(new FocusManager(this));
+ if (has_own_focus_manager) {
+ FocusManager::CreateFocusManager(hwnd_, GetRootView());
}
// Sets the RootView as a property, so the automation can introspect windows.
@@ -419,18 +419,6 @@
return GetWindowImpl(hwnd_);
}
-FocusManager* WidgetWin::GetFocusManager() {
- if (focus_manager_.get())
- return focus_manager_.get();
-
- HWND root = ::GetAncestor(hwnd_, GA_ROOT);
- if (!root)
- return NULL;
-
- WidgetWin* widget = GetWidget(root);
- return widget ? widget->focus_manager_.get() : NULL;
-}
-
void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
if (use_layered_buffer_ == use_layered_buffer)
return;
@@ -472,12 +460,7 @@
return root_view;
}
-// static
-WidgetWin* WidgetWin::GetWidget(HWND hwnd) {
- return reinterpret_cast<WidgetWin*>(win_util::GetWindowUserData(hwnd));
-}
-
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// MessageLoop::Observer
void WidgetWin::WillProcessMessage(const MSG& msg) {
@@ -489,7 +472,7 @@
}
}
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// FocusTraversable
View* WidgetWin::FindNextFocusableView(
@@ -1056,8 +1039,10 @@
// Otherwise we handle everything else.
if (!widget->ProcessWindowMessage(window, message, w_param, l_param, result))
result = DefWindowProc(window, message, w_param, l_param);
- if (message == WM_NCDESTROY)
+ if (message == WM_NCDESTROY) {
+ widget->hwnd_ = NULL;
widget->OnFinalMessage(window);
+ }
if (message == WM_ACTIVATE)
PostProcessActivateMessage(widget, LOWORD(w_param));
return result;
@@ -1066,16 +1051,18 @@
// static
void WidgetWin::PostProcessActivateMessage(WidgetWin* widget,
int activation_state) {
- if (!widget->focus_manager_.get()) {
+ FocusManager* focus_manager =
+ FocusManager::GetFocusManager(widget->GetNativeView());
+ if (!focus_manager) {
NOTREACHED();
return;
}
if (WA_INACTIVE == activation_state) {
- widget->focus_manager_->StoreFocusedView();
+ focus_manager->StoreFocusedView();
} else {
// We must restore the focus after the message has been DefProc'ed as it
// does set the focus to the last focused HWND.
- widget->focus_manager_->RestoreFocusedView();
+ focus_manager->RestoreFocusedView();
}
}
} // namespace views
« no previous file with comments | « views/widget/widget_win.h ('k') | views/window/window_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698