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

Unified Diff: mash/wm/window_layout.cc

Issue 1994763002: Wires up WorkspaceLayoutManager in mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: data deps 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mash/wm/window_layout.h ('k') | mash/wm/window_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/wm/window_layout.cc
diff --git a/mash/wm/window_layout.cc b/mash/wm/window_layout.cc
deleted file mode 100644
index bd374a1172e07f68d14eaeb536f291e68916b8f6..0000000000000000000000000000000000000000
--- a/mash/wm/window_layout.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mash/wm/window_layout.h"
-
-#include <stdint.h>
-
-#include "components/mus/public/cpp/property_type_converters.h"
-#include "components/mus/public/cpp/window.h"
-#include "components/mus/public/cpp/window_property.h"
-#include "mash/wm/property_util.h"
-
-namespace mash {
-namespace wm {
-
-WindowLayout::WindowLayout(mus::Window* owner) : LayoutManager(owner) {
- AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
- AddLayoutProperty(mus::mojom::WindowManager::kShowState_Property);
-}
-WindowLayout::~WindowLayout() {}
-
-void WindowLayout::LayoutWindow(mus::Window* window) {
- mus::mojom::ShowState show_state = GetWindowShowState(window);
- gfx::Rect user_set_bounds = GetWindowUserSetBounds(window);
- gfx::Size preferred_size = GetWindowPreferredSize(window);
-
- // Maximized/fullscreen windows should be sized to the bounds of the
- // container.
- // If a window has bounds set by the user, those should be respected as long
- // as they meet certain constraints (e.g. visible).
- // TODO(beng): transient windows:
- // Top level non-transient windows with no bounds but a preferred size should
- // opened centered within the work area.
- // Transient windows should be opened centered within their parent.
-
- switch (show_state) {
- case mus::mojom::ShowState::FULLSCREEN:
- case mus::mojom::ShowState::MAXIMIZED:
- FitToContainer(window);
- break;
-
- case mus::mojom::ShowState::DEFAULT:
- case mus::mojom::ShowState::DOCKED:
- case mus::mojom::ShowState::INACTIVE:
- case mus::mojom::ShowState::NORMAL: {
- if (!user_set_bounds.IsEmpty()) {
- // If the bounds are unchanged, this will do nothing.
- window->SetBounds(user_set_bounds);
- } else if (!preferred_size.IsEmpty()) {
- CenterWindow(window, preferred_size);
- }
- }
- case mus::mojom::ShowState::MINIMIZED:
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
-void WindowLayout::OnWindowSharedPropertyChanged(
- mus::Window* window,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) {
- // TODO(sky): this feels like the wrong place for this logic. Find a better
- // place.
- if (name == mus::mojom::WindowManager::kShowState_Property &&
- GetWindowShowState(window) == mus::mojom::ShowState::MAXIMIZED) {
- SetRestoreBounds(window, window->bounds());
- }
- LayoutManager::OnWindowSharedPropertyChanged(window, name, old_data,
- new_data);
-}
-
-void WindowLayout::FitToContainer(mus::Window* window) {
- window->SetBounds(gfx::Rect(owner()->bounds().size()));
-}
-
-void WindowLayout::CenterWindow(mus::Window* window,
- const gfx::Size& preferred_size) {
- const gfx::Rect bounds(
- (owner()->bounds().width() - preferred_size.width()) / 2,
- (owner()->bounds().height() - preferred_size.height()) / 2,
- preferred_size.width(), preferred_size.height());
- window->SetBounds(bounds);
-}
-
-} // namespace wm
-} // namespace mash
« no previous file with comments | « mash/wm/window_layout.h ('k') | mash/wm/window_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698