Commit aecdb0fb authored by sky's avatar sky Committed by Commit bot

Wires up WmWindowMus::SetBoundsInScreen()

As part of this I realized SetLockedToRoot and
SetDescendantsStayInSameRootWindow meant the same thing, so I nuked
the later.

In order to test this I need multiple display support, which isn't
quite working yet (in particular shutdown is currently
problematic).

BUG=615552
TEST=none
R=jamescook@chromium.org

Review-Url: https://codereview.chromium.org/2344783002
Cr-Commit-Position: refs/heads/master@{#419010}
parent b9101874
......@@ -26,6 +26,7 @@
#include "ash/wm/window_util.h"
#include "base/memory/ptr_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window.h"
......@@ -374,7 +375,7 @@ void WmWindowAura::AddChild(WmWindow* window) {
window_->AddChild(GetAuraWindow(window));
}
WmWindow* WmWindowAura::GetParent() {
const WmWindow* WmWindowAura::GetParent() const {
return Get(window_->parent());
}
......@@ -557,7 +558,11 @@ void WmWindowAura::SetRestoreOverrides(
}
void WmWindowAura::SetLockedToRoot(bool value) {
window_->SetProperty(kStayInSameRootWindowKey, value);
window_->SetProperty(kLockedToRootKey, value);
}
bool WmWindowAura::IsLockedToRoot() const {
return window_->GetProperty(kLockedToRootKey);
}
void WmWindowAura::SetCapture() {
......@@ -633,6 +638,10 @@ void WmWindowAura::CloseWidget() {
GetInternalWidget()->Close();
}
void WmWindowAura::SetFocused() {
aura::client::GetFocusClient(window_)->FocusWindow(window_);
}
bool WmWindowAura::IsFocused() const {
return window_->HasFocus();
}
......@@ -726,10 +735,6 @@ void WmWindowAura::SetChildrenUseExtendedHitRegion() {
window_, mouse_extend, touch_extend));
}
void WmWindowAura::SetDescendantsStayInSameRootWindow(bool value) {
window_->SetProperty(kStayInSameRootWindowKey, true);
}
std::unique_ptr<views::View> WmWindowAura::CreateViewWithRecreatedLayers() {
return base::MakeUnique<wm::WindowMirrorView>(this);
}
......
......@@ -92,7 +92,7 @@ class ASH_EXPORT WmWindowAura : public WmWindow,
void SetParentUsingContext(WmWindow* context,
const gfx::Rect& screen_bounds) override;
void AddChild(WmWindow* window) override;
WmWindow* GetParent() override;
const WmWindow* GetParent() const override;
const WmWindow* GetTransientParent() const override;
std::vector<WmWindow*> GetTransientChildren() override;
void SetLayoutManager(
......@@ -129,6 +129,7 @@ class ASH_EXPORT WmWindowAura : public WmWindow,
void SetRestoreOverrides(const gfx::Rect& bounds_override,
ui::WindowShowState window_state_override) override;
void SetLockedToRoot(bool value) override;
bool IsLockedToRoot() const override;
void SetCapture() override;
bool HasCapture() override;
void ReleaseCapture() override;
......@@ -147,6 +148,7 @@ class ASH_EXPORT WmWindowAura : public WmWindow,
void Show() override;
views::Widget* GetInternalWidget() override;
void CloseWidget() override;
void SetFocused() override;
bool IsFocused() const override;
bool IsActive() const override;
void Activate() override;
......@@ -166,7 +168,6 @@ class ASH_EXPORT WmWindowAura : public WmWindow,
void SetSnapsChildrenToPhysicalPixelBoundary() override;
void SnapToPixelBoundaryIfNecessary() override;
void SetChildrenUseExtendedHitRegion() override;
void SetDescendantsStayInSameRootWindow(bool value) override;
std::unique_ptr<views::View> CreateViewWithRecreatedLayers() override;
void AddObserver(WmWindowObserver* observer) override;
void RemoveObserver(WmWindowObserver* observer) override;
......
......@@ -6,10 +6,16 @@
#include <algorithm>
#include "ash/common/wm/system_modal_container_layout_manager.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm/wm_event.h"
#include "ash/common/wm/wm_screen_util.h"
#include "ash/common/wm_lookup.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
#include "ash/common/wm_window_tracker.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
......@@ -29,6 +35,38 @@ int GetDefaultSnappedWindowWidth(WmWindow* window) {
return std::min(work_area_width, std::max(ideal_width, min_width));
}
// Return true if the window or one of its ancestor returns true from
// IsLockedToRoot().
bool IsWindowOrAncestorLockedToRoot(const WmWindow* window) {
return window && (window->IsLockedToRoot() ||
IsWindowOrAncestorLockedToRoot(window->GetParent()));
}
// Move all transient children to |dst_root|, including the ones in
// the child windows and transient children of the transient children.
void MoveAllTransientChildrenToNewRoot(const display::Display& display,
WmWindow* window) {
WmWindow* dst_root = WmLookup::Get()
->GetRootWindowControllerWithDisplayId(display.id())
->GetWindow();
for (WmWindow* transient_child : window->GetTransientChildren()) {
const int container_id = transient_child->GetParent()->GetShellWindowId();
DCHECK_GE(container_id, 0);
WmWindow* container = dst_root->GetChildByShellWindowId(container_id);
const gfx::Rect transient_child_bounds_in_screen =
transient_child->GetBoundsInScreen();
container->AddChild(transient_child);
transient_child->SetBoundsInScreen(transient_child_bounds_in_screen,
display);
// Transient children may have transient children.
MoveAllTransientChildrenToNewRoot(display, transient_child);
}
// Move transient children of the child windows if any.
for (WmWindow* child : window->GetChildren())
MoveAllTransientChildrenToNewRoot(display, child);
}
} // namespace
void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
......@@ -87,5 +125,77 @@ void CenterWindow(WmWindow* window) {
window->GetWindowState()->OnWMEvent(&event);
}
void SetBoundsInScreen(WmWindow* window,
const gfx::Rect& bounds_in_screen,
const display::Display& display) {
DCHECK_NE(display::Display::kInvalidDisplayID, display.id());
// Don't move a window to other root window if:
// a) the window is a transient window. It moves when its
// transient parent moves.
// b) if the window or its ancestor has IsLockedToRoot(). It's intentionally
// kept in the same root window even if the bounds is outside of the
// display.
if (!window->GetTransientParent() &&
!IsWindowOrAncestorLockedToRoot(window)) {
WmRootWindowController* dst_root_window_controller =
WmLookup::Get()->GetRootWindowControllerWithDisplayId(display.id());
DCHECK(dst_root_window_controller);
WmWindow* dst_root = dst_root_window_controller->GetWindow();
DCHECK(dst_root);
WmWindow* dst_container = nullptr;
if (dst_root != window->GetRootWindow()) {
int container_id = window->GetParent()->GetShellWindowId();
// All containers that uses screen coordinates must have valid window ids.
DCHECK_GE(container_id, 0);
// Don't move modal background.
if (!SystemModalContainerLayoutManager::IsModalBackground(window))
dst_container = dst_root->GetChildByShellWindowId(container_id);
}
if (dst_container && window->GetParent() != dst_container) {
WmWindow* focused = WmShell::Get()->GetFocusedWindow();
WmWindow* active = WmShell::Get()->GetActiveWindow();
WmWindowTracker tracker;
if (focused)
tracker.Add(focused);
if (active && focused != active)
tracker.Add(active);
gfx::Point origin = bounds_in_screen.origin();
const gfx::Point display_origin = display.bounds().origin();
origin.Offset(-display_origin.x(), -display_origin.y());
gfx::Rect new_bounds = gfx::Rect(origin, bounds_in_screen.size());
// Set new bounds now so that the container's layout manager can adjust
// the bounds if necessary.
window->SetBounds(new_bounds);
dst_container->AddChild(window);
MoveAllTransientChildrenToNewRoot(display, window);
// Restore focused/active window.
if (tracker.Contains(focused)) {
focused->SetFocused();
WmShell::Get()->set_root_window_for_new_windows(
focused->GetRootWindow());
} else if (tracker.Contains(active)) {
active->Activate();
}
// TODO(oshima): We should not have to update the bounds again
// below in theory, but we currently do need as there is a code
// that assumes that the bounds will never be overridden by the
// layout mananger. We should have more explicit control how
// constraints are applied by the layout manager.
}
}
gfx::Point origin(bounds_in_screen.origin());
const gfx::Point display_origin =
window->GetDisplayNearestWindow().bounds().origin();
origin.Offset(-display_origin.x(), -display_origin.y());
window->SetBounds(gfx::Rect(origin, bounds_in_screen.size()));
}
} // namespace wm
} // namespace ash
......@@ -7,6 +7,10 @@
#include "ash/ash_export.h"
namespace display {
class Display;
}
namespace gfx {
class Rect;
class Size;
......@@ -54,6 +58,12 @@ ASH_EXPORT gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(
// Moves the window to the center of the display.
ASH_EXPORT void CenterWindow(WmWindow* window);
// Sets the bounds of |window| to |bounds_in_screen|. This may move |window|
// to |display| if necessary.
ASH_EXPORT void SetBoundsInScreen(WmWindow* window,
const gfx::Rect& bounds_in_screen,
const display::Display& display);
} // namespace wm
} // namespace ash
......
......@@ -208,7 +208,7 @@ void WmRootWindowController::CreateContainers() {
shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
shelf_container->SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
shelf_container->SetDescendantsStayInSameRootWindow(true);
shelf_container->SetLockedToRoot(true);
WmWindow* panel_container =
CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
......@@ -223,7 +223,7 @@ void WmRootWindowController::CreateContainers() {
shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
shelf_bubble_container->SetDescendantsStayInSameRootWindow(true);
shelf_bubble_container->SetLockedToRoot(true);
WmWindow* app_list_container =
CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
......@@ -266,7 +266,7 @@ void WmRootWindowController::CreateContainers() {
status_container->SetSnapsChildrenToPhysicalPixelBoundary();
status_container->SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
status_container->SetDescendantsStayInSameRootWindow(true);
status_container->SetLockedToRoot(true);
WmWindow* settings_bubble_container =
CreateContainer(kShellWindowId_SettingBubbleContainer,
......@@ -275,7 +275,7 @@ void WmRootWindowController::CreateContainers() {
settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
settings_bubble_container->SetDescendantsStayInSameRootWindow(true);
settings_bubble_container->SetLockedToRoot(true);
WmWindow* virtual_keyboard_parent_container = CreateContainer(
kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
......
......@@ -155,7 +155,11 @@ class ASH_EXPORT WmWindow {
const gfx::Rect& screen_bounds) = 0;
virtual void AddChild(WmWindow* window) = 0;
virtual WmWindow* GetParent() = 0;
WmWindow* GetParent() {
return const_cast<WmWindow*>(
const_cast<const WmWindow*>(this)->GetParent());
}
virtual const WmWindow* GetParent() const = 0;
WmWindow* GetTransientParent() {
return const_cast<WmWindow*>(
......@@ -200,7 +204,7 @@ class ASH_EXPORT WmWindow {
// This is the default.
// USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted
// from the display. In this case the window may move to a different
// display if allowed (see SetDescendantsStayInSameRootWindow()).
// display if allowed (see SetLockedToRoot()).
virtual void SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
const display::Display& dst_display) = 0;
virtual gfx::Rect GetBoundsInScreen() const = 0;
......@@ -228,6 +232,7 @@ class ASH_EXPORT WmWindow {
// If |value| is true the window can not be moved to another root, regardless
// of the bounds set on it.
virtual void SetLockedToRoot(bool value) = 0;
virtual bool IsLockedToRoot() const = 0;
virtual void SetCapture() = 0;
virtual bool HasCapture() = 0;
......@@ -250,6 +255,7 @@ class ASH_EXPORT WmWindow {
// forward to an associated widget.
virtual void CloseWidget() = 0;
virtual void SetFocused() = 0;
virtual bool IsFocused() const = 0;
virtual bool IsActive() const = 0;
......@@ -299,10 +305,6 @@ class ASH_EXPORT WmWindow {
// Makes the hit region for children slightly larger for easier resizing.
virtual void SetChildrenUseExtendedHitRegion() = 0;
// Sets whether descendants of this should not be moved to a different
// container. This is used by SetBoundsInScreen().
virtual void SetDescendantsStayInSameRootWindow(bool value) = 0;
// Returns a View that renders the contents of this window's layers.
virtual std::unique_ptr<views::View> CreateViewWithRecreatedLayers() = 0;
......
......@@ -6,7 +6,7 @@
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/wm/system_modal_container_layout_manager.h"
#include "ash/common/wm/window_positioning_utils.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
......@@ -27,44 +27,6 @@
#include "ui/wm/public/activation_client.h"
namespace ash {
namespace {
// Return true if the window or its ancestor has |kStayInSameRootWindowkey|
// property.
bool ShouldStayInSameRootWindow(const aura::Window* window) {
return window && (window->GetProperty(kStayInSameRootWindowKey) ||
ShouldStayInSameRootWindow(window->parent()));
}
// Move all transient children to |dst_root|, including the ones in
// the child windows and transient children of the transient children.
void MoveAllTransientChildrenToNewRoot(const display::Display& display,
aura::Window* window) {
aura::Window* dst_root = Shell::GetInstance()
->window_tree_host_manager()
->GetRootWindowForDisplayId(display.id());
aura::Window::Windows transient_children = ::wm::GetTransientChildren(window);
for (aura::Window::Windows::iterator iter = transient_children.begin();
iter != transient_children.end(); ++iter) {
aura::Window* transient_child = *iter;
int container_id = transient_child->parent()->id();
DCHECK_GE(container_id, 0);
aura::Window* container = Shell::GetContainer(dst_root, container_id);
gfx::Rect parent_bounds_in_screen = transient_child->GetBoundsInScreen();
container->AddChild(transient_child);
transient_child->SetBoundsInScreen(parent_bounds_in_screen, display);
// Transient children may have transient children.
MoveAllTransientChildrenToNewRoot(display, transient_child);
}
// Move transient children of the child windows if any.
aura::Window::Windows children = window->children();
for (aura::Window::Windows::iterator iter = children.begin();
iter != children.end(); ++iter)
MoveAllTransientChildrenToNewRoot(display, *iter);
}
} // namespace
// static
void ScreenPositionController::ConvertHostPointToRelativeToRootWindow(
......@@ -157,84 +119,12 @@ void ScreenPositionController::ConvertHostPointToScreen(
void ScreenPositionController::SetBounds(aura::Window* window,
const gfx::Rect& bounds,
const display::Display& display) {
DCHECK_NE(-1, display.id());
if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) {
window->SetBounds(bounds);
return;
}
// Don't move a window to other root window if:
// a) the window is a transient window. It moves when its
// transient_parent moves.
// b) if the window or its ancestor has kStayInSameRootWindowkey. It's
// intentionally kept in the same root window even if the bounds is
// outside of the display.
if (!::wm::GetTransientParent(window) &&
!ShouldStayInSameRootWindow(window)) {
aura::Window* dst_root = Shell::GetInstance()
->window_tree_host_manager()
->GetRootWindowForDisplayId(display.id());
DCHECK(dst_root);
aura::Window* dst_container = NULL;
if (dst_root != window->GetRootWindow()) {
int container_id = window->parent()->id();
// All containers that uses screen coordinates must have valid window ids.
DCHECK_GE(container_id, 0);
// Don't move modal background.
if (!SystemModalContainerLayoutManager::IsModalBackground(
WmWindowAura::Get(window)))
dst_container = Shell::GetContainer(dst_root, container_id);
}
if (dst_container && window->parent() != dst_container) {
aura::Window* focused =
aura::client::GetFocusClient(window)->GetFocusedWindow();
aura::client::ActivationClient* activation_client =
aura::client::GetActivationClient(window->GetRootWindow());
aura::Window* active = activation_client->GetActiveWindow();
aura::WindowTracker tracker;
if (focused)
tracker.Add(focused);
if (active && focused != active)
tracker.Add(active);
// Set new bounds now so that the container's layout manager
// can adjust the bounds if necessary.
gfx::Point origin = bounds.origin();
const gfx::Point display_origin = display.bounds().origin();
origin.Offset(-display_origin.x(), -display_origin.y());
gfx::Rect new_bounds = gfx::Rect(origin, bounds.size());
window->SetBounds(new_bounds);
dst_container->AddChild(window);
MoveAllTransientChildrenToNewRoot(display, window);
// Restore focused/active window.
if (tracker.Contains(focused)) {
aura::client::GetFocusClient(window)->FocusWindow(focused);
// TODO(beng): replace with GetRootWindow().
WmShell::Get()->set_root_window_for_new_windows(
WmWindowAura::Get(focused->GetRootWindow()));
} else if (tracker.Contains(active)) {
activation_client->ActivateWindow(active);
}
// TODO(oshima): We should not have to update the bounds again
// below in theory, but we currently do need as there is a code
// that assumes that the bounds will never be overridden by the
// layout mananger. We should have more explicit control how
// constraints are applied by the layout manager.
}
}
gfx::Point origin(bounds.origin());
const gfx::Point display_origin = display::Screen::GetScreen()
->GetDisplayNearestWindow(window)
.bounds()
.origin();
origin.Offset(-display_origin.x(), -display_origin.y());
window->SetBounds(gfx::Rect(origin, bounds.size()));
wm::SetBoundsInScreen(WmWindowAura::Get(window), bounds, display);
}
} // namespace ash
......@@ -800,14 +800,13 @@ TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
w1->SetBounds(gfx::Rect(150, 10, 50, 50));
EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
// The widget stays in the same root if kStayInSameRootWindowKey is set to
// true.
w1->GetNativeView()->SetProperty(kStayInSameRootWindowKey, true);
// The widget stays in the same root if kLockedToRootKey is set to true.
w1->GetNativeView()->SetProperty(kLockedToRootKey, true);
w1->SetBounds(gfx::Rect(10, 10, 50, 50));
EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
// The widget should now move to the 1st root window without the property.
w1->GetNativeView()->ClearProperty(kStayInSameRootWindowKey);
w1->GetNativeView()->ClearProperty(kLockedToRootKey);
w1->SetBounds(gfx::Rect(10, 10, 50, 50));
EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
......
......@@ -5,6 +5,7 @@
#include "ash/mus/bridge/wm_window_mus.h"
#include "ash/common/wm/container_finder.h"
#include "ash/common/wm/window_positioning_utils.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_layout_manager.h"
#include "ash/common/wm_transient_window_observer.h"
......@@ -114,15 +115,16 @@ WmWindowMus::~WmWindowMus() {
}
// static
WmWindowMus* WmWindowMus::Get(ui::Window* window) {
const WmWindowMus* WmWindowMus::Get(const ui::Window* window) {
if (!window)
return nullptr;
WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey);
const WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey);
if (wm_window)
return wm_window;
// WmWindowMus is owned by the ui::Window.
return new WmWindowMus(window);
// Unfortunately there isn't a good way to avoid the cast here.
return new WmWindowMus(const_cast<ui::Window*>(window));
}
// static
......@@ -442,7 +444,7 @@ void WmWindowMus::AddChild(WmWindow* window) {
window_->AddChild(GetMusWindow(window));
}
WmWindow* WmWindowMus::GetParent() {
const WmWindow* WmWindowMus::GetParent() const {
return Get(window_->parent());
}
......@@ -549,10 +551,14 @@ void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) {
void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
const display::Display& dst_display) {
// TODO: SetBoundsInScreen isn't fully implemented yet,
// http://crbug.com/615552.
NOTIMPLEMENTED();
SetBounds(ConvertRectFromScreen(bounds_in_screen));
DCHECK(GetParent()); // Aura code assumed a parent, so this does too.
if (static_cast<const WmWindowMus*>(GetParent())
->child_bounds_in_screen_behavior_ ==
BoundsInScreenBehavior::USE_LOCAL_COORDINATES) {
SetBounds(bounds_in_screen);
return;
}
wm::SetBoundsInScreen(this, bounds_in_screen, dst_display);
}
gfx::Rect WmWindowMus::GetBoundsInScreen() const {
......@@ -608,8 +614,11 @@ void WmWindowMus::SetRestoreOverrides(
}
void WmWindowMus::SetLockedToRoot(bool value) {
// TODO(sky): there is no getter for this. Investigate where used.
NOTIMPLEMENTED();
locked_to_root_ = value;
}
bool WmWindowMus::IsLockedToRoot() const {
return locked_to_root_;
}
void WmWindowMus::SetCapture() {
......@@ -701,6 +710,10 @@ void WmWindowMus::CloseWidget() {
widget_->Close();
}
void WmWindowMus::SetFocused() {
window_->SetFocus();
}
bool WmWindowMus::IsFocused() const {
return window_->HasFocus();
}
......@@ -780,9 +793,7 @@ void WmWindowMus::InstallResizeHandleWindowTargeter(
void WmWindowMus::SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior behavior) {
// TODO: SetBoundsInScreen isn't fully implemented yet,
// http://crbug.com/615552.
NOTIMPLEMENTED();
child_bounds_in_screen_behavior_ = behavior;
}
void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() {
......@@ -808,12 +819,6 @@ void WmWindowMus::SetChildrenUseExtendedHitRegion() {
children_use_extended_hit_region_ = true;
}
void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) {
// TODO: this logic feeds into SetBoundsInScreen(), which is not implemented:
// http://crbug.com/615552.
NOTIMPLEMENTED();
}
std::unique_ptr<views::View> WmWindowMus::CreateViewWithRecreatedLayers() {
// TODO: need real implementation, http://crbug.com/629497.
std::unique_ptr<views::View> view(new views::View);
......
......@@ -57,7 +57,10 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
~WmWindowMus() override;
// Returns a WmWindow for an ui::Window, creating if necessary.
static WmWindowMus* Get(ui::Window* window);
static WmWindowMus* Get(ui::Window* window) {
return const_cast<WmWindowMus*>(Get(const_cast<const ui::Window*>(window)));
}
static const WmWindowMus* Get(const ui::Window* window);
static WmWindowMus* Get(views::Widget* widget);
......@@ -153,7 +156,7 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
void SetParentUsingContext(WmWindow* context,
const gfx::Rect& screen_bounds) override;
void AddChild(WmWindow* window) override;
WmWindow* GetParent() override;
const WmWindow* GetParent() const override;
const WmWindow* GetTransientParent() const override;
std::vector<WmWindow*> GetTransientChildren() override;
void SetLayoutManager(
......@@ -190,6 +193,7 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
void SetRestoreOverrides(const gfx::Rect& bounds_override,
ui::WindowShowState window_state_override) override;
void SetLockedToRoot(bool value) override;
bool IsLockedToRoot() const override;
void SetCapture() override;
bool HasCapture() override;
void ReleaseCapture() override;
......@@ -200,6 +204,7 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
void Show() override;
views::Widget* GetInternalWidget() override;
void CloseWidget() override;
void SetFocused() override;
bool IsFocused() const override;
bool IsActive() const override;
void Activate() override;
......@@ -227,7 +232,6 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
void SetSnapsChildrenToPhysicalPixelBoundary() override;
void SnapToPixelBoundaryIfNecessary() override;
void SetChildrenUseExtendedHitRegion() override;
void SetDescendantsStayInSameRootWindow(bool value) override;
std::unique_ptr<views::View> CreateViewWithRecreatedLayers() override;
void AddObserver(WmWindowObserver* observer) override;
void RemoveObserver(WmWindowObserver* observer) override;
......@@ -297,6 +301,11 @@ class WmWindowMus : public WmWindow, public ui::WindowObserver {
// Set to true if set_window_type() is called.
bool is_wm_window_type_set_ = false;
BoundsInScreenBehavior child_bounds_in_screen_behavior_ =
BoundsInScreenBehavior::USE_LOCAL_COORDINATES;
bool locked_to_root_ = false;
DISALLOW_COPY_AND_ASSIGN(WmWindowMus);
};
......
......@@ -11,6 +11,8 @@ DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WindowState*);
namespace ash {
DEFINE_WINDOW_PROPERTY_KEY(bool, kLockedToRootKey, false);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsOverrideKey, NULL);
DEFINE_WINDOW_PROPERTY_KEY(ui::WindowShowState,
......@@ -19,8 +21,6 @@ DEFINE_WINDOW_PROPERTY_KEY(ui::WindowShowState,
DEFINE_WINDOW_PROPERTY_KEY(bool, kSnapChildrenToPixelBoundary, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kStayInSameRootWindowKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kUsesScreenCoordinatesKey, false);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(wm::WindowState, kWindowStateKey, NULL);
......
......@@ -25,6 +25,11 @@ class WindowState;
// Alphabetical sort.
// If this is set to true, the window stays in the same root window even if the
// bounds outside of its root window is set.
// This is exported as it's used in the tests.
ASH_EXPORT extern const aura::WindowProperty<bool>* const kLockedToRootKey;
// A property key which stores the bounds to restore a window to. These take
// preference over the current bounds/state. This is used by e.g. the always
// maximized mode window manager.
......@@ -41,12 +46,6 @@ ASH_EXPORT extern const aura::WindowProperty<ui::WindowShowState>* const
// boundary.
extern const aura::WindowProperty<bool>* const kSnapChildrenToPixelBoundary;
// If this is set to true, the window stays in the same root window
// even if the bounds outside of its root window is set.
// This is exported as it's used in the tests.
ASH_EXPORT extern const aura::WindowProperty<bool>* const
kStayInSameRootWindowKey;
// Property to tell if the container uses the screen coordinates.
extern const aura::WindowProperty<bool>* const kUsesScreenCoordinatesKey;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment