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

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

Issue 13902003: Remove Event::system_location (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 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 "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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/compositor/compositor.h" 33 #include "ui/compositor/compositor.h"
34 #include "ui/compositor/dip_util.h" 34 #include "ui/compositor/dip_util.h"
35 #include "ui/compositor/layer.h" 35 #include "ui/compositor/layer.h"
36 #include "ui/compositor/layer_animator.h" 36 #include "ui/compositor/layer_animator.h"
37 #include "ui/gfx/display.h" 37 #include "ui/gfx/display.h"
38 #include "ui/gfx/point3_f.h" 38 #include "ui/gfx/point3_f.h"
39 #include "ui/gfx/point_conversions.h" 39 #include "ui/gfx/point_conversions.h"
40 #include "ui/gfx/screen.h" 40 #include "ui/gfx/screen.h"
41 #include "ui/gfx/size_conversions.h" 41 #include "ui/gfx/size_conversions.h"
42 42
43 #if defined(OS_CHROMEOS)
44 #include "ui/base/events/event_utils.h"
45 #endif
46
43 using std::vector; 47 using std::vector;
44 48
45 namespace aura { 49 namespace aura {
46 50
47 namespace { 51 namespace {
48 52
49 const char kRootWindowForAcceleratedWidget[] = 53 const char kRootWindowForAcceleratedWidget[] =
50 "__AURA_ROOT_WINDOW_ACCELERATED_WIDGET__"; 54 "__AURA_ROOT_WINDOW_ACCELERATED_WIDGET__";
51 55
52 // Returns true if |target| has a non-client (frame) component at |location|, 56 // Returns true if |target| has a non-client (frame) component at |location|,
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 691 }
688 692
689 //////////////////////////////////////////////////////////////////////////////// 693 ////////////////////////////////////////////////////////////////////////////////
690 // RootWindow, private: 694 // RootWindow, private:
691 695
692 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root, 696 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root,
693 ui::LocatedEvent* event) { 697 ui::LocatedEvent* event) {
694 event->UpdateForRootTransform(GetInverseRootTransform()); 698 event->UpdateForRootTransform(GetInverseRootTransform());
695 #if defined(OS_CHROMEOS) 699 #if defined(OS_CHROMEOS)
696 const gfx::Rect& root_bounds = bounds(); 700 const gfx::Rect& root_bounds = bounds();
701 if (!event->native_event())
702 return;
703 const gfx::Point system_location =
704 ui::EventSystemLocationFromNative(event->native_event());
697 if (keep_inside_root & 705 if (keep_inside_root &
698 host_->GetBounds().Contains(event->system_location()) && 706 host_->GetBounds().Contains(system_location) &&
699 !root_bounds.Contains(event->root_location())) { 707 !root_bounds.Contains(event->root_location())) {
700 // Make sure that the mouse location inside the host window gets 708 // Make sure that the mouse location inside the host window gets
701 // translated inside root window. 709 // translated inside root window.
702 // TODO(oshima): This is (hopefully) short term bandaid to deal 710 // TODO(oshima): This is (hopefully) short term bandaid to deal
703 // with calculation error due to the fact that we rotate in dip 711 // with calculation error due to the fact that we rotate in dip
704 // coordinates instead of pixels. crbug.com/222483. 712 // coordinates instead of pixels. crbug.com/222483.
713 // When removing this, don't forget to remove the include of the
714 // event_util.h file.
705 int x = event->location().x(); 715 int x = event->location().x();
706 int y = event->location().y(); 716 int y = event->location().y();
707 x = std::min(std::max(x, root_bounds.x()), root_bounds.right()); 717 x = std::min(std::max(x, root_bounds.x()), root_bounds.right());
708 y = std::min(std::max(y, root_bounds.y()), root_bounds.bottom()); 718 y = std::min(std::max(y, root_bounds.y()), root_bounds.bottom());
709 const gfx::Point new_location(x, y); 719 const gfx::Point new_location(x, y);
710 event->set_location(new_location); 720 event->set_location(new_location);
711 event->set_root_location(new_location); 721 event->set_root_location(new_location);
712 } 722 }
713 #endif // defined(OS_CHROMEOS) 723 #endif // defined(OS_CHROMEOS)
714 } 724 }
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 return; 1171 return;
1162 gfx::Point host_mouse_location = root_mouse_location; 1172 gfx::Point host_mouse_location = root_mouse_location;
1163 ConvertPointToHost(&host_mouse_location); 1173 ConvertPointToHost(&host_mouse_location);
1164 1174
1165 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's 1175 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's
1166 // currently broken. See/ crbug.com/107931. 1176 // currently broken. See/ crbug.com/107931.
1167 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 1177 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
1168 host_mouse_location, 1178 host_mouse_location,
1169 host_mouse_location, 1179 host_mouse_location,
1170 ui::EF_IS_SYNTHESIZED); 1180 ui::EF_IS_SYNTHESIZED);
1171 ConvertPointToNativeScreen(&root_mouse_location); 1181 ConvertPointToNativeScreen(&root_mouse_location);
sadrul 2013/04/10 00:12:41 Is this conversion necessary anymore?
oshima 2013/04/10 01:28:01 doh, you're right. removed.
1172 event.set_system_location(root_mouse_location);
1173 OnHostMouseEvent(&event); 1182 OnHostMouseEvent(&event);
1174 } 1183 }
1175 1184
1176 gfx::Transform RootWindow::GetRootTransform() const { 1185 gfx::Transform RootWindow::GetRootTransform() const {
1177 float scale = ui::GetDeviceScaleFactor(layer()); 1186 float scale = ui::GetDeviceScaleFactor(layer());
1178 gfx::Transform transform; 1187 gfx::Transform transform;
1179 transform.Scale(scale, scale); 1188 transform.Scale(scale, scale);
1180 transform *= transformer_->GetTransform(); 1189 transform *= transformer_->GetTransform();
1181 return transform; 1190 return transform;
1182 } 1191 }
1183 1192
1184 gfx::Transform RootWindow::GetInverseRootTransform() const { 1193 gfx::Transform RootWindow::GetInverseRootTransform() const {
1185 float scale = ui::GetDeviceScaleFactor(layer()); 1194 float scale = ui::GetDeviceScaleFactor(layer());
1186 gfx::Transform transform; 1195 gfx::Transform transform;
1187 transform.Scale(1.0f / scale, 1.0f / scale); 1196 transform.Scale(1.0f / scale, 1.0f / scale);
1188 return transformer_->GetInverseTransform() * transform; 1197 return transformer_->GetInverseTransform() * transform;
1189 } 1198 }
1190 1199
1191 } // namespace aura 1200 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/event_generator.cc » ('j') | ui/views/widget/desktop_aura/x11_window_event_filter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698