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

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

Issue 2456903003: Send mouse exited event after mouse release outside view.
Patch Set: Created 4 years, 1 month 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 | « no previous file | ui/views/widget/widget_unittest.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 static_cast<View*>(NULL), 45 static_cast<View*>(NULL),
46 static_cast<View*>(NULL)) { 46 static_cast<View*>(NULL)) {
47 DCHECK(type == ui::ET_MOUSE_ENTERED || 47 DCHECK(type == ui::ET_MOUSE_ENTERED ||
48 type == ui::ET_MOUSE_EXITED); 48 type == ui::ET_MOUSE_EXITED);
49 SetType(type); 49 SetType(type);
50 } 50 }
51 51
52 ~MouseEnterExitEvent() override {} 52 ~MouseEnterExitEvent() override {}
53 }; 53 };
54 54
55 class GeneratedMouseMoveEvent : public ui::MouseEvent {
56 public:
57 GeneratedMouseMoveEvent(const ui::MouseEvent& event)
58 : ui::MouseEvent(event) {
59 SetType(ui::ET_MOUSE_MOVED);
60 }
61
62 ~GeneratedMouseMoveEvent() override {}
63 };
64
55 } // namespace 65 } // namespace
56 66
57 // This event handler receives events in the pre-target phase and takes care of 67 // This event handler receives events in the pre-target phase and takes care of
58 // the following: 68 // the following:
59 // - Shows keyboard-triggered context menus. 69 // - Shows keyboard-triggered context menus.
60 class PreEventDispatchHandler : public ui::EventHandler { 70 class PreEventDispatchHandler : public ui::EventHandler {
61 public: 71 public:
62 explicit PreEventDispatchHandler(View* owner) 72 explicit PreEventDispatchHandler(View* owner)
63 : owner_(owner) { 73 : owner_(owner) {
64 } 74 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ui::MouseEvent mouse_released(event, static_cast<View*>(this), 450 ui::MouseEvent mouse_released(event, static_cast<View*>(this),
441 mouse_pressed_handler_); 451 mouse_pressed_handler_);
442 // We allow the view to delete us from the event dispatch callback. As such, 452 // 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. 453 // configure state such that we're done first, then call View.
444 View* mouse_pressed_handler = mouse_pressed_handler_; 454 View* mouse_pressed_handler = mouse_pressed_handler_;
445 SetMouseHandler(NULL); 455 SetMouseHandler(NULL);
446 ui::EventDispatchDetails dispatch_details = 456 ui::EventDispatchDetails dispatch_details =
447 DispatchEvent(mouse_pressed_handler, &mouse_released); 457 DispatchEvent(mouse_pressed_handler, &mouse_released);
448 if (dispatch_details.dispatcher_destroyed) 458 if (dispatch_details.dispatcher_destroyed)
449 return; 459 return;
460 // We should send generated mouse event, to update hovers after releasing of
461 // mouse capturing.
462 OnMouseMoved(GeneratedMouseMoveEvent(event));
sadrul 2016/10/28 16:07:39 Always sending a mouse-move after a mouse-release
snake 2016/10/28 16:21:38 But we should do this, because View under cursor (
450 } 463 }
451 } 464 }
452 465
453 void RootView::OnMouseCaptureLost() { 466 void RootView::OnMouseCaptureLost() {
454 // TODO: this likely needs to reset touch handler too. 467 // TODO: this likely needs to reset touch handler too.
455 468
456 if (mouse_pressed_handler_ || gesture_handler_) { 469 if (mouse_pressed_handler_ || gesture_handler_) {
457 // Synthesize a release event for UpdateCursor. 470 // Synthesize a release event for UpdateCursor.
458 if (mouse_pressed_handler_) { 471 if (mouse_pressed_handler_) {
459 gfx::Point last_point(last_mouse_event_x_, last_mouse_event_y_); 472 gfx::Point last_point(last_mouse_event_x_, last_mouse_event_y_);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 770
758 #ifndef NDEBUG 771 #ifndef NDEBUG
759 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 772 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
760 #endif 773 #endif
761 774
762 return details; 775 return details;
763 } 776 }
764 777
765 } // namespace internal 778 } // namespace internal
766 } // namespace views 779 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698