Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / property_util.cc
blobd1240b68154304c65a8b597e9340aca37f0fb64c
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.
5 #include "ash/wm/property_util.h"
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"
17 namespace ash {
18 namespace {
19 bool g_default_windows_persist_across_all_workspaces = false;
20 } // namespace
22 void SetRestoreBoundsInScreen(aura::Window* window, const gfx::Rect& bounds) {
23 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
26 void SetRestoreBoundsInParent(aura::Window* window, const gfx::Rect& bounds) {
27 SetRestoreBoundsInScreen(window,
28 ScreenAsh::ConvertRectToScreen(window->parent(), bounds));
31 const gfx::Rect* GetRestoreBoundsInScreen(aura::Window* window) {
32 return window->GetProperty(aura::client::kRestoreBoundsKey);
35 gfx::Rect GetRestoreBoundsInParent(aura::Window* window) {
36 const gfx::Rect* rect = GetRestoreBoundsInScreen(window);
37 if (!rect)
38 return gfx::Rect();
39 return ScreenAsh::ConvertRectFromScreen(window->parent(), *rect);
42 void ClearRestoreBounds(aura::Window* window) {
43 window->ClearProperty(aura::client::kRestoreBoundsKey);
46 void SetTrackedByWorkspace(aura::Window* window, bool value) {
47 window->SetProperty(internal::kWindowTrackedByWorkspaceKey, value);
50 bool GetTrackedByWorkspace(const aura::Window* window) {
51 return window->GetProperty(internal::kWindowTrackedByWorkspaceKey);
54 void SetIgnoredByShelf(aura::Window* window, bool value) {
55 window->SetProperty(internal::kIgnoredByShelfKey, value);
58 bool GetIgnoredByShelf(const aura::Window* window) {
59 return window->GetProperty(internal::kIgnoredByShelfKey);
62 void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value) {
63 window->SetProperty(internal::kWindowRestoresToRestoreBounds, value);
66 bool GetWindowAlwaysRestoresToRestoreBounds(const aura::Window* window) {
67 return window->GetProperty(internal::kWindowRestoresToRestoreBounds);
70 void SetPersistsAcrossAllWorkspaces(
71 aura::Window* window,
72 WindowPersistsAcrossAllWorkspacesType type) {
73 window->SetProperty(
74 internal::kWindowPersistsAcrossAllWorkspacesKey, type);
77 bool GetPersistsAcrossAllWorkspaces(aura::Window* window) {
78 switch (window->GetProperty(
79 internal::kWindowPersistsAcrossAllWorkspacesKey)) {
80 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES:
81 return true;
82 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO:
83 return false;
84 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT:
85 return g_default_windows_persist_across_all_workspaces;
87 return false;
90 void SetDefaultPersistsAcrossAllWorkspaces(bool value) {
91 g_default_windows_persist_across_all_workspaces = value;
94 internal::RootWindowController* GetRootWindowController(
95 const aura::RootWindow* root_window) {
96 return root_window ?
97 root_window->GetProperty(internal::kRootWindowControllerKey) : NULL;
100 void SetRootWindowController(aura::RootWindow* root_window,
101 internal::RootWindowController* controller) {
102 root_window->SetProperty(internal::kRootWindowControllerKey, controller);
105 } // namespace ash