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/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_property.h" | |
11 #include "ui/base/ui_base_types.h" | 10 #include "ui/base/ui_base_types.h" |
12 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
13 | 12 |
14 DECLARE_WINDOW_PROPERTY_TYPE(bool) | |
15 | |
16 namespace ash { | 13 namespace ash { |
17 | 14 |
18 namespace { | |
19 | |
20 const aura::WindowProperty<bool> kWindowTrackedByWorkspaceSplitProp = {true}; | |
21 | |
22 } // namespace | |
23 | |
24 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { | 15 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { |
25 scoped_ptr<const gfx::Rect> old_bounds(GetRestoreBounds(window)); | 16 scoped_ptr<const gfx::Rect> old_bounds(GetRestoreBounds(window)); |
26 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); | 17 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
27 } | 18 } |
28 | 19 |
29 void SetRestoreBoundsIfNotSet(aura::Window* window) { | 20 void SetRestoreBoundsIfNotSet(aura::Window* window) { |
30 if (!GetRestoreBounds(window)) | 21 if (!GetRestoreBounds(window)) |
31 SetRestoreBounds(window, window->bounds()); | 22 SetRestoreBounds(window, window->bounds()); |
32 } | 23 } |
33 | 24 |
34 const gfx::Rect* GetRestoreBounds(aura::Window* window) { | 25 const gfx::Rect* GetRestoreBounds(aura::Window* window) { |
35 return window->GetProperty(aura::client::kRestoreBoundsKey); | 26 return window->GetProperty(aura::client::kRestoreBoundsKey); |
36 } | 27 } |
37 | 28 |
38 void ClearRestoreBounds(aura::Window* window) { | 29 void ClearRestoreBounds(aura::Window* window) { |
39 scoped_ptr<const gfx::Rect> old_bounds(GetRestoreBounds(window)); | 30 scoped_ptr<const gfx::Rect> old_bounds(GetRestoreBounds(window)); |
40 window->ClearProperty(aura::client::kRestoreBoundsKey); | 31 window->ClearProperty(aura::client::kRestoreBoundsKey); |
41 } | 32 } |
42 | 33 |
43 void ToggleMaximizedState(aura::Window* window) { | 34 void ToggleMaximizedState(aura::Window* window) { |
44 window->SetProperty(aura::client::kShowStateKey, | 35 window->SetProperty(aura::client::kShowStateKey, |
45 wm::IsWindowMaximized(window) ? ui::SHOW_STATE_NORMAL | 36 wm::IsWindowMaximized(window) ? ui::SHOW_STATE_NORMAL |
46 : ui::SHOW_STATE_MAXIMIZED); | 37 : ui::SHOW_STATE_MAXIMIZED); |
47 } | 38 } |
48 | 39 |
49 const aura::WindowProperty<bool>* const | |
50 kWindowTrackedByWorkspaceSplitPropKey = &kWindowTrackedByWorkspaceSplitProp; | |
51 | |
52 void SetTrackedByWorkspace(aura::Window* window, bool value) { | |
53 window->SetProperty(kWindowTrackedByWorkspaceSplitPropKey, value); | |
54 } | 40 } |
55 | |
56 bool GetTrackedByWorkspace(aura::Window* window) { | |
57 return window->GetProperty(kWindowTrackedByWorkspaceSplitPropKey); | |
58 } | |
59 | |
60 } | |
OLD | NEW |