| 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/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "ui/views/widget/tooltip_manager_aura.h" | 35 #include "ui/views/widget/tooltip_manager_aura.h" |
| 36 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
| 37 | 37 |
| 38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 #include "base/win/scoped_gdi_object.h" | 39 #include "base/win/scoped_gdi_object.h" |
| 40 #include "base/win/win_util.h" | 40 #include "base/win/win_util.h" |
| 41 #include "ui/base/l10n/l10n_util_win.h" | 41 #include "ui/base/l10n/l10n_util_win.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(ENABLE_DIP) | 44 #if defined(ENABLE_DIP) |
| 45 #include "ui/aura/monitor.h" | 45 #include "ui/gfx/monitor.h" |
| 46 #include "ui/aura/monitor_manager.h" | |
| 47 #endif | 46 #endif |
| 48 | 47 |
| 49 namespace views { | 48 namespace views { |
| 50 | 49 |
| 51 bool NativeWidgetAura::g_aura_desktop_hax = false; | 50 bool NativeWidgetAura::g_aura_desktop_hax = false; |
| 52 | 51 |
| 53 namespace { | 52 namespace { |
| 54 | 53 |
| 55 aura::client::WindowType GetAuraWindowTypeForWidgetType( | 54 aura::client::WindowType GetAuraWindowTypeForWidgetType( |
| 56 Widget::InitParams::Type type) { | 55 Widget::InitParams::Type type) { |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 bool NativeWidgetAura::CanFocus() { | 834 bool NativeWidgetAura::CanFocus() { |
| 836 return can_activate_; | 835 return can_activate_; |
| 837 } | 836 } |
| 838 | 837 |
| 839 void NativeWidgetAura::OnCaptureLost() { | 838 void NativeWidgetAura::OnCaptureLost() { |
| 840 delegate_->OnMouseCaptureLost(); | 839 delegate_->OnMouseCaptureLost(); |
| 841 } | 840 } |
| 842 | 841 |
| 843 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { | 842 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
| 844 #if defined(ENABLE_DIP) | 843 #if defined(ENABLE_DIP) |
| 845 aura::Monitor* monitor = GetMonitor(); | |
| 846 canvas->Save(); | 844 canvas->Save(); |
| 847 float scale = monitor->GetDeviceScaleFactor(); | 845 float scale = GetMonitorScaleFactor(); |
| 848 canvas->sk_canvas()->scale(SkFloatToScalar(scale), SkFloatToScalar(scale)); | 846 canvas->sk_canvas()->scale(SkFloatToScalar(scale), SkFloatToScalar(scale)); |
| 849 #endif | 847 #endif |
| 850 delegate_->OnNativeWidgetPaint(canvas); | 848 delegate_->OnNativeWidgetPaint(canvas); |
| 851 #if defined(ENABLE_DIP) | 849 #if defined(ENABLE_DIP) |
| 852 canvas->Restore(); | 850 canvas->Restore(); |
| 853 #endif | 851 #endif |
| 854 } | 852 } |
| 855 | 853 |
| 856 void NativeWidgetAura::OnWindowDestroying() { | 854 void NativeWidgetAura::OnWindowDestroying() { |
| 857 delegate_->OnNativeWidgetDestroying(); | 855 delegate_->OnNativeWidgetDestroying(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 //////////////////////////////////////////////////////////////////////////////// | 940 //////////////////////////////////////////////////////////////////////////////// |
| 943 // NativeWidgetAura, private: | 941 // NativeWidgetAura, private: |
| 944 | 942 |
| 945 void NativeWidgetAura::SetInitialFocus() { | 943 void NativeWidgetAura::SetInitialFocus() { |
| 946 // The window does not get keyboard messages unless we focus it. | 944 // The window does not get keyboard messages unless we focus it. |
| 947 if (!GetWidget()->SetInitialFocus()) | 945 if (!GetWidget()->SetInitialFocus()) |
| 948 window_->Focus(); | 946 window_->Focus(); |
| 949 } | 947 } |
| 950 | 948 |
| 951 #if defined(ENABLE_DIP) | 949 #if defined(ENABLE_DIP) |
| 952 aura::Monitor* NativeWidgetAura::GetMonitor() const { | 950 float NativeWidgetAura::GetMonitorScaleFactor() const { |
| 953 return aura::Env::GetInstance()->monitor_manager()-> | 951 gfx::Monitor monitor; |
| 954 GetMonitorNearestWindow(window_); | 952 gfx::Screen::GetMonitorNearestWindow(window_, &monitor); |
| 953 return monitor.device_scale_factor(); |
| 955 } | 954 } |
| 956 | 955 |
| 957 gfx::Point NativeWidgetAura::ConvertPointFromMonitor( | 956 gfx::Point NativeWidgetAura::ConvertPointFromMonitor( |
| 958 const gfx::Point& point) const { | 957 const gfx::Point& point) const { |
| 959 return point.Scale(1.0f / GetMonitor()->GetDeviceScaleFactor()); | 958 return point.Scale(1.0f / GetMonitorScaleFactor()); |
| 960 } | 959 } |
| 961 | 960 |
| 962 gfx::Size NativeWidgetAura::ConvertSizeFromMonitor( | 961 gfx::Size NativeWidgetAura::ConvertSizeFromMonitor( |
| 963 const gfx::Size& size) const { | 962 const gfx::Size& size) const { |
| 964 return size.Scale(1.0f / GetMonitor()->GetDeviceScaleFactor()); | 963 return size.Scale(1.0f / GetMonitorScaleFactor()); |
| 965 } | 964 } |
| 966 | 965 |
| 967 gfx::Rect NativeWidgetAura::ConvertRectFromMonitor( | 966 gfx::Rect NativeWidgetAura::ConvertRectFromMonitor( |
| 968 const gfx::Rect& rect) const { | 967 const gfx::Rect& rect) const { |
| 969 float scale = 1.0f / GetMonitor()->GetDeviceScaleFactor(); | 968 float scale = 1.0f / GetMonitorScaleFactor(); |
| 970 return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale)); | 969 return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale)); |
| 971 } | 970 } |
| 972 | 971 |
| 973 gfx::Size NativeWidgetAura::ConvertSizeToMonitor(const gfx::Size& size) const { | 972 gfx::Size NativeWidgetAura::ConvertSizeToMonitor(const gfx::Size& size) const { |
| 974 return size.Scale(GetMonitor()->GetDeviceScaleFactor()); | 973 return size.Scale(GetMonitorScaleFactor()); |
| 975 } | 974 } |
| 976 | 975 |
| 977 gfx::Rect NativeWidgetAura::ConvertRectToMonitor(const gfx::Rect& rect) const { | 976 gfx::Rect NativeWidgetAura::ConvertRectToMonitor(const gfx::Rect& rect) const { |
| 978 float scale = GetMonitor()->GetDeviceScaleFactor(); | 977 float scale = GetMonitorScaleFactor(); |
| 979 return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale)); | 978 return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale)); |
| 980 } | 979 } |
| 981 #endif | 980 #endif |
| 982 | 981 |
| 983 //////////////////////////////////////////////////////////////////////////////// | 982 //////////////////////////////////////////////////////////////////////////////// |
| 984 // Widget, public: | 983 // Widget, public: |
| 985 | 984 |
| 986 // static | 985 // static |
| 987 void Widget::NotifyLocaleChanged() { | 986 void Widget::NotifyLocaleChanged() { |
| 988 // Deliberately not implemented. | 987 // Deliberately not implemented. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 } | 1084 } |
| 1086 } | 1085 } |
| 1087 | 1086 |
| 1088 // static | 1087 // static |
| 1089 bool NativeWidgetPrivate::IsMouseButtonDown() { | 1088 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 1090 return aura::Env::GetInstance()->is_mouse_button_down(); | 1089 return aura::Env::GetInstance()->is_mouse_button_down(); |
| 1091 } | 1090 } |
| 1092 | 1091 |
| 1093 } // namespace internal | 1092 } // namespace internal |
| 1094 } // namespace views | 1093 } // namespace views |
| OLD | NEW |