Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1911)

Unified Diff: ash/wm/window_state.h

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/window_state.h
diff --git a/ash/wm/window_settings.h b/ash/wm/window_state.h
similarity index 38%
rename from ash/wm/window_settings.h
rename to ash/wm/window_state.h
index 749ff2e5b003c92d4076b4d53ae8e11a00a6861b..7024f9a7b5159c552b7289b9f499f449a241f0de 100644
--- a/ash/wm/window_settings.h
+++ b/ash/wm/window_state.h
@@ -2,23 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_WINDOW_SETTINGS_H_
-#define ASH_WM_WINDOW_SETTINGS_H_
+#ifndef ASH_WM_WINDOW_STATE_H_
+#define ASH_WM_WINDOW_STATE_H_
#include "ash/ash_export.h"
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "ui/base/ui_base_types.h"
namespace aura {
class Window;
}
+namespace gfx {
+class Rect;
+}
+
namespace ash {
namespace wm {
-// Per managed window information should be stored here
-// instead of using plain aura window property.
-class ASH_EXPORT WindowSettings {
+// WindowState manages and defines ash specific window state and
+// behavior. Ash specific per-window state (such as ones that controls
+// window manager behavior) and ash specific window behavior (such as
+// Maximize, minimize, snap sizing etc) should be added here instead
James Cook 2013/09/19 03:49:53 Maximize -> maximize
oshima 2013/09/19 17:44:05 Done.
+// of defining separate functions (like |MaximizeWindow(aura::Window*
+// window)|) nor using aura Window property.
James Cook 2013/09/19 03:49:53 nor -> or
oshima 2013/09/19 17:44:05 Done.
+// The WindowState gets created when first accessed by
+// |wm::GetWindowState|, and deleted when the window is deleted.
James Cook 2013/09/19 03:49:53 You might also mention here your design principle
oshima 2013/09/19 17:44:05 Done.
+class ASH_EXPORT WindowState {
public:
class ASH_EXPORT Observer {
public:
@@ -27,8 +39,91 @@ class ASH_EXPORT WindowSettings {
bool old_value) {}
};
- explicit WindowSettings(aura::Window* window);
- ~WindowSettings();
+ static bool IsMaximizedOrFullscreenState(ui::WindowShowState state);
+
+ explicit WindowState(aura::Window* window);
+ ~WindowState();
+
+ aura::Window* window() { return window_; }
+ const aura::Window* window() const { return window_; }
+
+ // Returns the window's current shows tate.
+ ui::WindowShowState GetShowState() const;
+
+ // Predicates to check window state.
+ bool IsMinimized() const;
+ bool IsMaximized() const;
+ bool IsFullscreen() const;
+ bool IsMaximizedOrFullscreen() const;
+ // True if the window's show state is SHOW_STATE_NORMAL or
+ // SHOW_STATE_DEFAULT.
+ bool IsNormalShowState() const;
+ bool IsActive() const;
+
+ // Checks if the window can change its state accordingly.
+ bool CanMaximize() const;
+ bool CanMinimize() const;
+ bool CanResize() const;
+ bool CanSnap() const;
+ bool CanActivate() const;
+
+ // Returns true if the window has restore bounds.
+ bool HasRestoreBounds() const;
+
+ void Maximize();
+ void Minimize();
+ void Unminimize();
+ void Activate();
+ void Deactivate();
+ void Restore();
+ void ToggleMaximized();
+
+ // Sets the window's bounds in screen coordinates.
+ void SetBoundsInScreen(const gfx::Rect& bounds_in_screen);
+
+ // Saves the current bounds to be used as a restore bounds.
+ void SaveCurrentBoundsForRestore();
+
+ // Same as |GetRestoreBoundsInScreen| except that it returns the
+ // bounds in the parent's coordinates.
+ gfx::Rect GetRestoreBoundsInParent() const;
+
+ // Returns the restore bounds property on the window in the virtual screen
+ // coordinates. The bounds can be NULL if the bounds property does not
+ // exist for the window. The window owns the bounds object.
+ gfx::Rect GetRestoreBoundsInScreen() const;
+
+ // Same as |SetRestoreBoundsInScreen| except that the bounds is in the
+ // parent's coordinates.
+ void SetRestoreBoundsInParent(const gfx::Rect& bounds_in_parent);
+
+ // Sets the restore bounds property on the window in the virtual screen
+ // coordinates. Deletes existing bounds value if exists.
+ void SetRestoreBoundsInScreen(const gfx::Rect& bounds_in_screen);
+
+ // Deletes and clears the restore bounds property on the window.
+ void ClearRestoreBounds();
+
+ // Sets whether the window should always be restored to the restore bounds
+ // (sometimes the workspace layout manager restores the window to its original
+ // bounds instead of the restore bounds. Setting this key overrides that
+ // behaviour). The flag is reset to the default value after the window is
+ // restored.
+ bool always_restores_to_restore_bounds() const {
+ return always_restores_to_restore_bounds_;
+ }
+ void set_always_restores_to_restore_bounds(bool value) {
+ always_restores_to_restore_bounds_ = value;
+ }
+
+ // Gets/Sets the bounds of the window before it was moved by the auto window
+ // management. As long as it was not auto-managed, it will return NULL.
+ const gfx::Rect* pre_auto_manage_window_bounds() const {
+ return pre_auto_manage_window_bounds_.get();
+ }
+ void SetPreAutoManageWindowBounds(const gfx::Rect& bounds);
+
+ // Layout related properties
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -88,20 +183,31 @@ class ASH_EXPORT WindowSettings {
bool continue_drag_after_reparent_;
bool ignored_by_shelf_;
+ bool always_restores_to_restore_bounds_;
+
+ // A property to remember the window position which was set before the
+ // auto window position manager changed the window bounds, so that it can get
+ // restored when only this one window gets shown.
+ scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_;
+
ObserverList<Observer> observer_list_;
- DISALLOW_COPY_AND_ASSIGN(WindowSettings);
+ DISALLOW_COPY_AND_ASSIGN(WindowState);
};
-// Returns the WindowSettings for |window|. Creates WindowSettings
+// Returns the WindowState for active window. Returns |NULL|
+// if there is no active window.
+ASH_EXPORT WindowState* GetActiveWindowState();
+
+// Returns the WindowState for |window|. Creates WindowState
// if it didn't exist. The settings object is owned by |window|.
-ASH_EXPORT WindowSettings* GetWindowSettings(aura::Window* window);
+ASH_EXPORT WindowState* GetWindowState(aura::Window* window);
-// const version of GetWindowSettings.
-ASH_EXPORT const WindowSettings*
-GetWindowSettings(const aura::Window* window);
+// const version of GetWindowState.
+ASH_EXPORT const WindowState*
+GetWindowState(const aura::Window* window);
} // namespace wm
} // namespace ash
-#endif // ASH_WM_WINDOW_SETTINGS_H_
+#endif // ASH_WM_WINDOW_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698