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

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

Issue 2863003: Attempt 2 at: (Closed)
Patch Set: Created 10 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
« no previous file with comments | « views/widget/root_view.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')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/keyboard_codes.h" 10 #include "base/keyboard_codes.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 mouse_move_handler_->OnMouseMoved(moved_event); 482 mouse_move_handler_->OnMouseMoved(moved_event);
483 483
484 gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint( 484 gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint(
485 moved_event.GetType(), moved_event.location()); 485 moved_event.GetType(), moved_event.location());
486 SetActiveCursor(cursor); 486 SetActiveCursor(cursor);
487 } else if (mouse_move_handler_ != NULL) { 487 } else if (mouse_move_handler_ != NULL) {
488 MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0); 488 MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
489 mouse_move_handler_->OnMouseExited(exited_event); 489 mouse_move_handler_->OnMouseExited(exited_event);
490 SetActiveCursor(NULL); 490 SetActiveCursor(NULL);
491 } 491 }
492
493 if (registered_near_views_.empty())
494 return;
495
496 std::set<View*> near_views;
497 GetViewsRegisteredForNearNotification(e, &near_views);
498
499 MouseEvent exited_near_event(Event::ET_MOUSE_EXITED_NEAR, 0, 0, 0);
500 for (std::set<View*>::const_iterator i = near_views_.begin();
501 i != near_views_.end(); ++i) {
502 if (near_views.find(*i) == near_views.end())
503 (*i)->OnMouseExitedNear(exited_near_event);
504 }
505
506 for (std::set<View*>::const_iterator i = near_views.begin();
507 i != near_views.end(); ++i) {
508 if (near_views_.find(*i) == near_views_.end()) {
509 MouseEvent entered_event(Event::ET_MOUSE_ENTERED,
510 this,
511 *i,
512 e.location(),
513 0);
514 (*i)->OnMouseNear(entered_event);
515 }
516 }
517
518 near_views_.swap(near_views);
492 } 519 }
493 520
494 void RootView::ProcessOnMouseExited() { 521 void RootView::ProcessOnMouseExited() {
495 if (mouse_move_handler_ != NULL) { 522 if (mouse_move_handler_ != NULL) {
496 MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0); 523 MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
497 mouse_move_handler_->OnMouseExited(exited_event); 524 mouse_move_handler_->OnMouseExited(exited_event);
498 mouse_move_handler_ = NULL; 525 mouse_move_handler_ = NULL;
499 } 526 }
527
528 SendMouseExitedNear();
500 } 529 }
501 530
502 void RootView::SetMouseHandler(View *new_mh) { 531 void RootView::SetMouseHandler(View *new_mh) {
503 // If we're clearing the mouse handler, clear explicit_mouse_handler as well. 532 // If we're clearing the mouse handler, clear explicit_mouse_handler as well.
504 explicit_mouse_handler_ = (new_mh != NULL); 533 explicit_mouse_handler_ = (new_mh != NULL);
505 mouse_pressed_handler_ = new_mh; 534 mouse_pressed_handler_ = new_mh;
506 } 535 }
507 536
508 void RootView::ProcessMouseDragCanceled() { 537 void RootView::ProcessMouseDragCanceled() {
509 if (mouse_pressed_handler_) { 538 if (mouse_pressed_handler_) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 if (!view->registered_for_visible_bounds_notification_) 902 if (!view->registered_for_visible_bounds_notification_)
874 return; 903 return;
875 view->registered_for_visible_bounds_notification_ = false; 904 view->registered_for_visible_bounds_notification_ = false;
876 View* ancestor = view->GetParent(); 905 View* ancestor = view->GetParent();
877 while (ancestor) { 906 while (ancestor) {
878 ancestor->RemoveDescendantToNotify(view); 907 ancestor->RemoveDescendantToNotify(view);
879 ancestor = ancestor->GetParent(); 908 ancestor = ancestor->GetParent();
880 } 909 }
881 } 910 }
882 911
912 void RootView::RegisterViewForNearNotification(View* view) {
913 registered_near_views_.insert(view);
914 }
915
916 void RootView::UnregisterViewForNearNotification(View* view) {
917 registered_near_views_.erase(view);
918 near_views_.erase(view);
919 }
920
883 void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { 921 void RootView::SetMouseLocationAndFlags(const MouseEvent& e) {
884 last_mouse_event_flags_ = e.GetFlags(); 922 last_mouse_event_flags_ = e.GetFlags();
885 last_mouse_event_x_ = e.x(); 923 last_mouse_event_x_ = e.x();
886 last_mouse_event_y_ = e.y(); 924 last_mouse_event_y_ = e.y();
887 } 925 }
888 926
889 std::string RootView::GetClassName() const { 927 std::string RootView::GetClassName() const {
890 return kViewClassName; 928 return kViewClassName;
891 } 929 }
892 930
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 gfx::NativeView native_view = 967 gfx::NativeView native_view =
930 static_cast<WidgetGtk*>(GetWidget())->window_contents(); 968 static_cast<WidgetGtk*>(GetWidget())->window_contents();
931 if (!native_view) 969 if (!native_view)
932 return; 970 return;
933 gdk_window_set_cursor(native_view->window, cursor); 971 gdk_window_set_cursor(native_view->window, cursor);
934 if (cursor) 972 if (cursor)
935 gdk_cursor_destroy(cursor); 973 gdk_cursor_destroy(cursor);
936 #endif 974 #endif
937 } 975 }
938 976
977 void RootView::GetViewsRegisteredForNearNotification(
978 const MouseEvent& e,
979 std::set<View*>* near_views) {
980 const gfx::Point& location = e.location();
981 for (std::set<View*>::const_iterator i = registered_near_views_.begin();
982 i != registered_near_views_.end(); ++i) {
983 View* view = *i;
984 DCHECK(view->near_insets_.get());
985 const gfx::Insets& insets = *view->near_insets_;
986 gfx::Point view_loc(view->x() - insets.left(),
987 view->y() - insets.top());
988 View::ConvertPointToView(view->GetParent(), this, &view_loc);
989 if (location.x() >= view_loc.x() &&
990 location.y() >= view_loc.y() &&
991 location.x() < view_loc.x() + (view->width() + insets.width()) &&
992 location.y() < view_loc.y() + (view->height() + insets.height())) {
993 near_views->insert(view);
994 }
995 }
996 }
997
998 void RootView::SendMouseExitedNear() {
999 if (near_views_.empty())
1000 return;
1001
1002 MouseEvent exited_near_event(Event::ET_MOUSE_EXITED_NEAR, 0, 0, 0);
1003 for (std::set<View*>::const_iterator i = near_views_.begin();
1004 i != near_views_.end(); ++i) {
1005 (*i)->OnMouseExitedNear(exited_near_event);
1006 }
1007
1008 near_views_.clear();
1009 }
1010
939 } // namespace views 1011 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/root_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698