Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 window_->ClearSharedProperty(kWindowAppIcon_Property); | 900 window_->ClearSharedProperty(kWindowAppIcon_Property); |
| 901 } | 901 } |
| 902 } | 902 } |
| 903 | 903 |
| 904 void NativeWidgetMus::InitModalType(ui::ModalType modal_type) { | 904 void NativeWidgetMus::InitModalType(ui::ModalType modal_type) { |
| 905 if (modal_type != ui::MODAL_TYPE_NONE) | 905 if (modal_type != ui::MODAL_TYPE_NONE) |
| 906 window_->SetModal(); | 906 window_->SetModal(); |
| 907 } | 907 } |
| 908 | 908 |
| 909 gfx::Rect NativeWidgetMus::GetWindowBoundsInScreen() const { | 909 gfx::Rect NativeWidgetMus::GetWindowBoundsInScreen() const { |
| 910 return window_ ? window_->GetBoundsInRoot() : gfx::Rect(); | 910 if (!window_) |
| 911 return gfx::Rect(); | |
| 912 | |
| 913 // Correct for the origin of the display. | |
| 914 const int64_t window_display_id = window_->GetRoot()->display_id(); | |
| 915 for (display::Display display : | |
| 916 display::Screen::GetScreen()->GetAllDisplays()) { | |
| 917 if (display.id() == window_display_id) { | |
| 918 gfx::Point display_origin = display.bounds().origin(); | |
| 919 gfx::Rect bounds_in_screen = window_->GetBoundsInRoot(); | |
| 920 bounds_in_screen.Offset(display_origin.x(), display_origin.y()); | |
| 921 return bounds_in_screen; | |
| 922 } | |
| 923 } | |
| 924 // Unknown display, assume primary display at 0,0. | |
| 925 return window_->GetBoundsInRoot(); | |
| 911 } | 926 } |
| 912 | 927 |
| 913 gfx::Rect NativeWidgetMus::GetClientAreaBoundsInScreen() const { | 928 gfx::Rect NativeWidgetMus::GetClientAreaBoundsInScreen() const { |
| 914 // View-to-screen coordinate system transformations depend on this returning | 929 // View-to-screen coordinate system transformations depend on this returning |
| 915 // the full window bounds, for example View::ConvertPointToScreen(). | 930 // the full window bounds, for example View::ConvertPointToScreen(). |
| 916 return GetWindowBoundsInScreen(); | 931 return GetWindowBoundsInScreen(); |
| 917 } | 932 } |
| 918 | 933 |
| 919 gfx::Rect NativeWidgetMus::GetRestoredBounds() const { | 934 gfx::Rect NativeWidgetMus::GetRestoredBounds() const { |
| 920 // Restored bounds should only be relevant if the window is minimized, | 935 // Restored bounds should only be relevant if the window is minimized, |
| 921 // maximized, fullscreen or docked. However, in some places the code expects | 936 // maximized, fullscreen or docked. However, in some places the code expects |
| 922 // GetRestoredBounds() to return the current window bounds if the window is | 937 // GetRestoredBounds() to return the current window bounds if the window is |
| 923 // not in either state. | 938 // not in either state. |
| 924 if (IsMinimized() || IsMaximized() || IsFullscreen()) { | 939 if (IsMinimized() || IsMaximized() || IsFullscreen()) { |
| 925 const char* kRestoreBounds_Property = | 940 const char* kRestoreBounds_Property = |
| 926 ui::mojom::WindowManager::kRestoreBounds_Property; | 941 ui::mojom::WindowManager::kRestoreBounds_Property; |
| 927 if (window_->HasSharedProperty(kRestoreBounds_Property)) | 942 if (window_->HasSharedProperty(kRestoreBounds_Property)) |
| 928 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); | 943 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); |
| 929 } | 944 } |
| 930 return GetWindowBoundsInScreen(); | 945 return GetWindowBoundsInScreen(); |
| 931 } | 946 } |
| 932 | 947 |
| 933 std::string NativeWidgetMus::GetWorkspace() const { | 948 std::string NativeWidgetMus::GetWorkspace() const { |
| 934 return std::string(); | 949 return std::string(); |
| 935 } | 950 } |
| 936 | 951 |
| 937 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) { | 952 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds_in_screen) { |
|
sky
2016/09/08 23:52:56
Rename arg in header to match.
James Cook
2016/09/09 03:55:36
Done.
| |
| 938 if (!(window_ && window_tree_host_)) | 953 if (!(window_ && window_tree_host_)) |
| 939 return; | 954 return; |
| 940 | 955 |
| 941 gfx::Size size(bounds.size()); | 956 // TODO(jamescook): Needs something like aura::ScreenPositionClient so higher |
| 957 // level code can move windows between displays. crbug.com/645291 | |
| 958 gfx::Point origin(bounds_in_screen.origin()); | |
| 959 const gfx::Point display_origin = display::Screen::GetScreen() | |
| 960 ->GetDisplayMatching(bounds_in_screen) | |
| 961 .bounds() | |
| 962 .origin(); | |
| 963 origin.Offset(-display_origin.x(), -display_origin.y()); | |
| 964 | |
| 965 gfx::Size size(bounds_in_screen.size()); | |
| 942 const gfx::Size min_size = GetMinimumSize(); | 966 const gfx::Size min_size = GetMinimumSize(); |
| 943 const gfx::Size max_size = GetMaximumSize(); | 967 const gfx::Size max_size = GetMaximumSize(); |
| 944 if (!max_size.IsEmpty()) | 968 if (!max_size.IsEmpty()) |
| 945 size.SetToMin(max_size); | 969 size.SetToMin(max_size); |
| 946 size.SetToMax(min_size); | 970 size.SetToMax(min_size); |
| 947 window_->SetBounds(gfx::Rect(bounds.origin(), size)); | 971 window_->SetBounds(gfx::Rect(origin, size)); |
| 948 // Observer on |window_tree_host_| expected to synchronously update bounds. | 972 // Observer on |window_tree_host_| expected to synchronously update bounds. |
| 949 DCHECK(window_->bounds() == window_tree_host_->GetBounds()); | 973 DCHECK(window_->bounds() == window_tree_host_->GetBounds()); |
| 950 } | 974 } |
| 951 | 975 |
| 952 void NativeWidgetMus::SetSize(const gfx::Size& size) { | 976 void NativeWidgetMus::SetSize(const gfx::Size& size) { |
| 953 if (!window_tree_host_) | 977 if (!window_tree_host_) |
| 954 return; | 978 return; |
| 955 | 979 |
| 956 gfx::Rect bounds = window_tree_host_->GetBounds(); | 980 gfx::Rect bounds = window_tree_host_->GetBounds(); |
| 957 SetBounds(gfx::Rect(bounds.origin(), size)); | 981 SetBounds(gfx::Rect(bounds.origin(), size)); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1437 | 1461 |
| 1438 gfx::Path mask_path; | 1462 gfx::Path mask_path; |
| 1439 native_widget_delegate_->GetHitTestMask(&mask_path); | 1463 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1440 // TODO(jamescook): Use the full path for the mask. | 1464 // TODO(jamescook): Use the full path for the mask. |
| 1441 gfx::Rect mask_rect = | 1465 gfx::Rect mask_rect = |
| 1442 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1466 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1443 window_->SetHitTestMask(mask_rect); | 1467 window_->SetHitTestMask(mask_rect); |
| 1444 } | 1468 } |
| 1445 | 1469 |
| 1446 } // namespace views | 1470 } // namespace views |
| OLD | NEW |