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

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

Issue 1887273002: Revert of mash: Close system tray bubble on click outside its bounds, part 1 (patchset #4 id:60001 … (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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 435
437 void RootView::OnMouseReleased(const ui::MouseEvent& event) { 436 void RootView::OnMouseReleased(const ui::MouseEvent& event) {
438 UpdateCursor(event); 437 UpdateCursor(event);
439 438
440 if (mouse_pressed_handler_) { 439 if (mouse_pressed_handler_) {
441 ui::MouseEvent mouse_released(event, static_cast<View*>(this), 440 ui::MouseEvent mouse_released(event, static_cast<View*>(this),
442 mouse_pressed_handler_); 441 mouse_pressed_handler_);
443 // We allow the view to delete us from the event dispatch callback. As such, 442 // We allow the view to delete us from the event dispatch callback. As such,
444 // configure state such that we're done first, then call View. 443 // configure state such that we're done first, then call View.
445 View* mouse_pressed_handler = mouse_pressed_handler_; 444 View* mouse_pressed_handler = mouse_pressed_handler_;
446 if (clear_mouse_handler_on_release_) 445 SetMouseHandler(NULL);
447 SetMouseHandler(nullptr);
448 ui::EventDispatchDetails dispatch_details = 446 ui::EventDispatchDetails dispatch_details =
449 DispatchEvent(mouse_pressed_handler, &mouse_released); 447 DispatchEvent(mouse_pressed_handler, &mouse_released);
450 if (dispatch_details.dispatcher_destroyed) 448 if (dispatch_details.dispatcher_destroyed)
451 return; 449 return;
452 } 450 }
453 } 451 }
454 452
455 void RootView::OnMouseCaptureLost() { 453 void RootView::OnMouseCaptureLost() {
456 // TODO: this likely needs to reset touch handler too. 454 // TODO: this likely needs to reset touch handler too.
457 455
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event)); 586 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event));
589 if (dispatch_details.dispatcher_destroyed || 587 if (dispatch_details.dispatcher_destroyed ||
590 dispatch_details.target_destroyed) { 588 dispatch_details.target_destroyed) {
591 return event.handled(); 589 return event.handled();
592 } 590 }
593 } 591 }
594 return event.handled(); 592 return event.handled();
595 } 593 }
596 594
597 void RootView::SetMouseHandler(View* new_mh) { 595 void RootView::SetMouseHandler(View* new_mh) {
598 SetMouseHandler(new_mh, true /* clear_on_release */); 596 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
597 explicit_mouse_handler_ = (new_mh != NULL);
598 mouse_pressed_handler_ = new_mh;
599 gesture_handler_ = new_mh;
600 drag_info_.Reset();
599 } 601 }
600 602
601 void RootView::GetAccessibleState(ui::AXViewState* state) { 603 void RootView::GetAccessibleState(ui::AXViewState* state) {
602 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle(); 604 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle();
603 state->role = widget_->widget_delegate()->GetAccessibleWindowRole(); 605 state->role = widget_->widget_delegate()->GetAccessibleWindowRole();
604 } 606 }
605 607
606 void RootView::UpdateParentLayer() { 608 void RootView::UpdateParentLayer() {
607 if (layer()) 609 if (layer())
608 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer()); 610 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer());
(...skipping 19 matching lines...) Expand all
628 old_dispatch_target_ = NULL; 630 old_dispatch_target_ = NULL;
629 } 631 }
630 } 632 }
631 633
632 void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) { 634 void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) {
633 if (!is_visible) { 635 if (!is_visible) {
634 // When the root view is being hidden (e.g. when widget is minimized) 636 // When the root view is being hidden (e.g. when widget is minimized)
635 // handlers are reset, so that after it is reshown, events are not captured 637 // handlers are reset, so that after it is reshown, events are not captured
636 // by old handlers. 638 // by old handlers.
637 explicit_mouse_handler_ = false; 639 explicit_mouse_handler_ = false;
638 clear_mouse_handler_on_release_ = true;
639 mouse_pressed_handler_ = NULL; 640 mouse_pressed_handler_ = NULL;
640 mouse_move_handler_ = NULL; 641 mouse_move_handler_ = NULL;
641 gesture_handler_ = NULL; 642 gesture_handler_ = NULL;
642 event_dispatch_target_ = NULL; 643 event_dispatch_target_ = NULL;
643 old_dispatch_target_ = NULL; 644 old_dispatch_target_ = NULL;
644 } 645 }
645 } 646 }
646 647
647 void RootView::OnPaint(gfx::Canvas* canvas) { 648 void RootView::OnPaint(gfx::Canvas* canvas) {
648 if (!layer() || !layer()->fills_bounds_opaquely()) 649 if (!layer() || !layer()->fills_bounds_opaquely())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 MouseEnterExitEvent notify_event(event, type); 699 MouseEnterExitEvent notify_event(event, type);
699 ui::EventDispatchDetails dispatch_details = DispatchEvent(p, &notify_event); 700 ui::EventDispatchDetails dispatch_details = DispatchEvent(p, &notify_event);
700 if (dispatch_details.dispatcher_destroyed || 701 if (dispatch_details.dispatcher_destroyed ||
701 dispatch_details.target_destroyed) { 702 dispatch_details.target_destroyed) {
702 return dispatch_details; 703 return dispatch_details;
703 } 704 }
704 } 705 }
705 return ui::EventDispatchDetails(); 706 return ui::EventDispatchDetails();
706 } 707 }
707 708
708 void RootView::SetMouseHandler(View* new_mh, bool clear_on_release) {
709 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
710 explicit_mouse_handler_ = (new_mh != nullptr);
711 clear_mouse_handler_on_release_ = clear_on_release;
712 mouse_pressed_handler_ = new_mh;
713 gesture_handler_ = new_mh;
714 drag_info_.Reset();
715 }
716
717 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { 709 bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
718 return event_dispatch_target_ == target; 710 return event_dispatch_target_ == target;
719 } 711 }
720 712
721 ui::EventDispatchDetails RootView::PreDispatchEvent(ui::EventTarget* target, 713 ui::EventDispatchDetails RootView::PreDispatchEvent(ui::EventTarget* target,
722 ui::Event* event) { 714 ui::Event* event) {
723 View* view = static_cast<View*>(target); 715 View* view = static_cast<View*>(target);
724 if (event->IsGestureEvent()) { 716 if (event->IsGestureEvent()) {
725 // Update |gesture_handler_| to indicate which View is currently handling 717 // Update |gesture_handler_| to indicate which View is currently handling
726 // gesture events. 718 // gesture events.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 757
766 #ifndef NDEBUG 758 #ifndef NDEBUG
767 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 759 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
768 #endif 760 #endif
769 761
770 return details; 762 return details;
771 } 763 }
772 764
773 } // namespace internal 765 } // namespace internal
774 } // namespace views 766 } // 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