summaryrefslogtreecommitdiffstats
path: root/mash
diff options
context:
space:
mode:
authormsw <msw@chromium.org>2016-02-25 16:26:41 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-26 00:29:10 +0000
commit268e0d997596f3f9a8c514d2eec662bc09597f99 (patch)
treef7374b4be6a6ed60fa36a1543efc41bfe4d38161 /mash
parentbe061845b6b411bc866bd041605120577e3a37ed (diff)
downloadchromium_src-268e0d997596f3f9a8c514d2eec662bc09597f99.zip
chromium_src-268e0d997596f3f9a8c514d2eec662bc09597f99.tar.gz
chromium_src-268e0d997596f3f9a8c514d2eec662bc09597f99.tar.bz2
Fix basic ash shelf layout in mash shell
Support bottom-alignment for the mash shelf and status area. Don't set widget bounds in ash's layout manager for mash. (The mash layout manager sets window bounds instead) Make ShelfDelegateMus::OnShelfCreated set preferred sizes. (needed by the mash shelf layout manager for placement) Add AshWindowType enum and set it as a window property. (needed by the mash shelf layout manager to discern windows) BUG=557406 TEST=mash_shell supports shelf and status area bottom-alignment. R=sky@chromium.org Review URL: https://codereview.chromium.org/1709843003 Cr-Commit-Position: refs/heads/master@{#377727}
Diffstat (limited to 'mash')
-rw-r--r--mash/wm/public/interfaces/BUILD.gn1
-rw-r--r--mash/wm/public/interfaces/ash_window_type.mojom13
-rw-r--r--mash/wm/shelf_layout.cc33
3 files changed, 40 insertions, 7 deletions
diff --git a/mash/wm/public/interfaces/BUILD.gn b/mash/wm/public/interfaces/BUILD.gn
index 65b21b4..5bc2601 100644
--- a/mash/wm/public/interfaces/BUILD.gn
+++ b/mash/wm/public/interfaces/BUILD.gn
@@ -6,6 +6,7 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
+ "ash_window_type.mojom",
"container.mojom",
"user_window_controller.mojom",
]
diff --git a/mash/wm/public/interfaces/ash_window_type.mojom b/mash/wm/public/interfaces/ash_window_type.mojom
new file mode 100644
index 0000000..b4359b3
--- /dev/null
+++ b/mash/wm/public/interfaces/ash_window_type.mojom
@@ -0,0 +1,13 @@
+// Copyright 2016 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.
+
+module mash.wm.mojom;
+
+enum AshWindowType {
+ SHELF = 0,
+ STATUS_AREA,
+ COUNT
+};
+
+const string kAshWindowType_Property = "ash:window-type";
diff --git a/mash/wm/shelf_layout.cc b/mash/wm/shelf_layout.cc
index c2fe1ba..7aa3f9d 100644
--- a/mash/wm/shelf_layout.cc
+++ b/mash/wm/shelf_layout.cc
@@ -8,14 +8,28 @@
#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_property.h"
#include "mash/wm/property_util.h"
+#include "mash/wm/public/interfaces/ash_window_type.mojom.h"
#include "ui/gfx/geometry/rect.h"
namespace mash {
namespace wm {
+namespace {
+
+mojom::AshWindowType GetAshWindowType(const mus::Window* window) {
+ if (!window->HasSharedProperty(mojom::kAshWindowType_Property))
+ return mojom::AshWindowType::COUNT;
+
+ return static_cast<mojom::AshWindowType>(
+ window->GetSharedProperty<int32_t>(mojom::kAshWindowType_Property));
+}
+
+} // namespace
+
ShelfLayout::ShelfLayout(mus::Window* owner) : LayoutManager(owner) {
AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
}
+
ShelfLayout::~ShelfLayout() {}
// We explicitly don't make assertions about the number of children in this
@@ -23,13 +37,18 @@ ShelfLayout::~ShelfLayout() {}
// shelf restarts.
void ShelfLayout::LayoutWindow(mus::Window* window) {
- gfx::Size preferred_size = GetWindowPreferredSize(window);
-
- gfx::Rect container_bounds = owner()->bounds();
- container_bounds.set_origin(
- gfx::Point(0, container_bounds.height() - preferred_size.height()));
- container_bounds.set_height(preferred_size.height());
- window->SetBounds(container_bounds);
+ // TODO(msw): Support additional shelf alignments and RTL UI.
+ const gfx::Size size = GetWindowPreferredSize(window);
+ const int y = owner()->bounds().height() - size.height();
+ const mojom::AshWindowType ash_window_type = GetAshWindowType(window);
+ if (ash_window_type == mojom::AshWindowType::SHELF) {
+ window->SetBounds(gfx::Rect(0, y, size.width(), size.height()));
+ } else if (ash_window_type == mojom::AshWindowType::STATUS_AREA) {
+ window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y,
+ size.width(), size.height()));
+ } else {
+ NOTREACHED() << "Unknown window in USER_SHELF container.";
+ }
}
} // namespace wm