summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 00:23:16 +0000
committerstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 00:23:16 +0000
commitc066b8d33fe09b6778f4e084a1c18c9a863f19a9 (patch)
tree3c99988a12af8422127ac9eca80a97cee39d9b95
parenteb9a40bfbbd396c8dd7c367f09abab0949e3f212 (diff)
downloadchromium_src-c066b8d33fe09b6778f4e084a1c18c9a863f19a9.zip
chromium_src-c066b8d33fe09b6778f4e084a1c18c9a863f19a9.tar.gz
chromium_src-c066b8d33fe09b6778f4e084a1c18c9a863f19a9.tar.bz2
Set panels windows to always be on top.
Make always on top windows part of WorkspaceLayoutManager but not part of any actual workspace. BUG=119794 TEST=Test minimizing, maximizing, and moving popup windows and panels in normal and maximized mode. Review URL: https://chromiumcodereview.appspot.com/9836089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128846 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/app_list/app_list.cc28
-rw-r--r--ash/app_list/app_list.h1
-rw-r--r--ash/app_list/app_list_view.cc3
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/shell.cc11
-rw-r--r--ash/shell_window_ids.h19
-rw-r--r--ash/wm/activation_controller.cc1
-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--chrome/browser/ui/views/frame/browser_frame.cc9
10 files changed, 198 insertions, 18 deletions
diff --git a/ash/app_list/app_list.cc b/ash/app_list/app_list.cc
index c4771b6f..6972eb0 100644
--- a/ash/app_list/app_list.cc
+++ b/ash/app_list/app_list.cc
@@ -21,7 +21,7 @@ namespace internal {
namespace {
-const float kDefaultContainerAnimationScaleFactor = 1.05f;
+const float kContainerAnimationScaleFactor = 1.05f;
// Duration for both default container and app list animation in milliseconds.
const int kAnimationDurationMs = 130;
@@ -133,14 +133,10 @@ void AppList::ScheduleAnimation() {
}
-void AppList::ScheduleBrowserWindowsAnimation() {
- aura::Window* default_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_DefaultContainer);
- // |default_container| could be NULL during Shell shutdown.
- if (!default_container)
- return;
-
- ui::Layer* layer = default_container->layer();
+void AppList::ScheduleBrowserWindowsAnimationForContainer(
+ aura::Window* container) {
+ DCHECK(container);
+ ui::Layer* layer = container->layer();
layer->GetAnimator()->StopAnimating();
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
@@ -154,10 +150,22 @@ void AppList::ScheduleBrowserWindowsAnimation() {
ui::GetScaleTransform(
gfx::Point(layer->bounds().width() / 2,
layer->bounds().height() / 2),
- kDefaultContainerAnimationScaleFactor) :
+ kContainerAnimationScaleFactor) :
ui::Transform());
}
+void AppList::ScheduleBrowserWindowsAnimation() {
+ // Note: containers could be NULL during Shell shutdown.
+ aura::Window* default_container = Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
+ if (default_container)
+ ScheduleBrowserWindowsAnimationForContainer(default_container);
+ aura::Window* always_on_top_container = Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_AlwaysOnTopContainer);
+ if (always_on_top_container)
+ ScheduleBrowserWindowsAnimationForContainer(always_on_top_container);
+}
+
void AppList::ScheduleDimmingAnimation() {
ui::Layer* layer = GetLayer(view_->GetWidget());
layer->GetAnimator()->StopAnimating();
diff --git a/ash/app_list/app_list.h b/ash/app_list/app_list.h
index 34a96c1..04656bc 100644
--- a/ash/app_list/app_list.h
+++ b/ash/app_list/app_list.h
@@ -57,6 +57,7 @@ class AppList : public aura::EventFilter,
// is the reverse of the showing animation.
void ScheduleAnimation();
+ void ScheduleBrowserWindowsAnimationForContainer(aura::Window* container);
void ScheduleBrowserWindowsAnimation();
void ScheduleDimmingAnimation();
void ScheduleAppListAnimation();
diff --git a/ash/app_list/app_list_view.cc b/ash/app_list/app_list_view.cc
index 80a25a6..26ca934 100644
--- a/ash/app_list/app_list_view.cc
+++ b/ash/app_list/app_list_view.cc
@@ -9,6 +9,7 @@
#include "ash/app_list/app_list_model_view.h"
#include "ash/app_list/app_list_view_delegate.h"
#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/screen.h"
@@ -76,6 +77,8 @@ void AppListView::Init(const gfx::Rect& bounds) {
widget_params.delegate = this;
widget_params.keep_on_top = true;
widget_params.transparent = true;
+ widget_params.parent = Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_AppListContainer);
views::Widget* widget = new views::Widget;
widget->Init(widget_params);
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 412c988..3bccd1a 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -255,6 +255,8 @@
'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 b86ade2..4c3282b 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -61,6 +61,7 @@
#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_controller.h"
#include "ash/wm/workspace/workspace_event_filter.h"
#include "ash/wm/workspace/workspace_layout_manager.h"
@@ -173,6 +174,10 @@ void CreateSpecialContainers(aura::RootWindow* root_window) {
"LauncherContainer",
non_lock_screen_containers);
+ CreateContainer(internal::kShellWindowId_AppListContainer,
+ "AppListContainer",
+ non_lock_screen_containers);
+
aura::Window* modal_container = CreateContainer(
internal::kShellWindowId_SystemModalContainer,
"SystemModalContainer",
@@ -888,6 +893,12 @@ void Shell::InitLayoutManagers() {
shelf_layout_manager->set_workspace_manager(
workspace_controller_->workspace_manager());
+ aura::Window* always_on_top_container =
+ GetContainer(internal::kShellWindowId_AlwaysOnTopContainer);
+ always_on_top_container->SetLayoutManager(
+ new internal::AlwaysOnTopLayoutManager(
+ always_on_top_container->GetRootWindow()));
+
// Create desktop background widget.
// TODO(bshe): We should be able to use OnDesktopBackgroundChanged function
// here after issue 117244 got fixed.
diff --git a/ash/shell_window_ids.h b/ash/shell_window_ids.h
index e6535ed..192c577 100644
--- a/ash/shell_window_ids.h
+++ b/ash/shell_window_ids.h
@@ -47,31 +47,34 @@ const int kShellWindowId_PanelContainer = 7;
// The container for the launcher.
const int kShellWindowId_LauncherContainer = 8;
+// The container for the app list.
+const int kShellWindowId_AppListContainer = 9;
+
// The container for user-specific modal windows.
-const int kShellWindowId_SystemModalContainer = 9;
+const int kShellWindowId_SystemModalContainer = 10;
// The container for the lock screen.
-const int kShellWindowId_LockScreenContainer = 10;
+const int kShellWindowId_LockScreenContainer = 11;
// The container for the lock screen modal windows.
-const int kShellWindowId_LockSystemModalContainer = 11;
+const int kShellWindowId_LockSystemModalContainer = 12;
// The container for the status area.
-const int kShellWindowId_StatusContainer = 12;
+const int kShellWindowId_StatusContainer = 13;
// The container for menus.
-const int kShellWindowId_MenuContainer = 13;
+const int kShellWindowId_MenuContainer = 14;
// The container for drag/drop images and tooltips.
-const int kShellWindowId_DragImageAndTooltipContainer = 14;
+const int kShellWindowId_DragImageAndTooltipContainer = 15;
// The container for bubbles briefly overlaid onscreen to show settings changes
// (volume, brightness, etc.).
-const int kShellWindowId_SettingBubbleContainer = 15;
+const int kShellWindowId_SettingBubbleContainer = 16;
// The container for special components overlaid onscreen, such as the
// region selector for partial screenshots.
-const int kShellWindowId_OverlayContainer = 16;
+const int kShellWindowId_OverlayContainer = 17;
} // namespace internal
diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc
index 6c68483..1d35998 100644
--- a/ash/wm/activation_controller.cc
+++ b/ash/wm/activation_controller.cc
@@ -31,6 +31,7 @@ const int kWindowContainerIds[] = {
kShellWindowId_AlwaysOnTopContainer,
kShellWindowId_SettingBubbleContainer,
kShellWindowId_DefaultContainer,
+ kShellWindowId_AppListContainer,
// Panel, launcher and status are intentionally checked after other
// containers even though these layers are higher. The user expects their
diff --git a/ash/wm/workspace/always_on_top_layout_manager.cc b/ash/wm/workspace/always_on_top_layout_manager.cc
new file mode 100644
index 0000000..25655bc
--- /dev/null
+++ b/ash/wm/workspace/always_on_top_layout_manager.cc
@@ -0,0 +1,94 @@
+// 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
new file mode 100644
index 0000000..97636eb
--- /dev/null
+++ b/ash/wm/workspace/always_on_top_layout_manager.h
@@ -0,0 +1,48 @@
+// 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/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index c215551..8fd042b 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -63,6 +63,15 @@ void BrowserFrame::InitBrowserFrame() {
// Aura frames are translucent.
params.transparent = true;
#endif
+#if defined(USE_ASH)
+ // Note: browser_view_->IsPanel() always returns false on Ash because the
+ // BrowserView is not a panel. For Browser child panels and popups, we want
+ // to set them to be always on top.
+ if (browser_view_->browser()->is_type_panel() &&
+ browser_view_->browser()->app_type() == Browser::APP_TYPE_CHILD) {
+ params.keep_on_top = true;
+ }
+#endif
Init(params);
native_browser_frame_->InitSystemContextMenu();