| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "ui/wm/core/shadow_controller.h" | 54 #include "ui/wm/core/shadow_controller.h" |
| 55 #include "ui/wm/core/shadow_types.h" | 55 #include "ui/wm/core/shadow_types.h" |
| 56 #include "ui/wm/core/visibility_controller.h" | 56 #include "ui/wm/core/visibility_controller.h" |
| 57 #include "ui/wm/core/window_animations.h" | 57 #include "ui/wm/core/window_animations.h" |
| 58 #include "ui/wm/core/window_modality_controller.h" | 58 #include "ui/wm/core/window_modality_controller.h" |
| 59 #include "ui/wm/public/activation_client.h" | 59 #include "ui/wm/public/activation_client.h" |
| 60 #include "ui/wm/public/drag_drop_client.h" | 60 #include "ui/wm/public/drag_drop_client.h" |
| 61 | 61 |
| 62 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 63 #include "ui/base/win/shell.h" | 63 #include "ui/base/win/shell.h" |
| 64 #include "ui/gfx/win/dpi.h" | 64 #include "ui/gfx/screen_win.h" |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, | 67 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, |
| 68 views::DesktopNativeWidgetAura*); | 68 views::DesktopNativeWidgetAura*); |
| 69 | 69 |
| 70 namespace views { | 70 namespace views { |
| 71 | 71 |
| 72 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, | 72 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, |
| 73 kDesktopNativeWidgetAuraKey, NULL); | 73 kDesktopNativeWidgetAuraKey, NULL); |
| 74 | 74 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 682 } |
| 683 | 683 |
| 684 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { | 684 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { |
| 685 return content_window_ ? | 685 return content_window_ ? |
| 686 desktop_window_tree_host_->GetRestoredBounds() : gfx::Rect(); | 686 desktop_window_tree_host_->GetRestoredBounds() : gfx::Rect(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 689 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
| 690 if (!content_window_) | 690 if (!content_window_) |
| 691 return; | 691 return; |
| 692 // TODO(ananta) | |
| 693 // This code by default scales the bounds rectangle by 1. | |
| 694 // We could probably get rid of this and similar logic from | |
| 695 // the DesktopNativeWidgetAura::OnWindowTreeHostResized function. | |
| 696 float scale = 1; | |
| 697 aura::Window* root = host_->window(); | 692 aura::Window* root = host_->window(); |
| 698 if (root) { | 693 gfx::Screen* screen = gfx::Screen::GetScreenFor(root); |
| 699 scale = gfx::Screen::GetScreenFor(root)-> | 694 gfx::Rect bounds_in_pixels = screen->DIPToScreenRectInWindow(root, bounds); |
| 700 GetDisplayNearestWindow(root).device_scale_factor(); | |
| 701 } | |
| 702 gfx::Rect bounds_in_pixels = | |
| 703 gfx::ScaleToEnclosingRect(bounds, scale, scale); | |
| 704 desktop_window_tree_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels); | 695 desktop_window_tree_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels); |
| 705 } | 696 } |
| 706 | 697 |
| 707 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { | 698 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { |
| 708 if (content_window_) | 699 if (content_window_) |
| 709 desktop_window_tree_host_->SetSize(size); | 700 desktop_window_tree_host_->SetSize(size); |
| 710 } | 701 } |
| 711 | 702 |
| 712 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { | 703 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { |
| 713 if (content_window_) | 704 if (content_window_) |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 if (cursor_reference_count_ == 0) { | 1197 if (cursor_reference_count_ == 0) { |
| 1207 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1198 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1208 // for cleaning up |cursor_manager_|. | 1199 // for cleaning up |cursor_manager_|. |
| 1209 delete cursor_manager_; | 1200 delete cursor_manager_; |
| 1210 native_cursor_manager_ = NULL; | 1201 native_cursor_manager_ = NULL; |
| 1211 cursor_manager_ = NULL; | 1202 cursor_manager_ = NULL; |
| 1212 } | 1203 } |
| 1213 } | 1204 } |
| 1214 | 1205 |
| 1215 } // namespace views | 1206 } // namespace views |
| OLD | NEW |