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/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #include "ui/wm/core/shadow_controller.h" | 52 #include "ui/wm/core/shadow_controller.h" |
53 #include "ui/wm/core/shadow_types.h" | 53 #include "ui/wm/core/shadow_types.h" |
54 #include "ui/wm/core/visibility_controller.h" | 54 #include "ui/wm/core/visibility_controller.h" |
55 #include "ui/wm/core/window_animations.h" | 55 #include "ui/wm/core/window_animations.h" |
56 #include "ui/wm/core/window_modality_controller.h" | 56 #include "ui/wm/core/window_modality_controller.h" |
57 #include "ui/wm/public/activation_client.h" | 57 #include "ui/wm/public/activation_client.h" |
58 #include "ui/wm/public/drag_drop_client.h" | 58 #include "ui/wm/public/drag_drop_client.h" |
59 | 59 |
60 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
61 #include "ui/base/win/shell.h" | 61 #include "ui/base/win/shell.h" |
62 #include "ui/gfx/win/dpi.h" | 62 #include "ui/gfx/screen_win.h" |
63 #endif | 63 #endif |
64 | 64 |
65 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, | 65 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, |
66 views::DesktopNativeWidgetAura*); | 66 views::DesktopNativeWidgetAura*); |
67 | 67 |
68 namespace views { | 68 namespace views { |
69 | 69 |
70 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, | 70 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, |
71 kDesktopNativeWidgetAuraKey, NULL); | 71 kDesktopNativeWidgetAuraKey, NULL); |
72 | 72 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 } | 678 } |
679 | 679 |
680 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { | 680 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { |
681 return content_window_ ? | 681 return content_window_ ? |
682 desktop_window_tree_host_->GetRestoredBounds() : gfx::Rect(); | 682 desktop_window_tree_host_->GetRestoredBounds() : gfx::Rect(); |
683 } | 683 } |
684 | 684 |
685 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 685 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
686 if (!content_window_) | 686 if (!content_window_) |
687 return; | 687 return; |
688 #if defined(OS_WIN) | |
689 // Windows has special scaling rules that do not apply to all platforms to | |
690 // accommodate multiple monitors with differing DPIs. | |
691 gfx::Rect bounds_in_pixels = | |
692 gfx::ScreenWin::DIPToScreenRect(host_->GetAcceleratedWidget(), bounds); | |
693 #else | |
688 // TODO(ananta) | 694 // TODO(ananta) |
689 // This code by default scales the bounds rectangle by 1. | 695 // This code by default scales the bounds rectangle by 1. |
690 // We could probably get rid of this and similar logic from | 696 // We could probably get rid of this and similar logic from |
691 // the DesktopNativeWidgetAura::OnWindowTreeHostResized function. | 697 // the DesktopNativeWidgetAura::OnWindowTreeHostResized function. |
692 float scale = 1; | 698 float scale = 1; |
693 aura::Window* root = host_->window(); | 699 aura::Window* root = host_->window(); |
694 if (root) { | 700 if (root) { |
695 scale = gfx::Screen::GetScreenFor(root)-> | 701 scale = gfx::Screen::GetScreenFor(root)-> |
696 GetDisplayNearestWindow(root).device_scale_factor(); | 702 GetDisplayNearestWindow(root).device_scale_factor(); |
sky
2015/10/29 15:51:51
Why can't this code be made to work consistently?
robliao
2015/11/07 00:56:40
This came down to the fixed origin coordinate betw
| |
697 } | 703 } |
698 gfx::Rect bounds_in_pixels = | 704 gfx::Rect bounds_in_pixels = |
699 gfx::ScaleToEnclosingRect(bounds, scale, scale); | 705 gfx::ScaleToEnclosingRect(bounds, scale, scale); |
706 #endif | |
700 desktop_window_tree_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels); | 707 desktop_window_tree_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels); |
701 } | 708 } |
702 | 709 |
703 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { | 710 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { |
704 if (content_window_) | 711 if (content_window_) |
705 desktop_window_tree_host_->SetSize(size); | 712 desktop_window_tree_host_->SetSize(size); |
706 } | 713 } |
707 | 714 |
708 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { | 715 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { |
709 if (content_window_) | 716 if (content_window_) |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1202 if (cursor_reference_count_ == 0) { | 1209 if (cursor_reference_count_ == 0) { |
1203 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1210 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1204 // for cleaning up |cursor_manager_|. | 1211 // for cleaning up |cursor_manager_|. |
1205 delete cursor_manager_; | 1212 delete cursor_manager_; |
1206 native_cursor_manager_ = NULL; | 1213 native_cursor_manager_ = NULL; |
1207 cursor_manager_ = NULL; | 1214 cursor_manager_ = NULL; |
1208 } | 1215 } |
1209 } | 1216 } |
1210 | 1217 |
1211 } // namespace views | 1218 } // namespace views |
OLD | NEW |