1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/wm/property_util.h"
6
7#include "ash/ash_export.h"
8#include "ash/screen_ash.h"
9#include "ash/wm/window_properties.h"
10#include "ash/wm/window_util.h"
11#include "ui/aura/client/aura_constants.h"
12#include "ui/aura/root_window.h"
13#include "ui/aura/window.h"
14#include "ui/base/ui_base_types.h"
15#include "ui/gfx/rect.h"
16
17namespace ash {
18
19void SetRestoreBoundsInScreen(aura::Window* window, const gfx::Rect& bounds) {
20  window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
21}
22
23void SetRestoreBoundsInParent(aura::Window* window, const gfx::Rect& bounds) {
24  SetRestoreBoundsInScreen(window,
25      ScreenAsh::ConvertRectToScreen(window->parent(), bounds));
26}
27
28const gfx::Rect* GetRestoreBoundsInScreen(aura::Window* window) {
29  return window->GetProperty(aura::client::kRestoreBoundsKey);
30}
31
32gfx::Rect GetRestoreBoundsInParent(aura::Window* window) {
33  const gfx::Rect* rect = GetRestoreBoundsInScreen(window);
34  if (!rect)
35    return gfx::Rect();
36  return ScreenAsh::ConvertRectFromScreen(window->parent(), *rect);
37}
38
39void ClearRestoreBounds(aura::Window* window) {
40  window->ClearProperty(aura::client::kRestoreBoundsKey);
41}
42
43void SetTrackedByWorkspace(aura::Window* window, bool value) {
44  window->SetProperty(internal::kWindowTrackedByWorkspaceKey, value);
45}
46
47bool GetTrackedByWorkspace(const aura::Window* window) {
48  return window->GetProperty(internal::kWindowTrackedByWorkspaceKey);
49}
50
51void SetIgnoredByShelf(aura::Window* window, bool value) {
52  window->SetProperty(internal::kIgnoredByShelfKey, value);
53}
54
55bool GetIgnoredByShelf(const aura::Window* window) {
56  return window->GetProperty(internal::kIgnoredByShelfKey);
57}
58
59void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value) {
60  window->SetProperty(internal::kWindowRestoresToRestoreBounds, value);
61}
62
63bool GetWindowAlwaysRestoresToRestoreBounds(const aura::Window* window) {
64  return window->GetProperty(internal::kWindowRestoresToRestoreBounds);
65}
66
67internal::RootWindowController* GetRootWindowController(
68    const aura::RootWindow* root_window) {
69  return root_window ?
70      root_window->GetProperty(internal::kRootWindowControllerKey) : NULL;
71}
72
73void SetRootWindowController(aura::RootWindow* root_window,
74                             internal::RootWindowController* controller) {
75  root_window->SetProperty(internal::kRootWindowControllerKey, controller);
76}
77
78}  // namespace ash
79