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

Side by Side Diff: views/widget/root_view.cc

Issue 141013: Relanding focus manager refactoring (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/widget/accelerator_handler.cc ('k') | views/widget/widget.h » ('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/widget/root_view.h" 5 #include "views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/drag_drop_types.h" 9 #include "app/drag_drop_types.h"
10 #include "app/gfx/canvas.h" 10 #include "app/gfx/canvas.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 void Run() { 41 void Run() {
42 if (root_view_) 42 if (root_view_)
43 root_view_->PaintNow(); 43 root_view_->PaintNow();
44 } 44 }
45 private: 45 private:
46 // The target root view. 46 // The target root view.
47 RootView* root_view_; 47 RootView* root_view_;
48 48
49 DISALLOW_EVIL_CONSTRUCTORS(PaintTask); 49 DISALLOW_COPY_AND_ASSIGN(PaintTask);
50 }; 50 };
51 51
52 const char RootView::kViewClassName[] = "views/RootView"; 52 const char RootView::kViewClassName[] = "views/RootView";
53 53
54 ///////////////////////////////////////////////////////////////////////////// 54 /////////////////////////////////////////////////////////////////////////////
55 // 55 //
56 // RootView - constructors, destructors, initialization 56 // RootView - constructors, destructors, initialization
57 // 57 //
58 ///////////////////////////////////////////////////////////////////////////// 58 /////////////////////////////////////////////////////////////////////////////
59 59
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 FocusView(NULL); 255 FocusView(NULL);
256 } 256 }
257 257
258 if (child == drag_view_) 258 if (child == drag_view_)
259 drag_view_ = NULL; 259 drag_view_ = NULL;
260 260
261 if (default_keyboard_handler_ == child) { 261 if (default_keyboard_handler_ == child) {
262 default_keyboard_handler_ = NULL; 262 default_keyboard_handler_ = NULL;
263 } 263 }
264 264
265 // For a given widget hierarchy, focus is tracked by a FocusManager attached 265 FocusManager* focus_manager = widget_->GetFocusManager();
266 // to our nearest enclosing Window. <-- Important Assumption! 266 // An unparanted RootView does not have a FocusManager.
267 // We may not have access to our window if this function is called as a 267 if (focus_manager)
268 // result of teardown during the deletion of the RootView and its hierarchy,
269 // so we don't bother notifying the FocusManager in that case because it
270 // will have already been destroyed (the Widget that contains us is
271 // NCDESTROY'ed which in turn destroys the focus manager _before_ the
272 // RootView is deleted.)
273 #if defined(OS_WIN)
274 Window* window = GetWindow();
275 if (window) {
276 FocusManager* focus_manager =
277 FocusManager::GetFocusManager(window->GetNativeWindow());
278 focus_manager->ViewRemoved(parent, child); 268 focus_manager->ViewRemoved(parent, child);
279 }
280 ViewStorage::GetSharedInstance()->ViewRemoved(parent, child); 269 ViewStorage::GetSharedInstance()->ViewRemoved(parent, child);
281 #endif
282 } 270 }
283 } 271 }
284 272
285 void RootView::SetFocusOnMousePressed(bool f) { 273 void RootView::SetFocusOnMousePressed(bool f) {
286 focus_on_mouse_pressed_ = f; 274 focus_on_mouse_pressed_ = f;
287 } 275 }
288 276
289 bool RootView::OnMousePressed(const MouseEvent& e) { 277 bool RootView::OnMousePressed(const MouseEvent& e) {
290 // This function does not normally handle non-client messages except for 278 // This function does not normally handle non-client messages except for
291 // non-client double-clicks. Actually, all double-clicks are special as the 279 // non-client double-clicks. Actually, all double-clicks are special as the
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 void RootView::OnWidgetDestroyed() { 502 void RootView::OnWidgetDestroyed() {
515 #if defined(OS_WIN) 503 #if defined(OS_WIN)
516 if (drop_target_.get()) { 504 if (drop_target_.get()) {
517 RevokeDragDrop(GetWidget()->GetNativeView()); 505 RevokeDragDrop(GetWidget()->GetNativeView());
518 drop_target_ = NULL; 506 drop_target_ = NULL;
519 } 507 }
520 #else 508 #else
521 // TODO(port): Port RootViewDropTarget and this goes away. 509 // TODO(port): Port RootViewDropTarget and this goes away.
522 NOTIMPLEMENTED(); 510 NOTIMPLEMENTED();
523 #endif 511 #endif
524 widget_ = NULL;
525 } 512 }
526 513
527 void RootView::ProcessMouseDragCanceled() { 514 void RootView::ProcessMouseDragCanceled() {
528 if (mouse_pressed_handler_) { 515 if (mouse_pressed_handler_) {
529 // Synthesize a release event. 516 // Synthesize a release event.
530 MouseEvent release_event(Event::ET_MOUSE_RELEASED, last_mouse_event_x_, 517 MouseEvent release_event(Event::ET_MOUSE_RELEASED, last_mouse_event_x_,
531 last_mouse_event_y_, last_mouse_event_flags_); 518 last_mouse_event_y_, last_mouse_event_flags_);
532 OnMouseReleased(release_event, true); 519 OnMouseReleased(release_event, true);
533 } 520 }
534 } 521 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 previous_cursor_ = NULL; 939 previous_cursor_ = NULL;
953 } 940 }
954 #elif defined(OS_LINUX) 941 #elif defined(OS_LINUX)
955 gdk_window_set_cursor(GetWidget()->GetNativeView()->window, cursor); 942 gdk_window_set_cursor(GetWidget()->GetNativeView()->window, cursor);
956 if (cursor) 943 if (cursor)
957 gdk_cursor_destroy(cursor); 944 gdk_cursor_destroy(cursor);
958 #endif 945 #endif
959 } 946 }
960 947
961 } // namespace views 948 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/accelerator_handler.cc ('k') | views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698