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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "third_party/skia/include/core/SkRegion.h" | 10 #include "third_party/skia/include/core/SkRegion.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 context = parent; | 130 context = parent; |
131 parent = NULL; | 131 parent = NULL; |
132 } | 132 } |
133 // SetAlwaysOnTop before SetParent so that always-on-top container is used. | 133 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
134 SetAlwaysOnTop(params.keep_on_top); | 134 SetAlwaysOnTop(params.keep_on_top); |
135 // Make sure we have a real |window_bounds|. | 135 // Make sure we have a real |window_bounds|. |
136 if (parent && window_bounds == gfx::Rect()) { | 136 if (parent && window_bounds == gfx::Rect()) { |
137 // If a parent is specified but no bounds are given, | 137 // If a parent is specified but no bounds are given, |
138 // use the origin of the parent's display so that the widget | 138 // use the origin of the parent's display so that the widget |
139 // will be added to the same display as the parent. | 139 // will be added to the same display as the parent. |
140 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> | 140 gfx::Rect bounds = |
141 GetDisplayNearestWindow(parent).bounds(); | 141 gfx::Screen::GetScreen()->GetDisplayNearestWindow(parent).bounds(); |
142 window_bounds.set_origin(bounds.origin()); | 142 window_bounds.set_origin(bounds.origin()); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 // Set properties before adding to the parent so that its layout manager sees | 146 // Set properties before adding to the parent so that its layout manager sees |
147 // the correct values. | 147 // the correct values. |
148 OnSizeConstraintsChanged(); | 148 OnSizeConstraintsChanged(); |
149 | 149 |
150 if (parent) { | 150 if (parent) { |
151 parent->AddChild(window_); | 151 parent->AddChild(window_); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 278 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
279 if (!window_) | 279 if (!window_) |
280 return; | 280 return; |
281 | 281 |
282 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); | 282 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); |
283 // When centering window, we take the intersection of the host and | 283 // When centering window, we take the intersection of the host and |
284 // the parent. We assume the root window represents the visible | 284 // the parent. We assume the root window represents the visible |
285 // rect of a single screen. | 285 // rect of a single screen. |
286 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> | 286 gfx::Rect work_area = |
287 GetDisplayNearestWindow(window_).work_area(); | 287 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); |
288 | 288 |
289 aura::client::ScreenPositionClient* screen_position_client = | 289 aura::client::ScreenPositionClient* screen_position_client = |
290 aura::client::GetScreenPositionClient(window_->GetRootWindow()); | 290 aura::client::GetScreenPositionClient(window_->GetRootWindow()); |
291 if (screen_position_client) { | 291 if (screen_position_client) { |
292 gfx::Point origin = work_area.origin(); | 292 gfx::Point origin = work_area.origin(); |
293 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), | 293 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), |
294 &origin); | 294 &origin); |
295 work_area.set_origin(origin); | 295 work_area.set_origin(origin); |
296 } | 296 } |
297 | 297 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 397 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
398 if (!window_) | 398 if (!window_) |
399 return; | 399 return; |
400 | 400 |
401 aura::Window* root = window_->GetRootWindow(); | 401 aura::Window* root = window_->GetRootWindow(); |
402 if (root) { | 402 if (root) { |
403 aura::client::ScreenPositionClient* screen_position_client = | 403 aura::client::ScreenPositionClient* screen_position_client = |
404 aura::client::GetScreenPositionClient(root); | 404 aura::client::GetScreenPositionClient(root); |
405 if (screen_position_client) { | 405 if (screen_position_client) { |
406 gfx::Display dst_display = | 406 gfx::Display dst_display = |
407 gfx::Screen::GetScreenFor(window_)->GetDisplayMatching(bounds); | 407 gfx::Screen::GetScreen()->GetDisplayMatching(bounds); |
408 screen_position_client->SetBounds(window_, bounds, dst_display); | 408 screen_position_client->SetBounds(window_, bounds, dst_display); |
409 return; | 409 return; |
410 } | 410 } |
411 } | 411 } |
412 window_->SetBounds(bounds); | 412 window_->SetBounds(bounds); |
413 } | 413 } |
414 | 414 |
415 void NativeWidgetAura::SetSize(const gfx::Size& size) { | 415 void NativeWidgetAura::SetSize(const gfx::Size& size) { |
416 if (window_) | 416 if (window_) |
417 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size)); | 417 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size)); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 636 |
637 void NativeWidgetAura::ClearNativeFocus() { | 637 void NativeWidgetAura::ClearNativeFocus() { |
638 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); | 638 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); |
639 if (window_ && client && window_->Contains(client->GetFocusedWindow())) | 639 if (window_ && client && window_->Contains(client->GetFocusedWindow())) |
640 client->ResetFocusWithinActiveWindow(window_); | 640 client->ResetFocusWithinActiveWindow(window_); |
641 } | 641 } |
642 | 642 |
643 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { | 643 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { |
644 if (!window_) | 644 if (!window_) |
645 return gfx::Rect(); | 645 return gfx::Rect(); |
646 return gfx::Screen::GetScreenFor(window_)-> | 646 return gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); |
647 GetDisplayNearestWindow(window_).work_area(); | |
648 } | 647 } |
649 | 648 |
650 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( | 649 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( |
651 const gfx::Vector2d& drag_offset, | 650 const gfx::Vector2d& drag_offset, |
652 Widget::MoveLoopSource source, | 651 Widget::MoveLoopSource source, |
653 Widget::MoveLoopEscapeBehavior escape_behavior) { | 652 Widget::MoveLoopEscapeBehavior escape_behavior) { |
654 // |escape_behavior| is only needed on windows when running the native message | 653 // |escape_behavior| is only needed on windows when running the native message |
655 // loop. | 654 // loop. |
656 if (!window_ || !window_->GetRootWindow()) | 655 if (!window_ || !window_->GetRootWindow()) |
657 return Widget::MOVE_LOOP_CANCELED; | 656 return Widget::MOVE_LOOP_CANCELED; |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1170 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1172 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1171 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1173 return gfx::FontList(gfx::Font(caption_font.get())); | 1172 return gfx::FontList(gfx::Font(caption_font.get())); |
1174 #else | 1173 #else |
1175 return gfx::FontList(); | 1174 return gfx::FontList(); |
1176 #endif | 1175 #endif |
1177 } | 1176 } |
1178 | 1177 |
1179 } // namespace internal | 1178 } // namespace internal |
1180 } // namespace views | 1179 } // namespace views |
OLD | NEW |