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

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/root_window_unittest.cc » ('j') | ui/aura/root_window_unittest.cc » ('J')
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 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED &&
402 !(event.flags() & ui::EF_IS_SYNTHESIZED)) {
403 SetLastMouseLocation(window(), event.root_location());
404 }
405
401 if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate()) 406 if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate())
402 return DispatchDetails(); 407 return DispatchDetails();
403 408
404 // |event| may be an event in the process of being dispatched to a target (in 409 // |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 410 // 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 411 // 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 412 // event's target will be NULL, and the event will be in the root-window's
408 // coordinate system. 413 // coordinate system.
409 aura::Window* target = static_cast<Window*>(event.target()); 414 aura::Window* target = static_cast<Window*>(event.target());
410 if (!target) 415 if (!target)
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() { 791 ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() {
787 DispatchDetails details; 792 DispatchDetails details;
788 if (!synthesize_mouse_move_) 793 if (!synthesize_mouse_move_)
789 return details; 794 return details;
790 synthesize_mouse_move_ = false; 795 synthesize_mouse_move_ = false;
791 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); 796 gfx::Point root_mouse_location = GetLastMouseLocationInRoot();
792 if (!window()->bounds().Contains(root_mouse_location)) 797 if (!window()->bounds().Contains(root_mouse_location))
793 return details; 798 return details;
794 gfx::Point host_mouse_location = root_mouse_location; 799 gfx::Point host_mouse_location = root_mouse_location;
795 host()->ConvertPointToHost(&host_mouse_location); 800 host()->ConvertPointToHost(&host_mouse_location);
796
797 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 801 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
798 host_mouse_location, 802 host_mouse_location,
799 host_mouse_location, 803 host_mouse_location,
800 ui::EF_IS_SYNTHESIZED, 804 ui::EF_IS_SYNTHESIZED,
801 0); 805 0);
802 return OnEventFromSource(&event); 806 return OnEventFromSource(&event);
803 } 807 }
804 808
805 void RootWindow::PreDispatchLocatedEvent(Window* target, 809 void RootWindow::PreDispatchLocatedEvent(Window* target,
806 ui::LocatedEvent* event) { 810 ui::LocatedEvent* event) {
807 int flags = event->flags(); 811 int flags = event->flags();
808 if (IsNonClientLocation(target, event->location())) 812 if (IsNonClientLocation(target, event->location()))
809 flags |= ui::EF_IS_NON_CLIENT; 813 flags |= ui::EF_IS_NON_CLIENT;
810 event->set_flags(flags); 814 event->set_flags(flags);
811 815
812 if (!dispatching_held_event_ && 816 if (!dispatching_held_event_ &&
813 (event->IsMouseEvent() || event->IsScrollEvent())) { 817 (event->IsMouseEvent() || event->IsScrollEvent()) &&
818 !(event->flags() & ui::EF_IS_SYNTHESIZED)) {
814 if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) 819 if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)
815 SetLastMouseLocation(window(), event->root_location()); 820 SetLastMouseLocation(window(), event->root_location());
816 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) 821 synthesize_mouse_move_ = false;
817 synthesize_mouse_move_ = false;
818 } 822 }
819 } 823 }
820 824
821 void RootWindow::PreDispatchMouseEvent(Window* target, 825 void RootWindow::PreDispatchMouseEvent(Window* target,
822 ui::MouseEvent* event) { 826 ui::MouseEvent* event) {
823 client::CursorClient* cursor_client = client::GetCursorClient(window()); 827 client::CursorClient* cursor_client = client::GetCursorClient(window());
824 if (cursor_client && 828 if (cursor_client &&
825 !cursor_client->IsMouseEventsEnabled() && 829 !cursor_client->IsMouseEventsEnabled() &&
826 (event->flags() & ui::EF_IS_SYNTHESIZED)) { 830 (event->flags() & ui::EF_IS_SYNTHESIZED)) {
827 event->SetHandled(); 831 event->SetHandled();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 break; 945 break;
942 946
943 default: 947 default:
944 NOTREACHED(); 948 NOTREACHED();
945 break; 949 break;
946 } 950 }
947 PreDispatchLocatedEvent(target, event); 951 PreDispatchLocatedEvent(target, event);
948 } 952 }
949 953
950 } // namespace aura 954 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/root_window_unittest.cc » ('j') | ui/aura/root_window_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698