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

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

Issue 1887263002: Revert of mash: Close system tray bubble on click outside its bounds, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « ui/views/widget/root_view.h ('k') | ui/views/widget/widget.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // RootView, public: 150 // RootView, public:
151 151
152 // Creation and lifetime ------------------------------------------------------- 152 // Creation and lifetime -------------------------------------------------------
153 153
154 RootView::RootView(Widget* widget) 154 RootView::RootView(Widget* widget)
155 : widget_(widget), 155 : widget_(widget),
156 mouse_pressed_handler_(NULL), 156 mouse_pressed_handler_(NULL),
157 mouse_move_handler_(NULL), 157 mouse_move_handler_(NULL),
158 last_click_handler_(NULL), 158 last_click_handler_(NULL),
159 explicit_mouse_handler_(false), 159 explicit_mouse_handler_(false),
160 clear_mouse_handler_on_release_(true),
161 last_mouse_event_flags_(0), 160 last_mouse_event_flags_(0),
162 last_mouse_event_x_(-1), 161 last_mouse_event_x_(-1),
163 last_mouse_event_y_(-1), 162 last_mouse_event_y_(-1),
164 gesture_handler_(NULL), 163 gesture_handler_(NULL),
165 gesture_handler_set_before_processing_(false), 164 gesture_handler_set_before_processing_(false),
166 pre_dispatch_handler_(new internal::PreEventDispatchHandler(this)), 165 pre_dispatch_handler_(new internal::PreEventDispatchHandler(this)),
167 post_dispatch_handler_(new internal::PostEventDispatchHandler), 166 post_dispatch_handler_(new internal::PostEventDispatchHandler),
168 focus_search_(this, false, false), 167 focus_search_(this, false, false),
169 focus_traversable_parent_(NULL), 168 focus_traversable_parent_(NULL),
170 focus_traversable_parent_view_(NULL), 169 focus_traversable_parent_view_(NULL),
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 434
436 void RootView::OnMouseReleased(const ui::MouseEvent& event) { 435 void RootView::OnMouseReleased(const ui::MouseEvent& event) {
437 UpdateCursor(event); 436 UpdateCursor(event);
438 437
439 if (mouse_pressed_handler_) { 438 if (mouse_pressed_handler_) {
440 ui::MouseEvent mouse_released(event, static_cast<View*>(this), 439 ui::MouseEvent mouse_released(event, static_cast<View*>(this),
441 mouse_pressed_handler_); 440 mouse_pressed_handler_);
442 // We allow the view to delete us from the event dispatch callback. As such, 441 // We allow the view to delete us from the event dispatch callback. As such,
443 // configure state such that we're done first, then call View. 442 // configure state such that we're done first, then call View.
444 View* mouse_pressed_handler = mouse_pressed_handler_; 443 View* mouse_pressed_handler = mouse_pressed_handler_;
445 if (clear_mouse_handler_on_release_) 444 SetMouseHandler(NULL);
446 SetMouseHandler(nullptr);
447 ui::EventDispatchDetails dispatch_details = 445 ui::EventDispatchDetails dispatch_details =
448 DispatchEvent(mouse_pressed_handler, &mouse_released); 446 DispatchEvent(mouse_pressed_handler, &mouse_released);
449 if (dispatch_details.dispatcher_destroyed) 447 if (dispatch_details.dispatcher_destroyed)
450 return; 448 return;
451 } 449 }
452 } 450 }
453 451
454 void RootView::OnMouseCaptureLost() { 452 void RootView::OnMouseCaptureLost() {
455 // TODO: this likely needs to reset touch handler too. 453 // TODO: this likely needs to reset touch handler too.
456 454
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event)); 585 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event));
588 if (dispatch_details.dispatcher_destroyed || 586 if (dispatch_details.dispatcher_destroyed ||
589 dispatch_details.target_destroyed) { 587 dispatch_details.target_destroyed) {
590 return event.handled(); 588 return event.handled();
591 } 589 }
592 } 590 }
593 return event.handled(); 591 return event.handled();
594 } 592 }
595 593
596 void RootView::SetMouseHandler(View* new_mh) { 594 void RootView::SetMouseHandler(View* new_mh) {
597 SetMouseHandler(new_mh, true /* clear_on_release */); 595 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
596 explicit_mouse_handler_ = (new_mh != NULL);
597 mouse_pressed_handler_ = new_mh;
598 gesture_handler_ = new_mh;
599 drag_info_.Reset();
598 } 600 }
599 601
600 void RootView::GetAccessibleState(ui::AXViewState* state) { 602 void RootView::GetAccessibleState(ui::AXViewState* state) {
601 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle(); 603 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle();
602 state->role = widget_->widget_delegate()->GetAccessibleWindowRole(); 604 state->role = widget_->widget_delegate()->GetAccessibleWindowRole();
603 } 605 }
604 606
605 void RootView::UpdateParentLayer() { 607 void RootView::UpdateParentLayer() {
606 if (layer()) 608 if (layer())
607 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer()); 609 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer());
(...skipping 19 matching lines...) Expand all
627 old_dispatch_target_ = NULL; 629 old_dispatch_target_ = NULL;
628 } 630 }
629 } 631 }
630 632
631 void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) { 633 void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) {
632 if (!is_visible) { 634 if (!is_visible) {
633 // When the root view is being hidden (e.g. when widget is minimized) 635 // When the root view is being hidden (e.g. when widget is minimized)
634 // handlers are reset, so that after it is reshown, events are not captured 636 // handlers are reset, so that after it is reshown, events are not captured
635 // by old handlers. 637 // by old handlers.
636 explicit_mouse_handler_ = false; 638 explicit_mouse_handler_ = false;
637 clear_mouse_handler_on_release_ = true;
638 mouse_pressed_handler_ = NULL; 639 mouse_pressed_handler_ = NULL;
639 mouse_move_handler_ = NULL; 640 mouse_move_handler_ = NULL;
640 gesture_handler_ = NULL; 641 gesture_handler_ = NULL;
641 event_dispatch_target_ = NULL; 642 event_dispatch_target_ = NULL;
642 old_dispatch_target_ = NULL; 643 old_dispatch_target_ = NULL;
643 } 644 }
644 } 645 }
645 646
646 void RootView::OnPaint(gfx::Canvas* canvas) { 647 void RootView::OnPaint(gfx::Canvas* canvas) {
647 if (!layer() || !layer()->fills_bounds_opaquely()) 648 if (!layer() || !layer()->fills_bounds_opaquely())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 MouseEnterExitEvent notify_event(event, type); 698 MouseEnterExitEvent notify_event(event, type);
698 ui::EventDispatchDetails dispatch_details = DispatchEvent(p, &notify_event); 699 ui::EventDispatchDetails dispatch_details = DispatchEvent(p, &notify_event);
699 if (dispatch_details.dispatcher_destroyed || 700 if (dispatch_details.dispatcher_destroyed ||
700 dispatch_details.target_destroyed) { 701 dispatch_details.target_destroyed) {
701 return dispatch_details; 702 return dispatch_details;
702 } 703 }
703 } 704 }
704 return ui::EventDispatchDetails(); 705 return ui::EventDispatchDetails();
705 } 706 }
706 707
707 void RootView::SetMouseHandler(View* new_mh, bool clear_on_release) {
708 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
709 explicit_mouse_handler_ = (new_mh != nullptr);
710 clear_mouse_handler_on_release_ = clear_on_release;
711 mouse_pressed_handler_ = new_mh;
712 gesture_handler_ = new_mh;
713 drag_info_.Reset();
714 }
715
716 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { 708 bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
717 return event_dispatch_target_ == target; 709 return event_dispatch_target_ == target;
718 } 710 }
719 711
720 ui::EventDispatchDetails RootView::PreDispatchEvent(ui::EventTarget* target, 712 ui::EventDispatchDetails RootView::PreDispatchEvent(ui::EventTarget* target,
721 ui::Event* event) { 713 ui::Event* event) {
722 View* view = static_cast<View*>(target); 714 View* view = static_cast<View*>(target);
723 if (event->IsGestureEvent()) { 715 if (event->IsGestureEvent()) {
724 // Update |gesture_handler_| to indicate which View is currently handling 716 // Update |gesture_handler_| to indicate which View is currently handling
725 // gesture events. 717 // gesture events.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 756
765 #ifndef NDEBUG 757 #ifndef NDEBUG
766 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 758 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
767 #endif 759 #endif
768 760
769 return details; 761 return details;
770 } 762 }
771 763
772 } // namespace internal 764 } // namespace internal
773 } // namespace views 765 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/root_view.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698