OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/property_util.h" | 5 #include "ash/wm/property_util.h" |
6 | 6 |
| 7 #include "ash/ash_export.h" |
| 8 #include "ash/wm/window_properties.h" |
7 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
8 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
10 #include "ui/aura/window_property.h" | |
11 #include "ui/base/ui_base_types.h" | 12 #include "ui/base/ui_base_types.h" |
12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
13 | 14 |
14 DECLARE_WINDOW_PROPERTY_TYPE(bool) | |
15 DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowPersistsAcrossAllWorkspacesType) | |
16 | |
17 namespace ash { | 15 namespace ash { |
18 | |
19 namespace { | 16 namespace { |
20 | |
21 const aura::WindowProperty<bool> kWindowTrackedByWorkspaceProp = {true}; | |
22 | |
23 const aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType> | |
24 kWindowPersistsAcrossAllWorkspacesProp = | |
25 {WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT}; | |
26 | |
27 bool g_default_windows_persist_across_all_workspaces = false; | 17 bool g_default_windows_persist_across_all_workspaces = false; |
28 | |
29 } // namespace | 18 } // namespace |
30 | 19 |
31 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { | 20 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { |
32 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); | 21 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
33 } | 22 } |
34 | 23 |
35 void SetRestoreBoundsIfNotSet(aura::Window* window) { | 24 void SetRestoreBoundsIfNotSet(aura::Window* window) { |
36 if (!GetRestoreBounds(window)) | 25 if (!GetRestoreBounds(window)) |
37 SetRestoreBounds(window, window->bounds()); | 26 SetRestoreBounds(window, window->bounds()); |
38 } | 27 } |
39 | 28 |
40 const gfx::Rect* GetRestoreBounds(aura::Window* window) { | 29 const gfx::Rect* GetRestoreBounds(aura::Window* window) { |
41 return window->GetProperty(aura::client::kRestoreBoundsKey); | 30 return window->GetProperty(aura::client::kRestoreBoundsKey); |
42 } | 31 } |
43 | 32 |
44 void ClearRestoreBounds(aura::Window* window) { | 33 void ClearRestoreBounds(aura::Window* window) { |
45 window->ClearProperty(aura::client::kRestoreBoundsKey); | 34 window->ClearProperty(aura::client::kRestoreBoundsKey); |
46 } | 35 } |
47 | 36 |
48 void ToggleMaximizedState(aura::Window* window) { | 37 void ToggleMaximizedState(aura::Window* window) { |
49 window->SetProperty(aura::client::kShowStateKey, | 38 window->SetProperty(aura::client::kShowStateKey, |
50 wm::IsWindowMaximized(window) ? ui::SHOW_STATE_NORMAL | 39 wm::IsWindowMaximized(window) ? ui::SHOW_STATE_NORMAL |
51 : ui::SHOW_STATE_MAXIMIZED); | 40 : ui::SHOW_STATE_MAXIMIZED); |
52 } | 41 } |
53 | 42 |
54 const aura::WindowProperty<bool>* const | |
55 kWindowTrackedByWorkspacePropKey = &kWindowTrackedByWorkspaceProp; | |
56 | |
57 const aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType>* const | |
58 kWindowPersistsAcrossAllWorkspacesPropKey = | |
59 &kWindowPersistsAcrossAllWorkspacesProp; | |
60 | |
61 void SetTrackedByWorkspace(aura::Window* window, bool value) { | 43 void SetTrackedByWorkspace(aura::Window* window, bool value) { |
62 window->SetProperty(kWindowTrackedByWorkspacePropKey, value); | 44 window->SetProperty(internal::kWindowTrackedByWorkspaceKey, value); |
63 } | 45 } |
64 | 46 |
65 bool GetTrackedByWorkspace(aura::Window* window) { | 47 bool GetTrackedByWorkspace(aura::Window* window) { |
66 return window->GetProperty(kWindowTrackedByWorkspacePropKey); | 48 return window->GetProperty(internal::kWindowTrackedByWorkspaceKey); |
67 } | 49 } |
68 | 50 |
69 void SetPersistsAcrossAllWorkspaces( | 51 void SetPersistsAcrossAllWorkspaces( |
70 aura::Window* window, | 52 aura::Window* window, |
71 WindowPersistsAcrossAllWorkspacesType type) { | 53 WindowPersistsAcrossAllWorkspacesType type) { |
72 window->SetProperty(kWindowPersistsAcrossAllWorkspacesPropKey, type); | 54 window->SetProperty( |
| 55 internal::kWindowPersistsAcrossAllWorkspacesKey, type); |
73 } | 56 } |
74 | 57 |
75 bool GetPersistsAcrossAllWorkspaces(aura::Window* window) { | 58 bool GetPersistsAcrossAllWorkspaces(aura::Window* window) { |
76 switch (window->GetProperty(kWindowPersistsAcrossAllWorkspacesPropKey)) { | 59 switch (window->GetProperty( |
| 60 internal::kWindowPersistsAcrossAllWorkspacesKey)) { |
77 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES: | 61 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES: |
78 return true; | 62 return true; |
79 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO: | 63 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO: |
80 return false; | 64 return false; |
81 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT: | 65 case WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT: |
82 return g_default_windows_persist_across_all_workspaces; | 66 return g_default_windows_persist_across_all_workspaces; |
83 } | 67 } |
84 return false; | 68 return false; |
85 } | 69 } |
86 | 70 |
87 void SetDefaultPersistsAcrossAllWorkspaces(bool value) { | 71 void SetDefaultPersistsAcrossAllWorkspaces(bool value) { |
88 g_default_windows_persist_across_all_workspaces = value; | 72 g_default_windows_persist_across_all_workspaces = value; |
89 } | 73 } |
90 | 74 |
91 } | 75 } |
OLD | NEW |