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

Side by Side Diff: views/focus/focus_manager.cc

Issue 122002: Moving the WM_SETFOCUS message processing out of FocusManager (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/focus/focus_manager.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/focus/focus_manager.h" 5 #include "views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 WNDPROC original_handler = win_util::GetSuperclassWNDPROC(window); 66 WNDPROC original_handler = win_util::GetSuperclassWNDPROC(window);
67 DCHECK(original_handler); 67 DCHECK(original_handler);
68 FocusManager* focus_manager = FocusManager::GetFocusManager(window); 68 FocusManager* focus_manager = FocusManager::GetFocusManager(window);
69 // There are cases when we have no FocusManager for the window. This happens 69 // There are cases when we have no FocusManager for the window. This happens
70 // because we subclass certain windows (such as the TabContents window) 70 // because we subclass certain windows (such as the TabContents window)
71 // but that window may not have an associated FocusManager. 71 // but that window may not have an associated FocusManager.
72 if (focus_manager) { 72 if (focus_manager) {
73 switch (message) { 73 switch (message) {
74 case WM_SETFOCUS:
75 if (!focus_manager->OnSetFocus(window))
76 return 0;
77 break;
78 case WM_NCDESTROY: 74 case WM_NCDESTROY:
79 if (!focus_manager->OnNCDestroy(window)) 75 if (!focus_manager->OnNCDestroy(window))
80 return 0; 76 return 0;
81 break; 77 break;
82 default: 78 default:
83 break; 79 break;
84 } 80 }
85 } 81 }
86 return CallWindowProc(original_handler, window, message, wParam, lParam); 82 return CallWindowProc(original_handler, window, message, wParam, lParam);
87 } 83 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 #endif 178 #endif
183 179
184 FocusManager::~FocusManager() { 180 FocusManager::~FocusManager() {
185 // If there are still registered FocusChange listeners, chances are they were 181 // If there are still registered FocusChange listeners, chances are they were
186 // leaked so warn about them. 182 // leaked so warn about them.
187 DCHECK(focus_change_listeners_.empty()); 183 DCHECK(focus_change_listeners_.empty());
188 } 184 }
189 185
190 #if defined(OS_WIN) 186 #if defined(OS_WIN)
191 // Message handlers. 187 // Message handlers.
192 bool FocusManager::OnSetFocus(HWND window) {
193 if (ignore_set_focus_msg_)
194 return true;
195
196 // Focus the view associated with that window.
197 View* v = static_cast<View*>(GetProp(window, kViewKey));
198 if (v && v->IsFocusable()) {
199 v->GetRootView()->FocusView(v);
200 } else {
201 SetFocusedView(NULL);
202 }
203
204 return true;
205 }
206
207 bool FocusManager::OnNCDestroy(HWND window) { 188 bool FocusManager::OnNCDestroy(HWND window) {
208 // Window is being destroyed, undo the subclassing. 189 // Window is being destroyed, undo the subclassing.
209 FocusManager::UninstallFocusSubclass(window); 190 FocusManager::UninstallFocusSubclass(window);
210 191
211 if (window == root_) { 192 if (window == root_) {
212 // We are the top window. 193 // We are the top window.
213 194
214 DCHECK(GetProp(window, kFocusManagerKey)); 195 DCHECK(GetProp(window, kFocusManagerKey));
215 196
216 // Make sure this is called on the window that was set with the 197 // Make sure this is called on the window that was set with the
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), 703 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(),
723 listener); 704 listener);
724 if (place == focus_change_listeners_.end()) { 705 if (place == focus_change_listeners_.end()) {
725 NOTREACHED() << "Removing a listener that isn't registered."; 706 NOTREACHED() << "Removing a listener that isn't registered.";
726 return; 707 return;
727 } 708 }
728 focus_change_listeners_.erase(place); 709 focus_change_listeners_.erase(place);
729 } 710 }
730 711
731 } // namespace views 712 } // namespace views
OLDNEW
« no previous file with comments | « views/focus/focus_manager.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698