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

Side by Side Diff: ui/aura/root_window.cc

Issue 143303006: Do not set the last mouse location from synthesized event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/aura/test/event_generator.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/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 const gfx::Display& display = 391 const gfx::Display& display =
392 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); 392 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window());
393 cursor_client->SetDisplay(display); 393 cursor_client->SetDisplay(display);
394 } 394 }
395 synthesize_mouse_move_ = false; 395 synthesize_mouse_move_ = false;
396 } 396 }
397 397
398 ui::EventDispatchDetails RootWindow::DispatchMouseEnterOrExit( 398 ui::EventDispatchDetails RootWindow::DispatchMouseEnterOrExit(
399 const ui::MouseEvent& event, 399 const ui::MouseEvent& event,
400 ui::EventType type) { 400 ui::EventType type) {
401
402 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED &&
403 !(event.flags() & ui::EF_IS_SYNTHESIZED)) {
404 SetLastMouseLocation(window(), event.root_location());
405 }
oshima 2014/02/11 19:43:38 This was necessary because EnterOrExit may cause e
sadrul 2014/02/11 21:26:20 Can you explain this a bit more? The early returns
406
401 if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate()) 407 if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate())
402 return DispatchDetails(); 408 return DispatchDetails();
403 409
404 // |event| may be an event in the process of being dispatched to a target (in 410 // |event| may be an event in the process of being dispatched to a target (in
405 // which case its locations will be in the event's target's coordinate 411 // which case its locations will be in the event's target's coordinate
406 // system), or a synthetic event created in root-window (in which case, the 412 // system), or a synthetic event created in root-window (in which case, the
407 // event's target will be NULL, and the event will be in the root-window's 413 // event's target will be NULL, and the event will be in the root-window's
408 // coordinate system. 414 // coordinate system.
409 aura::Window* target = static_cast<Window*>(event.target()); 415 aura::Window* target = static_cast<Window*>(event.target());
410 if (!target) 416 if (!target)
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() { 792 ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() {
787 DispatchDetails details; 793 DispatchDetails details;
788 if (!synthesize_mouse_move_) 794 if (!synthesize_mouse_move_)
789 return details; 795 return details;
790 synthesize_mouse_move_ = false; 796 synthesize_mouse_move_ = false;
791 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); 797 gfx::Point root_mouse_location = GetLastMouseLocationInRoot();
792 if (!window()->bounds().Contains(root_mouse_location)) 798 if (!window()->bounds().Contains(root_mouse_location))
793 return details; 799 return details;
794 gfx::Point host_mouse_location = root_mouse_location; 800 gfx::Point host_mouse_location = root_mouse_location;
795 host()->ConvertPointToHost(&host_mouse_location); 801 host()->ConvertPointToHost(&host_mouse_location);
796
797 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 802 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
798 host_mouse_location, 803 host_mouse_location,
799 host_mouse_location, 804 host_mouse_location,
800 ui::EF_IS_SYNTHESIZED, 805 ui::EF_IS_SYNTHESIZED,
801 0); 806 0);
802 return OnEventFromSource(&event); 807 return OnEventFromSource(&event);
803 } 808 }
804 809
805 void RootWindow::PreDispatchLocatedEvent(Window* target, 810 void RootWindow::PreDispatchLocatedEvent(Window* target,
806 ui::LocatedEvent* event) { 811 ui::LocatedEvent* event) {
807 int flags = event->flags(); 812 int flags = event->flags();
808 if (IsNonClientLocation(target, event->location())) 813 if (IsNonClientLocation(target, event->location()))
809 flags |= ui::EF_IS_NON_CLIENT; 814 flags |= ui::EF_IS_NON_CLIENT;
810 event->set_flags(flags); 815 event->set_flags(flags);
811 816
812 if (!dispatching_held_event_ && 817 if (!dispatching_held_event_ &&
813 (event->IsMouseEvent() || event->IsScrollEvent())) { 818 (event->IsMouseEvent() || event->IsScrollEvent())) {
814 if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) 819 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) {
sadrul 2014/02/13 04:38:59 Merge the two if's?
oshima 2014/02/13 15:25:32 Done.
815 SetLastMouseLocation(window(), event->root_location()); 820 if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)
816 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) 821 SetLastMouseLocation(window(), event->root_location());
817 synthesize_mouse_move_ = false; 822 synthesize_mouse_move_ = false;
823 }
818 } 824 }
819 } 825 }
820 826
821 void RootWindow::PreDispatchMouseEvent(Window* target, 827 void RootWindow::PreDispatchMouseEvent(Window* target,
822 ui::MouseEvent* event) { 828 ui::MouseEvent* event) {
823 client::CursorClient* cursor_client = client::GetCursorClient(window()); 829 client::CursorClient* cursor_client = client::GetCursorClient(window());
824 if (cursor_client && 830 if (cursor_client &&
825 !cursor_client->IsMouseEventsEnabled() && 831 !cursor_client->IsMouseEventsEnabled() &&
826 (event->flags() & ui::EF_IS_SYNTHESIZED)) { 832 (event->flags() & ui::EF_IS_SYNTHESIZED)) {
827 event->SetHandled(); 833 event->SetHandled();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 break; 947 break;
942 948
943 default: 949 default:
944 NOTREACHED(); 950 NOTREACHED();
945 break; 951 break;
946 } 952 }
947 PreDispatchLocatedEvent(target, event); 953 PreDispatchLocatedEvent(target, event);
948 } 954 }
949 955
950 } // namespace aura 956 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698