summaryrefslogtreecommitdiffstats
path: root/ash/wm/property_util.cc
blob: 43fabc2b9754c71922b92509cb95d58cdcf63dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) 2012 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 "ash/wm/property_util.h"

#include "ash/ash_export.h"
#include "ash/screen_ash.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/rect.h"

namespace ash {
namespace {
bool g_default_windows_persist_across_all_workspaces = false;
}  // namespace

void SetRestoreBoundsInScreen(aura::Window* window, const gfx::Rect& bounds) {
  window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
}

void SetRestoreBoundsInParent(aura::Window* window, const gfx::Rect& bounds) {
  SetRestoreBoundsInScreen(window,
      ScreenAsh::ConvertRectToScreen(window->parent(), bounds));
}

const gfx::Rect* GetRestoreBoundsInScreen(aura::Window* window) {
  return window->GetProperty(aura::client::kRestoreBoundsKey);
}

gfx::Rect GetRestoreBoundsInParent(aura::Window* window) {
  const gfx::Rect* rect = GetRestoreBoundsInScreen(window);
  if (!rect)
    return gfx::Rect();
  return ScreenAsh::ConvertRectFromScreen(window->parent(), *rect);
}

void ClearRestoreBounds(aura::Window* window) {
  window->ClearProperty(aura::client::kRestoreBoundsKey);
}

void SetTrackedByWorkspace(aura::Window* window, bool value) {
  window->SetProperty(internal::kWindowTrackedByWorkspaceKey, value);
}

bool GetTrackedByWorkspace(const aura::Window* window) {
  return window->GetProperty(internal::kWindowTrackedByWorkspaceKey);
}

void SetIgnoredByShelf(aura::Window* window, bool value) {
  window->SetProperty(internal::kIgnoredByShelfKey, value);
}

bool GetIgnoredByShelf(const aura::Window* window) {
  return window->GetProperty(internal::kIgnoredByShelfKey);
}

void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value) {
  window->SetProperty(internal::kWindowRestoresToRestoreBounds, value);
}

bool GetWindowAlwaysRestoresToRestoreBounds(const aura::Window* window) {
  return window->GetProperty(internal::kWindowRestoresToRestoreBounds);
}

void SetPersistsAcrossAllWorkspaces(
    aura::Window* window,
    WindowPersistsAcrossAllWorkspacesType type) {
  window->SetProperty(
      internal::kWindowPersistsAcrossAllWorkspacesKey, type);
}

bool GetPersistsAcrossAllWorkspaces(aura::Window* window) {
  switch (window->GetProperty(
      internal::kWindowPersistsAcrossAllWorkspacesKey)) {
    case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES:
      return true;
    case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO:
      return false;
    case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT:
      return g_default_windows_persist_across_all_workspaces;
  }
  return false;
}

void SetDefaultPersistsAcrossAllWorkspaces(bool value) {
  g_default_windows_persist_across_all_workspaces = value;
}

internal::RootWindowController* GetRootWindowController(
    aura::RootWindow* root_window) {
  return root_window ?
      root_window->GetProperty(internal::kRootWindowControllerKey) : NULL;
}

void SetRootWindowController(aura::RootWindow* root_window,
                             internal::RootWindowController* controller) {
  root_window->SetProperty(internal::kRootWindowControllerKey, controller);
}

}  // namespace ash