| 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 "mash/wm/window_layout.h" | 5 #include "mash/wm/window_layout.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
| 10 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
| 11 #include "components/mus/public/cpp/window_property.h" | 11 #include "components/mus/public/cpp/window_property.h" |
| 12 #include "mash/wm/property_util.h" | 12 #include "mash/wm/property_util.h" |
| 13 | 13 |
| 14 namespace mash { | 14 namespace mash { |
| 15 namespace wm { | 15 namespace wm { |
| 16 | 16 |
| 17 WindowLayout::WindowLayout(mus::Window* owner) : LayoutManager(owner) { | 17 WindowLayout::WindowLayout(mus::Window* owner) : LayoutManager(owner) { |
| 18 AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property); | 18 AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property); |
| 19 AddLayoutProperty(mus::mojom::WindowManager::kShowState_Property); | 19 AddLayoutProperty(mus::mojom::WindowManager::kShowState_Property); |
| 20 } | 20 } |
| 21 WindowLayout::~WindowLayout() {} | 21 WindowLayout::~WindowLayout() {} |
| 22 | 22 |
| 23 void WindowLayout::LayoutWindow(mus::Window* window) { | 23 void WindowLayout::LayoutWindow(mus::Window* window) { |
| 24 mus::mojom::ShowState show_state = GetWindowShowState(window); | 24 mus::mojom::ShowState show_state = GetWindowShowState(window); |
| 25 gfx::Rect user_set_bounds = GetWindowUserSetBounds(window); | 25 gfx::Rect user_set_bounds = GetWindowUserSetBounds(window); |
| 26 gfx::Size preferred_size = GetWindowPreferredSize(window); | 26 gfx::Size preferred_size = GetWindowPreferredSize(window); |
| 27 | 27 |
| 28 // Maximized/fullscreen/presentation windows should be sized to the bounds | 28 // Maximized/fullscreen windows should be sized to the bounds of the |
| 29 // of the container. | 29 // container. |
| 30 // If a window has bounds set by the user, those should be respected as long | 30 // If a window has bounds set by the user, those should be respected as long |
| 31 // as they meet certain constraints (e.g. visible). | 31 // as they meet certain constraints (e.g. visible). |
| 32 // TODO(beng): transient windows: | 32 // TODO(beng): transient windows: |
| 33 // Top level non-transient windows with no bounds but a preferred size should | 33 // Top level non-transient windows with no bounds but a preferred size should |
| 34 // opened centered within the work area. | 34 // opened centered within the work area. |
| 35 // Transient windows should be opened centered within their parent. | 35 // Transient windows should be opened centered within their parent. |
| 36 | 36 |
| 37 switch (show_state) { | 37 switch (show_state) { |
| 38 case mus::mojom::ShowState::FULLSCREEN: |
| 38 case mus::mojom::ShowState::MAXIMIZED: | 39 case mus::mojom::ShowState::MAXIMIZED: |
| 39 case mus::mojom::ShowState::IMMERSIVE: | |
| 40 case mus::mojom::ShowState::PRESENTATION: | |
| 41 FitToContainer(window); | 40 FitToContainer(window); |
| 42 break; | 41 break; |
| 43 case mus::mojom::ShowState::RESTORED: { | 42 |
| 43 case mus::mojom::ShowState::DEFAULT: |
| 44 case mus::mojom::ShowState::DOCKED: |
| 45 case mus::mojom::ShowState::INACTIVE: |
| 46 case mus::mojom::ShowState::NORMAL: { |
| 44 if (!user_set_bounds.IsEmpty()) { | 47 if (!user_set_bounds.IsEmpty()) { |
| 45 // If the bounds are unchanged, this will do nothing. | 48 // If the bounds are unchanged, this will do nothing. |
| 46 window->SetBounds(user_set_bounds); | 49 window->SetBounds(user_set_bounds); |
| 47 } else if (!preferred_size.IsEmpty()) { | 50 } else if (!preferred_size.IsEmpty()) { |
| 48 CenterWindow(window, preferred_size); | 51 CenterWindow(window, preferred_size); |
| 49 } | 52 } |
| 50 } | 53 } |
| 51 case mus::mojom::ShowState::MINIMIZED: | 54 case mus::mojom::ShowState::MINIMIZED: |
| 52 break; | 55 break; |
| 53 default: | 56 default: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 79 const gfx::Size& preferred_size) { | 82 const gfx::Size& preferred_size) { |
| 80 const gfx::Rect bounds( | 83 const gfx::Rect bounds( |
| 81 (owner()->bounds().width() - preferred_size.width()) / 2, | 84 (owner()->bounds().width() - preferred_size.width()) / 2, |
| 82 (owner()->bounds().height() - preferred_size.height()) / 2, | 85 (owner()->bounds().height() - preferred_size.height()) / 2, |
| 83 preferred_size.width(), preferred_size.height()); | 86 preferred_size.width(), preferred_size.height()); |
| 84 window->SetBounds(bounds); | 87 window->SetBounds(bounds); |
| 85 } | 88 } |
| 86 | 89 |
| 87 } // namespace wm | 90 } // namespace wm |
| 88 } // namespace mash | 91 } // namespace mash |
| OLD | NEW |