diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 00:23:16 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 00:23:16 +0000 |
commit | c066b8d33fe09b6778f4e084a1c18c9a863f19a9 (patch) | |
tree | 3c99988a12af8422127ac9eca80a97cee39d9b95 /ash/wm/workspace | |
parent | eb9a40bfbbd396c8dd7c367f09abab0949e3f212 (diff) | |
download | chromium_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
Diffstat (limited to 'ash/wm/workspace')
-rw-r--r-- | ash/wm/workspace/always_on_top_layout_manager.cc | 94 | ||||
-rw-r--r-- | ash/wm/workspace/always_on_top_layout_manager.h | 48 |
2 files changed, 142 insertions, 0 deletions
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_ |