Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: mash/wm/window_layout.cc

Issue 1954933002: Initial cut of ash/wm/common classes for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WmWindowMus::GetGlobals Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/presentation windows should be sized to the bounds
James Cook 2016/05/06 19:46:47 nit: presentation doesn't exist now
sky 2016/05/06 22:12:57 Done.
29 // of the container. 29 // of the 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::MAXIMIZED: 38 case mus::mojom::ShowState::MAXIMIZED:
39 case mus::mojom::ShowState::IMMERSIVE: 39 case mus::mojom::ShowState::FULLSCREEN:
40 case mus::mojom::ShowState::PRESENTATION:
41 FitToContainer(window); 40 FitToContainer(window);
42 break; 41 break;
43 case mus::mojom::ShowState::RESTORED: { 42 case mus::mojom::ShowState::DOCKED:
43 case mus::mojom::ShowState::INACTIVE:
44 case mus::mojom::ShowState::DEFAULT:
45 case mus::mojom::ShowState::NORMAL: {
James Cook 2016/05/06 19:46:47 nit: order these either alphabetically, or in the
sky 2016/05/06 22:12:57 Done.
44 if (!user_set_bounds.IsEmpty()) { 46 if (!user_set_bounds.IsEmpty()) {
45 // If the bounds are unchanged, this will do nothing. 47 // If the bounds are unchanged, this will do nothing.
46 window->SetBounds(user_set_bounds); 48 window->SetBounds(user_set_bounds);
47 } else if (!preferred_size.IsEmpty()) { 49 } else if (!preferred_size.IsEmpty()) {
48 CenterWindow(window, preferred_size); 50 CenterWindow(window, preferred_size);
James Cook 2016/05/06 19:46:47 Do we want to center docked windows? Or will they
sky 2016/05/06 22:12:57 This code won't end up being used for docked windo
49 } 51 }
50 } 52 }
51 case mus::mojom::ShowState::MINIMIZED: 53 case mus::mojom::ShowState::MINIMIZED:
52 break; 54 break;
53 default: 55 default:
54 NOTREACHED(); 56 NOTREACHED();
55 break; 57 break;
56 } 58 }
57 } 59 }
58 60
(...skipping 20 matching lines...) Expand all
79 const gfx::Size& preferred_size) { 81 const gfx::Size& preferred_size) {
80 const gfx::Rect bounds( 82 const gfx::Rect bounds(
81 (owner()->bounds().width() - preferred_size.width()) / 2, 83 (owner()->bounds().width() - preferred_size.width()) / 2,
82 (owner()->bounds().height() - preferred_size.height()) / 2, 84 (owner()->bounds().height() - preferred_size.height()) / 2,
83 preferred_size.width(), preferred_size.height()); 85 preferred_size.width(), preferred_size.height());
84 window->SetBounds(bounds); 86 window->SetBounds(bounds);
85 } 87 }
86 88
87 } // namespace wm 89 } // namespace wm
88 } // namespace mash 90 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698