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

Unified Diff: ui/views/widget/root_view.cc

Issue 1876553002: 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: tweak comments 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/root_view.cc
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index ff1294ae9f776ca0cd17acde66aea875292c6265..6081a1a89261cd6d3e1b591348196f3c00f179d2 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -157,6 +157,7 @@ RootView::RootView(Widget* widget)
mouse_move_handler_(NULL),
last_click_handler_(NULL),
explicit_mouse_handler_(false),
+ clear_mouse_handler_on_release_(true),
last_mouse_event_flags_(0),
last_mouse_event_x_(-1),
last_mouse_event_y_(-1),
@@ -441,7 +442,9 @@ void RootView::OnMouseReleased(const ui::MouseEvent& event) {
// We allow the view to delete us from the event dispatch callback. As such,
// configure state such that we're done first, then call View.
View* mouse_pressed_handler = mouse_pressed_handler_;
- SetMouseHandler(NULL);
+ if (clear_mouse_handler_on_release_) {
sky 2016/04/11 15:25:45 nit: no {}
+ SetMouseHandler(nullptr);
+ }
ui::EventDispatchDetails dispatch_details =
DispatchEvent(mouse_pressed_handler, &mouse_released);
if (dispatch_details.dispatcher_destroyed)
@@ -592,11 +595,7 @@ bool RootView::OnMouseWheel(const ui::MouseWheelEvent& event) {
}
void RootView::SetMouseHandler(View* new_mh) {
- // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
- explicit_mouse_handler_ = (new_mh != NULL);
- mouse_pressed_handler_ = new_mh;
- gesture_handler_ = new_mh;
- drag_info_.Reset();
+ SetMouseHandler(new_mh, true /* clear_on_release */);
}
void RootView::GetAccessibleState(ui::AXViewState* state) {
@@ -636,6 +635,7 @@ void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) {
// handlers are reset, so that after it is reshown, events are not captured
// by old handlers.
explicit_mouse_handler_ = false;
+ clear_mouse_handler_on_release_ = true;
mouse_pressed_handler_ = NULL;
mouse_move_handler_ = NULL;
gesture_handler_ = NULL;
@@ -705,6 +705,15 @@ ui::EventDispatchDetails RootView::NotifyEnterExitOfDescendant(
return ui::EventDispatchDetails();
}
+void RootView::SetMouseHandler(View* new_mh, bool clear_on_release) {
+ // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
+ explicit_mouse_handler_ = (new_mh != nullptr);
+ clear_mouse_handler_on_release_ = clear_on_release;
+ mouse_pressed_handler_ = new_mh;
+ gesture_handler_ = new_mh;
+ drag_info_.Reset();
+}
+
bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
return event_dispatch_target_ == target;
}
« 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