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

Side by Side Diff: ash/drag_drop/drag_drop_tracker.cc

Issue 10948020: Convert native mouse locations to the locations in screen coordinate in RootWindowHostLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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
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 "ash/drag_drop/drag_drop_tracker.h" 5 #include "ash/drag_drop/drag_drop_tracker.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/coordinate_conversion.h" 9 #include "ash/wm/coordinate_conversion.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 22 matching lines...) Expand all
33 DragDropTracker::DragDropTracker(aura::RootWindow* root_window) 33 DragDropTracker::DragDropTracker(aura::RootWindow* root_window)
34 : capture_window_(CreateCaptureWindow(root_window)) { 34 : capture_window_(CreateCaptureWindow(root_window)) {
35 capture_window_->SetCapture(); 35 capture_window_->SetCapture();
36 } 36 }
37 37
38 DragDropTracker::~DragDropTracker() { 38 DragDropTracker::~DragDropTracker() {
39 capture_window_->ReleaseCapture(); 39 capture_window_->ReleaseCapture();
40 } 40 }
41 41
42 aura::Window* DragDropTracker::GetTarget(const ui::LocatedEvent& event) { 42 aura::Window* DragDropTracker::GetTarget(const ui::LocatedEvent& event) {
43 std::pair<aura::RootWindow*, gfx::Point> pair = 43 DCHECK(capture_window_.get());
44 ash::wm::GetRootWindowRelativeToWindow(capture_window_.get(), 44 gfx::Point location_in_screen = event.location();
45 event.location()); 45 wm::ConvertPointToScreen(capture_window_.get(),
46 return pair.first->GetEventHandlerForPoint(pair.second); 46 &location_in_screen);
47 aura::RootWindow* root_window_at_point =
48 wm::GetRootWindowAt(location_in_screen);
49 gfx::Point location_in_root = location_in_screen;
50 wm::ConvertPointFromScreen(root_window_at_point, &location_in_root);
51 return root_window_at_point->GetEventHandlerForPoint(location_in_root);
47 } 52 }
48 53
49 ui::MouseEvent* DragDropTracker::ConvertMouseEvent( 54 ui::MouseEvent* DragDropTracker::ConvertMouseEvent(
50 aura::Window* target, 55 aura::Window* target,
51 const ui::MouseEvent& event) { 56 const ui::MouseEvent& event) {
52 DCHECK(capture_window_.get()); 57 DCHECK(capture_window_.get());
53 std::pair<aura::RootWindow*, gfx::Point> location_pair = 58 gfx::Point target_location = event.location();
54 ash::wm::GetRootWindowRelativeToWindow(capture_window_.get(), 59 aura::Window::ConvertPointToTarget(capture_window_.get(), target,
55 event.location()); 60 &target_location);
56 aura::Window::ConvertPointToTarget(location_pair.first, target, 61 gfx::Point location_in_screen = event.location();
57 &location_pair.second); 62 ash::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
58 std::pair<aura::RootWindow*, gfx::Point> root_location_pair = 63 gfx::Point target_root_location = event.root_location();
59 ash::wm::GetRootWindowRelativeToWindow(capture_window_->GetRootWindow(), 64 aura::Window::ConvertPointToTarget(
60 event.root_location()); 65 capture_window_->GetRootWindow(),
66 ash::wm::GetRootWindowAt(location_in_screen),
67 &target_root_location);
61 return new ui::MouseEvent(event.type(), 68 return new ui::MouseEvent(event.type(),
62 location_pair.second, 69 target_location,
63 root_location_pair.second, 70 target_root_location,
64 event.flags()); 71 event.flags());
65 } 72 }
66 73
67 } // namespace internal 74 } // namespace internal
68 } // namespace ash 75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/mouse_cursor_event_filter_unittest.cc ('k') | ash/drag_drop/drag_drop_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698