OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 #include "ui/base/gestures/gesture_types.h" | 32 #include "ui/base/gestures/gesture_types.h" |
33 #include "ui/base/hit_test.h" | 33 #include "ui/base/hit_test.h" |
34 #include "ui/base/view_prop.h" | 34 #include "ui/base/view_prop.h" |
35 #include "ui/compositor/compositor.h" | 35 #include "ui/compositor/compositor.h" |
36 #include "ui/compositor/dip_util.h" | 36 #include "ui/compositor/dip_util.h" |
37 #include "ui/compositor/layer.h" | 37 #include "ui/compositor/layer.h" |
38 #include "ui/compositor/layer_animator.h" | 38 #include "ui/compositor/layer_animator.h" |
39 #include "ui/gfx/display.h" | 39 #include "ui/gfx/display.h" |
40 #include "ui/gfx/point3_f.h" | 40 #include "ui/gfx/point3_f.h" |
41 #include "ui/gfx/point_conversions.h" | 41 #include "ui/gfx/point_conversions.h" |
| 42 #include "ui/gfx/rect_conversions.h" |
42 #include "ui/gfx/screen.h" | 43 #include "ui/gfx/screen.h" |
43 | 44 |
44 using std::vector; | 45 using std::vector; |
45 | 46 |
46 namespace aura { | 47 namespace aura { |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
50 const char kRootWindowForAcceleratedWidget[] = | 51 const char kRootWindowForAcceleratedWidget[] = |
51 "__AURA_ROOT_WINDOW_ACCELERATED_WIDGET__"; | 52 "__AURA_ROOT_WINDOW_ACCELERATED_WIDGET__"; |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 921 |
921 void RootWindow::OnHostMoved(const gfx::Point& origin) { | 922 void RootWindow::OnHostMoved(const gfx::Point& origin) { |
922 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 923 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
923 OnRootWindowMoved(this, origin)); | 924 OnRootWindowMoved(this, origin)); |
924 } | 925 } |
925 | 926 |
926 void RootWindow::OnHostResized(const gfx::Size& size) { | 927 void RootWindow::OnHostResized(const gfx::Size& size) { |
927 DispatchHeldMouseMove(); | 928 DispatchHeldMouseMove(); |
928 // The compositor should have the same size as the native root window host. | 929 // The compositor should have the same size as the native root window host. |
929 // Get the latest scale from display because it might have been changed. | 930 // Get the latest scale from display because it might have been changed. |
930 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), | 931 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), size); |
931 size); | 932 |
932 gfx::Size old(bounds().size()); | |
933 // The layer, and all the observers should be notified of the | 933 // The layer, and all the observers should be notified of the |
934 // transformed size of the root window. | 934 // transformed size of the root window. |
935 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size)); | 935 gfx::Size old(bounds().size()); |
| 936 gfx::RectF bounds(ui::ConvertSizeToDIP(layer(), size)); |
936 layer()->transform().TransformRect(&bounds); | 937 layer()->transform().TransformRect(&bounds); |
937 SetBounds(bounds); | 938 // The transform is expected to produce an integer rect as its output. |
| 939 SetBounds(gfx::ToNearestRect(bounds)); |
938 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 940 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
939 OnRootWindowResized(this, old)); | 941 OnRootWindowResized(this, old)); |
940 } | 942 } |
941 | 943 |
942 float RootWindow::GetDeviceScaleFactor() { | 944 float RootWindow::GetDeviceScaleFactor() { |
943 return compositor()->device_scale_factor(); | 945 return compositor()->device_scale_factor(); |
944 } | 946 } |
945 | 947 |
946 RootWindow* RootWindow::AsRootWindow() { | 948 RootWindow* RootWindow::AsRootWindow() { |
947 return this; | 949 return this; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 ui::MouseEvent event(ui::ET_MOUSE_MOVED, | 1042 ui::MouseEvent event(ui::ET_MOUSE_MOVED, |
1041 orig_mouse_location, | 1043 orig_mouse_location, |
1042 orig_mouse_location, | 1044 orig_mouse_location, |
1043 ui::EF_IS_SYNTHESIZED); | 1045 ui::EF_IS_SYNTHESIZED); |
1044 event.set_system_location(Env::GetInstance()->last_mouse_location()); | 1046 event.set_system_location(Env::GetInstance()->last_mouse_location()); |
1045 OnHostMouseEvent(&event); | 1047 OnHostMouseEvent(&event); |
1046 #endif | 1048 #endif |
1047 } | 1049 } |
1048 | 1050 |
1049 } // namespace aura | 1051 } // namespace aura |
OLD | NEW |