summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 15:26:03 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 15:26:03 +0000
commit24eea16cb849a85b22ff6460358ecfcfe4f81279 (patch)
treeb1b3a757edf28fb07ad78374c6926d94dc9f99d6 /ash
parent6a24fccd5c2e34a7522438a92cef6e7de41c2ec8 (diff)
downloadchromium_src-24eea16cb849a85b22ff6460358ecfcfe4f81279.zip
chromium_src-24eea16cb849a85b22ff6460358ecfcfe4f81279.tar.gz
chromium_src-24eea16cb849a85b22ff6460358ecfcfe4f81279.tar.bz2
Adds the ability for windows to persist across all workspaces. Chrome
makes the default that all windows persist across all workspaces and explicitly disables this for browsers. As part of this I promoted duplicated code from WorkspaceLayoutManager and AlwaysOnTopLayoutManager to BaseLayoutManager. BUG=122301,122390,121280,121784 TEST=see bugs, covered by unit tests too. R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10020061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/shell.cc3
-rw-r--r--ash/shell/toplevel_window.cc13
-rw-r--r--ash/shell/toplevel_window.h1
-rw-r--r--ash/shell/window_type_launcher.cc109
-rw-r--r--ash/shell/window_type_launcher.h2
-rw-r--r--ash/wm/base_layout_manager.cc43
-rw-r--r--ash/wm/base_layout_manager.h6
-rw-r--r--ash/wm/property_util.cc41
-rw-r--r--ash/wm/property_util.h23
-rw-r--r--ash/wm/window_util.cc8
-rw-r--r--ash/wm/window_util.h5
-rw-r--r--ash/wm/workspace/always_on_top_layout_manager.cc94
-rw-r--r--ash/wm/workspace/always_on_top_layout_manager.h48
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc67
-rw-r--r--ash/wm/workspace/workspace_layout_manager.h8
-rw-r--r--ash/wm/workspace/workspace_manager.cc4
-rw-r--r--ash/wm/workspace/workspace_manager_unittest.cc65
18 files changed, 241 insertions, 301 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 5c8c215..ad6445b 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -259,8 +259,6 @@
'wm/window_util.h',
'wm/workspace_controller.cc',
'wm/workspace_controller.h',
- 'wm/workspace/always_on_top_layout_manager.cc',
- 'wm/workspace/always_on_top_layout_manager.h',
'wm/workspace/frame_maximize_button.cc',
'wm/workspace/frame_maximize_button.h',
'wm/workspace/managed_workspace.cc',
diff --git a/ash/shell.cc b/ash/shell.cc
index 0d30ef1..8fc842c 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -65,7 +65,6 @@
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_modality_controller.h"
#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/always_on_top_layout_manager.h"
#include "ash/wm/workspace/workspace_event_filter.h"
#include "ash/wm/workspace/workspace_layout_manager.h"
#include "ash/wm/workspace/workspace_manager.h"
@@ -925,7 +924,7 @@ void Shell::InitLayoutManagers() {
aura::Window* always_on_top_container =
GetContainer(internal::kShellWindowId_AlwaysOnTopContainer);
always_on_top_container->SetLayoutManager(
- new internal::AlwaysOnTopLayoutManager(
+ new internal::BaseLayoutManager(
always_on_top_container->GetRootWindow()));
// Create desktop background widget.
diff --git a/ash/shell/toplevel_window.cc b/ash/shell/toplevel_window.cc
index 57cbfa5..8ff724b 100644
--- a/ash/shell/toplevel_window.cc
+++ b/ash/shell/toplevel_window.cc
@@ -4,6 +4,7 @@
#include "ash/shell/toplevel_window.h"
+#include "ash/wm/property_util.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/gfx/canvas.h"
@@ -14,7 +15,8 @@ namespace shell {
ToplevelWindow::CreateParams::CreateParams()
: can_resize(false),
- can_maximize(false) {
+ can_maximize(false),
+ persist_across_all_workspaces(false) {
}
// static
@@ -26,6 +28,11 @@ void ToplevelWindow::CreateToplevelWindow(const CreateParams& params) {
views::Widget::CreateWindowWithBounds(new ToplevelWindow(params),
gfx::Rect(x, 150, 300, 300));
widget->GetNativeView()->SetName("Examples:ToplevelWindow");
+ if (params.persist_across_all_workspaces) {
+ SetPersistsAcrossAllWorkspaces(
+ widget->GetNativeView(),
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
+ }
widget->Show();
}
@@ -40,7 +47,9 @@ void ToplevelWindow::OnPaint(gfx::Canvas* canvas) {
}
string16 ToplevelWindow::GetWindowTitle() const {
- return ASCIIToUTF16("Examples: Toplevel Window");
+ return params_.persist_across_all_workspaces ?
+ ASCIIToUTF16("Examples: Toplevel Window (P)") :
+ ASCIIToUTF16("Examples: Toplevel Window");
}
views::View* ToplevelWindow::GetContentsView() {
diff --git a/ash/shell/toplevel_window.h b/ash/shell/toplevel_window.h
index d67ff9b..375819c 100644
--- a/ash/shell/toplevel_window.h
+++ b/ash/shell/toplevel_window.h
@@ -18,6 +18,7 @@ class ToplevelWindow : public views::WidgetDelegateView {
bool can_resize;
bool can_maximize;
+ bool persist_across_all_workspaces;
};
static void CreateToplevelWindow(const CreateParams& params);
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index 3d96906..c6f5427 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -20,6 +20,7 @@
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
using views::MenuItemView;
@@ -164,6 +165,12 @@ class NonModalTransient : public views::WidgetDelegateView {
// static
views::Widget* NonModalTransient::non_modal_transient_ = NULL;
+void AddViewToLayout(views::GridLayout* layout, views::View* view) {
+ layout->StartRow(0, 0);
+ layout->AddView(view);
+ layout->AddPaddingRow(0, 5);
+}
+
} // namespace
void InitWindowTypeLauncher() {
@@ -179,6 +186,9 @@ void InitWindowTypeLauncher() {
WindowTypeLauncher::WindowTypeLauncher()
: ALLOW_THIS_IN_INITIALIZER_LIST(create_button_(
new views::NativeTextButton(this, ASCIIToUTF16("Create Window")))),
+ ALLOW_THIS_IN_INITIALIZER_LIST(create_persistant_button_(
+ new views::NativeTextButton(
+ this, ASCIIToUTF16("Create Persistant Window")))),
ALLOW_THIS_IN_INITIALIZER_LIST(panel_button_(
new views::NativeTextButton(this, ASCIIToUTF16("Create Panel")))),
ALLOW_THIS_IN_INITIALIZER_LIST(create_nonresizable_button_(
@@ -207,17 +217,28 @@ WindowTypeLauncher::WindowTypeLauncher()
ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_(
new views::NativeTextButton(
this, ASCIIToUTF16("Show/Hide a Window")))) {
- AddChildView(create_button_);
- AddChildView(panel_button_);
- AddChildView(create_nonresizable_button_);
- AddChildView(bubble_button_);
- AddChildView(lock_button_);
- AddChildView(widgets_button_);
- AddChildView(system_modal_button_);
- AddChildView(window_modal_button_);
- AddChildView(transient_button_);
- AddChildView(examples_button_);
- AddChildView(show_hide_window_button_);
+ views::GridLayout* layout = new views::GridLayout(this);
+ layout->SetInsets(5, 5, 5, 5);
+ SetLayoutManager(layout);
+ views::ColumnSet* column_set = layout->AddColumnSet(0);
+ column_set->AddColumn(views::GridLayout::LEADING,
+ views::GridLayout::CENTER,
+ 0,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ AddViewToLayout(layout, create_button_);
+ AddViewToLayout(layout, create_persistant_button_);
+ AddViewToLayout(layout, panel_button_);
+ AddViewToLayout(layout, create_nonresizable_button_);
+ AddViewToLayout(layout, bubble_button_);
+ AddViewToLayout(layout, lock_button_);
+ AddViewToLayout(layout, widgets_button_);
+ AddViewToLayout(layout, system_modal_button_);
+ AddViewToLayout(layout, window_modal_button_);
+ AddViewToLayout(layout, transient_button_);
+ AddViewToLayout(layout, examples_button_);
+ AddViewToLayout(layout, show_hide_window_button_);
#if !defined(OS_MACOSX)
set_context_menu_controller(this);
#endif
@@ -230,66 +251,6 @@ void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) {
canvas->FillRect(GetLocalBounds(), SK_ColorWHITE);
}
-void WindowTypeLauncher::Layout() {
- gfx::Size create_button_ps = create_button_->GetPreferredSize();
- gfx::Rect local_bounds = GetLocalBounds();
- create_button_->SetBounds(
- 5, local_bounds.bottom() - create_button_ps.height() - 5,
- create_button_ps.width(), create_button_ps.height());
-
- gfx::Size panel_button_ps = panel_button_->GetPreferredSize();
- panel_button_->SetBounds(
- 5, create_button_->y() - panel_button_ps.height() - 5,
- panel_button_ps.width(), panel_button_ps.height());
-
- gfx::Size bubble_button_ps = bubble_button_->GetPreferredSize();
- bubble_button_->SetBounds(
- 5, panel_button_->y() - bubble_button_ps.height() - 5,
- bubble_button_ps.width(), bubble_button_ps.height());
-
- gfx::Size create_nr_button_ps =
- create_nonresizable_button_->GetPreferredSize();
- create_nonresizable_button_->SetBounds(
- 5, bubble_button_->y() - create_nr_button_ps.height() - 5,
- create_nr_button_ps.width(), create_nr_button_ps.height());
-
- gfx::Size lock_ps = lock_button_->GetPreferredSize();
- lock_button_->SetBounds(
- 5, create_nonresizable_button_->y() - lock_ps.height() - 5,
- lock_ps.width(), lock_ps.height());
-
- gfx::Size widgets_ps = widgets_button_->GetPreferredSize();
- widgets_button_->SetBounds(
- 5, lock_button_->y() - widgets_ps.height() - 5,
- widgets_ps.width(), widgets_ps.height());
-
- gfx::Size system_modal_ps = system_modal_button_->GetPreferredSize();
- system_modal_button_->SetBounds(
- 5, widgets_button_->y() - system_modal_ps.height() - 5,
- system_modal_ps.width(), system_modal_ps.height());
-
- gfx::Size window_modal_ps = window_modal_button_->GetPreferredSize();
- window_modal_button_->SetBounds(
- 5, system_modal_button_->y() - window_modal_ps.height() - 5,
- window_modal_ps.width(), window_modal_ps.height());
-
- gfx::Size transient_ps = transient_button_->GetPreferredSize();
- transient_button_->SetBounds(
- 5, window_modal_button_->y() - transient_ps.height() - 5,
- transient_ps.width(), transient_ps.height());
-
- gfx::Size examples_ps = examples_button_->GetPreferredSize();
- examples_button_->SetBounds(
- 5, transient_button_->y() - examples_ps.height() - 5,
- examples_ps.width(), examples_ps.height());
-
- gfx::Size show_hide_window_ps =
- show_hide_window_button_->GetPreferredSize();
- show_hide_window_button_->SetBounds(
- 5, examples_button_->y() - show_hide_window_ps.height() - 5,
- show_hide_window_ps.width(), show_hide_window_ps.height());
-}
-
bool WindowTypeLauncher::OnMousePressed(const views::MouseEvent& event) {
// Overridden so we get OnMouseReleased and can show the context menu.
return true;
@@ -318,6 +279,12 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender,
params.can_resize = true;
params.can_maximize = true;
ToplevelWindow::CreateToplevelWindow(params);
+ } else if (sender == create_persistant_button_) {
+ ToplevelWindow::CreateParams params;
+ params.can_resize = true;
+ params.can_maximize = true;
+ params.persist_across_all_workspaces = true;
+ ToplevelWindow::CreateToplevelWindow(params);
} else if (sender == panel_button_) {
PanelWindow::CreatePanelWindow(gfx::Rect());
} else if (sender == create_nonresizable_button_) {
diff --git a/ash/shell/window_type_launcher.h b/ash/shell/window_type_launcher.h
index 02c15d9..3b9807d 100644
--- a/ash/shell/window_type_launcher.h
+++ b/ash/shell/window_type_launcher.h
@@ -44,7 +44,6 @@ class WindowTypeLauncher : public views::WidgetDelegateView,
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
- virtual void Layout() OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
// Overridden from views::WidgetDelegate:
@@ -67,6 +66,7 @@ class WindowTypeLauncher : public views::WidgetDelegateView,
#endif // !defined(OS_MACOSX)
views::NativeTextButton* create_button_;
+ views::NativeTextButton* create_persistant_button_;
views::NativeTextButton* panel_button_;
views::NativeTextButton* create_nonresizable_button_;
views::NativeTextButton* bubble_button_;
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 3524e93..9277c50 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -8,13 +8,18 @@
#include "ash/shell.h"
#include "ash/wm/property_util.h"
#include "ash/wm/shelf_layout_manager.h"
+#include "ash/wm/window_animations.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/aura/window_property.h"
#include "ui/base/ui_base_types.h"
+#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/screen.h"
+DECLARE_WINDOW_PROPERTY_TYPE(ui::WindowShowState)
+
namespace {
// Given a |window| and tentative |restore_bounds|, returns new bounds that
@@ -36,6 +41,10 @@ gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window,
return restore_bounds;
}
+// Used to remember the show state before the window was minimized.
+DEFINE_WINDOW_PROPERTY_KEY(
+ ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT);
+
} // namespace
namespace ash {
@@ -82,7 +91,13 @@ void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
}
void BaseLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
- bool visibile) {
+ bool visible) {
+ if (visible && wm::IsWindowMinimized(child)) {
+ // Attempting to show a minimized window. Unminimize it.
+ child->SetProperty(aura::client::kShowStateKey,
+ child->GetProperty(kRestoreShowStateKey));
+ child->ClearProperty(kRestoreShowStateKey);
+ }
}
void BaseLayoutManager::SetChildBounds(aura::Window* child,
@@ -118,8 +133,10 @@ void BaseLayoutManager::OnMonitorWorkAreaInsetsChanged() {
void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
- if (key == aura::client::kShowStateKey)
+ if (key == aura::client::kShowStateKey) {
UpdateBoundsFromShowState(window);
+ ShowStateChanged(window, static_cast<ui::WindowShowState>(old));
+ }
}
void BaseLayoutManager::OnWindowDestroying(aura::Window* window) {
@@ -132,6 +149,28 @@ void BaseLayoutManager::OnWindowDestroying(aura::Window* window) {
//////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, private:
+void BaseLayoutManager::ShowStateChanged(aura::Window* window,
+ ui::WindowShowState last_show_state) {
+ if (wm::IsWindowMinimized(window)) {
+ // Save the previous show state so that we can correctly restore it.
+ window->SetProperty(kRestoreShowStateKey, last_show_state);
+ SetWindowVisibilityAnimationType(
+ window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
+
+ // Hide the window.
+ window->Hide();
+ // Activate another window.
+ if (wm::IsActiveWindow(window))
+ wm::DeactivateWindow(window);
+ } else if ((window->TargetVisibility() ||
+ last_show_state == ui::SHOW_STATE_MINIMIZED) &&
+ !window->layer()->visible()) {
+ // The layer may be hidden if the window was previously minimized. Make
+ // sure it's visible.
+ window->Show();
+ }
+}
+
void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
switch (window->GetProperty(aura::client::kShowStateKey)) {
case ui::SHOW_STATE_DEFAULT:
diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h
index e669f07..0638d36 100644
--- a/ash/wm/base_layout_manager.h
+++ b/ash/wm/base_layout_manager.h
@@ -14,6 +14,7 @@
#include "base/compiler_specific.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/root_window_observer.h"
+#include "ui/base/ui_base_types.h"
#include "ui/aura/window_observer.h"
namespace aura {
@@ -63,6 +64,11 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager,
intptr_t old) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
+ protected:
+ // Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes.
+ virtual void ShowStateChanged(aura::Window* window,
+ ui::WindowShowState last_show_state);
+
private:
// Update window bounds based on a change in show state.
void UpdateBoundsFromShowState(aura::Window* window);
diff --git a/ash/wm/property_util.cc b/ash/wm/property_util.cc
index e412354..83082f6 100644
--- a/ash/wm/property_util.cc
+++ b/ash/wm/property_util.cc
@@ -12,12 +12,19 @@
#include "ui/gfx/rect.h"
DECLARE_WINDOW_PROPERTY_TYPE(bool)
+DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowPersistsAcrossAllWorkspacesType)
namespace ash {
namespace {
-const aura::WindowProperty<bool> kWindowTrackedByWorkspaceSplitProp = {true};
+const aura::WindowProperty<bool> kWindowTrackedByWorkspaceProp = {true};
+
+const aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType>
+ kWindowPersistsAcrossAllWorkspacesProp =
+ {WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT};
+
+bool g_default_windows_persist_across_all_workspaces = false;
} // namespace
@@ -45,14 +52,40 @@ void ToggleMaximizedState(aura::Window* window) {
}
const aura::WindowProperty<bool>* const
- kWindowTrackedByWorkspaceSplitPropKey = &kWindowTrackedByWorkspaceSplitProp;
+ kWindowTrackedByWorkspacePropKey = &kWindowTrackedByWorkspaceProp;
+
+const aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType>* const
+ kWindowPersistsAcrossAllWorkspacesPropKey =
+ &kWindowPersistsAcrossAllWorkspacesProp;
void SetTrackedByWorkspace(aura::Window* window, bool value) {
- window->SetProperty(kWindowTrackedByWorkspaceSplitPropKey, value);
+ window->SetProperty(kWindowTrackedByWorkspacePropKey, value);
}
bool GetTrackedByWorkspace(aura::Window* window) {
- return window->GetProperty(kWindowTrackedByWorkspaceSplitPropKey);
+ return window->GetProperty(kWindowTrackedByWorkspacePropKey);
+}
+
+void SetPersistsAcrossAllWorkspaces(
+ aura::Window* window,
+ WindowPersistsAcrossAllWorkspacesType type) {
+ window->SetProperty(kWindowPersistsAcrossAllWorkspacesPropKey, type);
+}
+
+bool GetPersistsAcrossAllWorkspaces(aura::Window* window) {
+ switch (window->GetProperty(kWindowPersistsAcrossAllWorkspacesPropKey)) {
+ 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;
}
}
diff --git a/ash/wm/property_util.h b/ash/wm/property_util.h
index 01ab2bc..7e1820e 100644
--- a/ash/wm/property_util.h
+++ b/ash/wm/property_util.h
@@ -40,7 +40,17 @@ ASH_EXPORT void ClearRestoreBounds(aura::Window* window);
ASH_EXPORT void ToggleMaximizedState(aura::Window* window);
ASH_EXPORT extern const aura::WindowProperty<bool>* const
- kWindowTrackedByWorkspaceSplitPropKey;
+ kWindowTrackedByWorkspacePropKey;
+
+enum WindowPersistsAcrossAllWorkspacesType {
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT,
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO,
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES,
+};
+
+ASH_EXPORT extern const
+ aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType>* const
+ kWindowPersistsAcrossAllWorkspacesPropKey;
// Sets whether the specified window is tracked by workspace code. Default is
// true. If set to false the workspace does not switch the current workspace,
@@ -49,6 +59,17 @@ ASH_EXPORT extern const aura::WindowProperty<bool>* const
ASH_EXPORT void SetTrackedByWorkspace(aura::Window* window, bool value);
ASH_EXPORT bool GetTrackedByWorkspace(aura::Window* window);
+// Makes |window| persist across all workspaces. The default is controlled
+// by SetDefaultPersistsAcrossAllWorkspaces().
+ASH_EXPORT void SetPersistsAcrossAllWorkspaces(
+ aura::Window* window,
+ WindowPersistsAcrossAllWorkspacesType type);
+ASH_EXPORT bool GetPersistsAcrossAllWorkspaces(aura::Window* window);
+
+// Sets the default value for whether windows persist across all workspaces.
+// The default is false.
+ASH_EXPORT void SetDefaultPersistsAcrossAllWorkspaces(bool value);
+
}
#endif // ASH_WM_PROPERTY_UTIL_H_
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index be1f3e9..b273cb6 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -96,13 +96,5 @@ void RestoreWindow(aura::Window* window) {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
}
-void SetOpenWindowSplit(aura::Window* window, bool value) {
- window->SetProperty(kOpenWindowSplitKey, value);
-}
-
-bool GetOpenWindowSplit(aura::Window* window) {
- return window->GetProperty(kOpenWindowSplitKey);
-}
-
} // namespace wm
} // namespace ash
diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h
index c4da88b..1191daa 100644
--- a/ash/wm/window_util.h
+++ b/ash/wm/window_util.h
@@ -50,11 +50,6 @@ ASH_EXPORT void MinimizeWindow(aura::Window* window);
// Restores |window|, which must not be NULL.
ASH_EXPORT void RestoreWindow(aura::Window* window);
-// Sets whether the window should be open in a split mode. Only applicable when
-// workspaces are used.
-ASH_EXPORT void SetOpenWindowSplit(aura::Window* window, bool value);
-ASH_EXPORT bool GetOpenWindowSplit(aura::Window* window);
-
} // namespace wm
} // namespace ash
diff --git a/ash/wm/workspace/always_on_top_layout_manager.cc b/ash/wm/workspace/always_on_top_layout_manager.cc
deleted file mode 100644
index 25655bc..0000000
--- a/ash/wm/workspace/always_on_top_layout_manager.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// 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/workspace/always_on_top_layout_manager.h"
-
-#include "ash/wm/window_animations.h"
-#include "ash/wm/window_util.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/event.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_observer.h"
-#include "ui/aura/window_property.h"
-#include "ui/base/ui_base_types.h"
-#include "ui/gfx/compositor/layer.h"
-#include "ui/gfx/rect.h"
-
-DECLARE_WINDOW_PROPERTY_TYPE(ui::WindowShowState)
-
-namespace ash {
-namespace internal {
-
-namespace {
-
-// Used to remember the show state before the window was minimized.
-DEFINE_WINDOW_PROPERTY_KEY(
- ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT);
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// AlwaysOnTopLayoutManager, public:
-
-AlwaysOnTopLayoutManager::AlwaysOnTopLayoutManager(
- aura::RootWindow* root_window)
- : BaseLayoutManager(root_window) {
-}
-
-AlwaysOnTopLayoutManager::~AlwaysOnTopLayoutManager() {
-}
-
-void AlwaysOnTopLayoutManager::OnChildWindowVisibilityChanged(
- aura::Window* child,
- bool visible) {
- if (visible) {
- if (wm::IsWindowMinimized(child)) {
- // Attempting to show a minimized window. Unminimize it.
- child->SetProperty(aura::client::kShowStateKey,
- child->GetProperty(kRestoreShowStateKey));
- child->ClearProperty(kRestoreShowStateKey);
- }
- }
-}
-
-void AlwaysOnTopLayoutManager::OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) {
- BaseLayoutManager::OnWindowPropertyChanged(window, key, old);
- if (key == aura::client::kShowStateKey)
- ShowStateChanged(window, static_cast<ui::WindowShowState>(old));
-}
-
-void AlwaysOnTopLayoutManager::ShowStateChanged(
- aura::Window* window,
- ui::WindowShowState last_show_state) {
- if (wm::IsWindowMinimized(window)) {
- // Save the previous show state so that we can correctly restore it.
- window->SetProperty(kRestoreShowStateKey, last_show_state);
- SetWindowVisibilityAnimationType(
- window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
-
- // Hide the window.
- window->Hide();
- // Activate another window.
- if (wm::IsActiveWindow(window))
- wm::DeactivateWindow(window);
- return;
- }
- // We can end up here if the window was minimized and we are transitioning
- // to another state. In that case the window is hidden.
- if ((window->TargetVisibility() ||
- last_show_state == ui::SHOW_STATE_MINIMIZED)) {
- if (!window->layer()->visible()) {
- // The layer may be hidden if the window was previously minimized. Make
- // sure it's visible.
- window->Show();
- }
- return;
- }
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/always_on_top_layout_manager.h b/ash/wm/workspace/always_on_top_layout_manager.h
deleted file mode 100644
index 97636eb..0000000
--- a/ash/wm/workspace/always_on_top_layout_manager.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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.
-
-#ifndef ASH_WM_WORKSPACE_ALWAYS_ON_TOP_LAYOUT_MANAGER_H_
-#define ASH_WM_WORKSPACE_ALWAYS_ON_TOP_LAYOUT_MANAGER_H_
-#pragma once
-
-#include "ash/wm/base_layout_manager.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/base/ui_base_types.h"
-
-namespace aura {
-class RootWindow;
-class Window;
-}
-
-namespace ash {
-namespace internal {
-
-// LayoutManager for top level windows when WorkspaceManager is enabled.
-class ASH_EXPORT AlwaysOnTopLayoutManager : public BaseLayoutManager {
- public:
- explicit AlwaysOnTopLayoutManager(aura::RootWindow* root_window);
- virtual ~AlwaysOnTopLayoutManager();
-
- // Overridden from BaseLayoutManager:
- virtual void OnChildWindowVisibilityChanged(aura::Window* child,
- bool visibile) OVERRIDE;
-
- // Overriden from aura::WindowObserver:
- virtual void OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) OVERRIDE;
-
- private:
- void ShowStateChanged(
- aura::Window* window,
- ui::WindowShowState last_show_state);
-
- DISALLOW_COPY_AND_ASSIGN(AlwaysOnTopLayoutManager);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_ALWAYS_ON_TOP_LAYOUT_MANAGER_H_
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index 9c60d06..991db32 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -6,7 +6,6 @@
#include "ash/screen_ash.h"
#include "ash/wm/property_util.h"
-#include "ash/wm/window_animations.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace.h"
#include "ash/wm/workspace/workspace_manager.h"
@@ -18,26 +17,12 @@
#include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
#include "ui/base/ui_base_types.h"
-#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/rect.h"
#include "ui/views/widget/native_widget_aura.h"
-DECLARE_WINDOW_PROPERTY_TYPE(ui::WindowShowState)
-
namespace ash {
namespace internal {
-namespace {
-
-// Used to remember the show state before the window was minimized.
-DEFINE_WINDOW_PROPERTY_KEY(
- ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT);
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// WorkspaceLayoutManager, public:
-
WorkspaceLayoutManager::WorkspaceLayoutManager(
aura::RootWindow* root_window,
WorkspaceManager* workspace_manager)
@@ -75,19 +60,13 @@ void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(
void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(
aura::Window* child,
bool visible) {
+ BaseLayoutManager::OnChildWindowVisibilityChanged(child, visible);
if (!workspace_manager_->IsManagedWindow(child))
return;
- if (visible) {
- if (wm::IsWindowMinimized(child)) {
- // Attempting to show a minimized window. Unminimize it.
- child->SetProperty(aura::client::kShowStateKey,
- child->GetProperty(kRestoreShowStateKey));
- child->ClearProperty(kRestoreShowStateKey);
- }
+ if (visible)
workspace_manager_->AddWindow(child);
- } else {
+ else
workspace_manager_->RemoveWindow(child);
- }
}
void WorkspaceLayoutManager::SetChildBounds(
@@ -104,11 +83,8 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
BaseLayoutManager::OnWindowPropertyChanged(window, key, old);
- if (key == aura::client::kShowStateKey &&
- workspace_manager_->IsManagedWindow(window)) {
- ShowStateChanged(window, static_cast<ui::WindowShowState>(old));
- } else if (key == ash::kWindowTrackedByWorkspaceSplitPropKey &&
- ash::GetTrackedByWorkspace(window)) {
+ if (key == ash::kWindowTrackedByWorkspacePropKey &&
+ ash::GetTrackedByWorkspace(window)) {
// We currently don't need to support transitioning from true to false, so
// we ignore it.
workspace_manager_->AddWindow(window);
@@ -118,33 +94,16 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
void WorkspaceLayoutManager::ShowStateChanged(
aura::Window* window,
ui::WindowShowState last_show_state) {
- if (wm::IsWindowMinimized(window)) {
- // Save the previous show state so that we can correctly restore it.
- window->SetProperty(kRestoreShowStateKey, last_show_state);
- workspace_manager_->RemoveWindow(window);
- SetWindowVisibilityAnimationType(
- window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
-
- // Hide the window.
- window->Hide();
- // Activate another window.
- if (wm::IsActiveWindow(window))
- wm::DeactivateWindow(window);
- return;
- }
- // We can end up here if the window was minimized and we are transitioning
- // to another state. In that case the window is hidden.
- if ((window->TargetVisibility() ||
- (last_show_state == ui::SHOW_STATE_MINIMIZED)) &&
- !workspace_manager_->IsManagingWindow(window)) {
- workspace_manager_->AddWindow(window);
- if (!window->layer()->visible()) {
- // The layer may be hidden if the window was previously minimized. Make
- // sure it's visible.
- window->Show();
+ if (workspace_manager_->IsManagedWindow(window)) {
+ if (wm::IsWindowMinimized(window))
+ workspace_manager_->RemoveWindow(window);
+ else if ((window->TargetVisibility() ||
+ (last_show_state == ui::SHOW_STATE_MINIMIZED)) &&
+ !workspace_manager_->IsManagingWindow(window)) {
+ workspace_manager_->AddWindow(window);
}
- return;
}
+ BaseLayoutManager::ShowStateChanged(window, last_show_state);
workspace_manager_->ShowStateChanged(window);
}
diff --git a/ash/wm/workspace/workspace_layout_manager.h b/ash/wm/workspace/workspace_layout_manager.h
index ff14a1d..1969c04 100644
--- a/ash/wm/workspace/workspace_layout_manager.h
+++ b/ash/wm/workspace/workspace_layout_manager.h
@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window_observer.h"
-#include "ui/base/ui_base_types.h"
namespace aura {
class MouseEvent;
@@ -53,12 +52,11 @@ class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
virtual void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) OVERRIDE;
+ protected:
+ virtual void ShowStateChanged(aura::Window* window,
+ ui::WindowShowState last_show_state) OVERRIDE;
private:
- void ShowStateChanged(
- aura::Window* window,
- ui::WindowShowState last_show_state);
-
// Owned by WorkspaceController.
WorkspaceManager* workspace_manager_;
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
index e4cec4b..e461d9e 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -84,7 +84,8 @@ WorkspaceManager::~WorkspaceManager() {
bool WorkspaceManager::IsManagedWindow(aura::Window* window) const {
return window->type() == aura::client::WINDOW_TYPE_NORMAL &&
- !window->transient_parent() && ash::GetTrackedByWorkspace(window);
+ !window->transient_parent() && ash::GetTrackedByWorkspace(window) &&
+ !ash::GetPersistsAcrossAllWorkspaces(window);
}
bool WorkspaceManager::IsManagingWindow(aura::Window* window) const {
@@ -329,7 +330,6 @@ void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) {
new_workspace->AddWindowAfter(window, NULL);
} else {
// Maximized -> unmaximized; move window to unmaximized workspace.
- wm::SetOpenWindowSplit(window, false);
new_workspace = GetManagedWorkspace();
current_workspace->RemoveWindow(window);
if (!new_workspace)
diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc
index 5d04322..6d112c1 100644
--- a/ash/wm/workspace/workspace_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_manager_unittest.cc
@@ -518,5 +518,70 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
w2->bounds().ToString());
}
+// Verifies persist across all workspaces.
+TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) {
+ // Create a maximized window.
+ scoped_ptr<Window> w1(CreateTestWindow());
+ w1->Show();
+ w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_TRUE(w1->layer()->IsDrawn());
+ EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
+
+ // Create a window that persists across all workspaces, it should be visible
+ // even while in a maximized workspace.
+ scoped_ptr<Window> w2(CreateTestWindow());
+ SetPersistsAcrossAllWorkspaces(
+ w2.get(),
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
+ w2->Show();
+ wm::ActivateWindow(w2.get());
+ EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
+ EXPECT_TRUE(std::find(active_workspace()->windows().begin(),
+ active_workspace()->windows().end(), w2.get()) ==
+ active_workspace()->windows().end());
+ EXPECT_TRUE(w1->layer()->IsDrawn());
+ EXPECT_TRUE(w2->layer()->IsDrawn());
+
+ // Activate the maximized window, w1, ensure w2 is still visible.
+ wm::ActivateWindow(w1.get());
+ EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
+ EXPECT_TRUE(w1->layer()->IsDrawn());
+ EXPECT_TRUE(w2->layer()->IsDrawn());
+
+ // Create another window (normal) and show/activate it. w1 (maximized window)
+ // should hide, but w2 should still be visible since it persists across all
+ // windows.
+ scoped_ptr<Window> w3(CreateTestWindow());
+ w3->Show();
+ wm::ActivateWindow(w3.get());
+ EXPECT_EQ(Workspace::TYPE_MANAGED, active_workspace()->type());
+ EXPECT_FALSE(w1->layer()->IsDrawn());
+ EXPECT_TRUE(w2->layer()->IsDrawn());
+ EXPECT_TRUE(w3->layer()->IsDrawn());
+
+ // Activate w2 again, shouldn't switch workspaces.
+ wm::ActivateWindow(w2.get());
+ EXPECT_EQ(Workspace::TYPE_MANAGED, active_workspace()->type());
+ EXPECT_FALSE(w1->layer()->IsDrawn());
+ EXPECT_TRUE(w2->layer()->IsDrawn());
+ EXPECT_TRUE(w3->layer()->IsDrawn());
+}
+
+// Verifies Show()ing a minimized window that persists across all workspaces
+// unminimizes thew indow.
+TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) {
+ // Create a window that persists across all workspaces.
+ scoped_ptr<Window> w1(CreateTestWindow());
+ SetPersistsAcrossAllWorkspaces(
+ w1.get(),
+ WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
+ w1->Show();
+ wm::ActivateWindow(w1.get());
+ w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
+ EXPECT_FALSE(w1->IsVisible());
+ w1->Show();
+ EXPECT_TRUE(w1->IsVisible());
+}
+
} // namespace internal
} // namespace ash