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_root_window_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h" |
6 | 6 |
7 #include "base/win/metro.h" | 7 #include "base/win/metro.h" |
8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 gfx::Vector2d(expanded.width() - size_in_pixels.width(), | 233 gfx::Vector2d(expanded.width() - size_in_pixels.width(), |
234 expanded.height() - size_in_pixels.height()); | 234 expanded.height() - size_in_pixels.height()); |
235 message_handler_->SetSize(expanded); | 235 message_handler_->SetSize(expanded); |
236 } | 236 } |
237 | 237 |
238 void DesktopWindowTreeHostWin::StackAtTop() { | 238 void DesktopWindowTreeHostWin::StackAtTop() { |
239 message_handler_->StackAtTop(); | 239 message_handler_->StackAtTop(); |
240 } | 240 } |
241 | 241 |
242 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) { | 242 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) { |
| 243 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); |
243 gfx::Size expanded_size; | 244 gfx::Size expanded_size; |
244 expanded_size = GetExpandedWindowSize( | 245 expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(), |
245 message_handler_->window_ex_style(), size); | 246 size_in_pixels); |
246 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(expanded_size); | 247 window_enlargement_ = |
247 message_handler_->CenterWindow(size_in_pixels); | 248 gfx::Vector2d(expanded_size.width() - size_in_pixels.width(), |
| 249 expanded_size.height() - size_in_pixels.height()); |
| 250 message_handler_->CenterWindow(expanded_size); |
248 } | 251 } |
249 | 252 |
250 void DesktopWindowTreeHostWin::GetWindowPlacement( | 253 void DesktopWindowTreeHostWin::GetWindowPlacement( |
251 gfx::Rect* bounds, | 254 gfx::Rect* bounds, |
252 ui::WindowShowState* show_state) const { | 255 ui::WindowShowState* show_state) const { |
253 message_handler_->GetWindowPlacement(bounds, show_state); | 256 message_handler_->GetWindowPlacement(bounds, show_state); |
254 InsetBottomRight(bounds, window_enlargement_); | 257 InsetBottomRight(bounds, window_enlargement_); |
255 *bounds = gfx::win::ScreenToDIPRect(*bounds); | 258 *bounds = gfx::win::ScreenToDIPRect(*bounds); |
256 } | 259 } |
257 | 260 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 449 } |
447 | 450 |
448 void DesktopWindowTreeHostWin::ToggleFullScreen() { | 451 void DesktopWindowTreeHostWin::ToggleFullScreen() { |
449 SetWindowTransparency(); | 452 SetWindowTransparency(); |
450 } | 453 } |
451 | 454 |
452 // GetBounds and SetBounds work in pixel coordinates, whereas other get/set | 455 // GetBounds and SetBounds work in pixel coordinates, whereas other get/set |
453 // methods work in DIP. | 456 // methods work in DIP. |
454 | 457 |
455 gfx::Rect DesktopWindowTreeHostWin::GetBounds() const { | 458 gfx::Rect DesktopWindowTreeHostWin::GetBounds() const { |
456 // Match the logic in HWNDMessageHandler::ClientAreaSizeChanged(). | 459 gfx::Rect bounds(message_handler_->GetClientAreaBounds()); |
457 if (IsMinimized()) | |
458 return gfx::Rect(); | |
459 gfx::Rect bounds(WidgetSizeIsClientSize() ? | |
460 message_handler_->GetClientAreaBoundsInScreen() : | |
461 message_handler_->GetWindowBoundsInScreen()); | |
462 | |
463 // If the window bounds were expanded we need to return the original bounds | 460 // If the window bounds were expanded we need to return the original bounds |
464 // To achieve this we do the reverse of the expansion, i.e. add the | 461 // To achieve this we do the reverse of the expansion, i.e. add the |
465 // window_expansion_top_left_delta_ to the origin and subtract the | 462 // window_expansion_top_left_delta_ to the origin and subtract the |
466 // window_expansion_bottom_right_delta_ from the width and height. | 463 // window_expansion_bottom_right_delta_ from the width and height. |
467 gfx::Rect without_expansion( | 464 gfx::Rect without_expansion( |
468 bounds.x() + window_expansion_top_left_delta_.x(), | 465 bounds.x() + window_expansion_top_left_delta_.x(), |
469 bounds.y() + window_expansion_top_left_delta_.y(), | 466 bounds.y() + window_expansion_top_left_delta_.y(), |
470 bounds.width() - window_expansion_bottom_right_delta_.x() - | 467 bounds.width() - window_expansion_bottom_right_delta_.x() - |
471 window_enlargement_.x(), | 468 window_enlargement_.x(), |
472 bounds.height() - window_expansion_bottom_right_delta_.y() - | 469 bounds.height() - window_expansion_bottom_right_delta_.y() - |
473 window_enlargement_.y()); | 470 window_enlargement_.y()); |
474 return without_expansion; | 471 return without_expansion; |
475 } | 472 } |
476 | 473 |
477 void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { | 474 void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { |
478 // If the window bounds have to be expanded we need to subtract the | 475 // If the window bounds have to be expanded we need to subtract the |
479 // window_expansion_top_left_delta_ from the origin and add the | 476 // window_expansion_top_left_delta_ from the origin and add the |
480 // window_expansion_bottom_right_delta_ to the width and height | 477 // window_expansion_bottom_right_delta_ to the width and height |
| 478 gfx::Size old_hwnd_size(message_handler_->GetClientAreaBounds().size()); |
| 479 gfx::Size old_content_size = GetBounds().size(); |
| 480 |
481 gfx::Rect expanded( | 481 gfx::Rect expanded( |
482 bounds.x() - window_expansion_top_left_delta_.x(), | 482 bounds.x() - window_expansion_top_left_delta_.x(), |
483 bounds.y() - window_expansion_top_left_delta_.y(), | 483 bounds.y() - window_expansion_top_left_delta_.y(), |
484 bounds.width() + window_expansion_bottom_right_delta_.x(), | 484 bounds.width() + window_expansion_bottom_right_delta_.x(), |
485 bounds.height() + window_expansion_bottom_right_delta_.y()); | 485 bounds.height() + window_expansion_bottom_right_delta_.y()); |
486 | 486 |
487 gfx::Rect new_expanded( | 487 gfx::Rect new_expanded( |
488 expanded.origin(), | 488 expanded.origin(), |
489 GetExpandedWindowSize(message_handler_->window_ex_style(), | 489 GetExpandedWindowSize(message_handler_->window_ex_style(), |
490 expanded.size())); | 490 expanded.size())); |
491 window_enlargement_ = | 491 window_enlargement_ = |
492 gfx::Vector2d(new_expanded.width() - expanded.width(), | 492 gfx::Vector2d(new_expanded.width() - expanded.width(), |
493 new_expanded.height() - expanded.height()); | 493 new_expanded.height() - expanded.height()); |
494 message_handler_->SetBounds(new_expanded); | 494 message_handler_->SetBounds(new_expanded); |
| 495 |
| 496 // The client area size may have changed even though the window bounds have |
| 497 // not, if the window bounds were expanded to 64 pixels both times. |
| 498 if (old_hwnd_size == new_expanded.size() && old_content_size != bounds.size()) |
| 499 HandleClientSizeChanged(new_expanded.size()); |
495 } | 500 } |
496 | 501 |
497 gfx::Insets DesktopWindowTreeHostWin::GetInsets() const { | 502 gfx::Insets DesktopWindowTreeHostWin::GetInsets() const { |
498 return gfx::Insets(); | 503 return gfx::Insets(); |
499 } | 504 } |
500 | 505 |
501 void DesktopWindowTreeHostWin::SetInsets(const gfx::Insets& insets) { | 506 void DesktopWindowTreeHostWin::SetInsets(const gfx::Insets& insets) { |
502 } | 507 } |
503 | 508 |
504 gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const { | 509 gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const { |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 | 995 |
991 // static | 996 // static |
992 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 997 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
993 internal::NativeWidgetDelegate* native_widget_delegate, | 998 internal::NativeWidgetDelegate* native_widget_delegate, |
994 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 999 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
995 return new DesktopWindowTreeHostWin(native_widget_delegate, | 1000 return new DesktopWindowTreeHostWin(native_widget_delegate, |
996 desktop_native_widget_aura); | 1001 desktop_native_widget_aura); |
997 } | 1002 } |
998 | 1003 |
999 } // namespace views | 1004 } // namespace views |
OLD | NEW |