diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 22:05:56 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 22:05:56 +0000 |
commit | b2b46ac85b0fca2481e715a6181d3b448ed2da6c (patch) | |
tree | 15228bccd19f9115e0a3b00708db7c228b2a650d /ash | |
parent | c0f759b1863f24bbcdd5679623a33380874cbb69 (diff) | |
download | chromium_src-b2b46ac85b0fca2481e715a6181d3b448ed2da6c.zip chromium_src-b2b46ac85b0fca2481e715a6181d3b448ed2da6c.tar.gz chromium_src-b2b46ac85b0fca2481e715a6181d3b448ed2da6c.tar.bz2 |
Minimize panels on entering fullscreen and exit fullscreen on selecting another window.
BUG=313919
TEST=WindowSelectorTest.FullscreenWindow, PanelLayoutManagerTest.PanelsHideAndRestoreWithShelf
TEST=Navigate to a page using the fullscreen API (i.e. http://blogs.sitepointstatic.com/examples/tech/full-screen/index.html) and alt tab from the fullscreen window. You should be able to switch to another window or a panel which was previously open.
Review URL: https://codereview.chromium.org/64853007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234922 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/root_window_controller.cc | 6 | ||||
-rw-r--r-- | ash/root_window_controller.h | 1 | ||||
-rw-r--r-- | ash/wm/overview/window_selector.cc | 2 | ||||
-rw-r--r-- | ash/wm/overview/window_selector_controller.cc | 15 | ||||
-rw-r--r-- | ash/wm/overview/window_selector_unittest.cc | 33 | ||||
-rw-r--r-- | ash/wm/panels/panel_layout_manager.cc | 53 | ||||
-rw-r--r-- | ash/wm/panels/panel_layout_manager.h | 10 | ||||
-rw-r--r-- | ash/wm/panels/panel_layout_manager_unittest.cc | 16 |
8 files changed, 116 insertions, 20 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index c068809..d66f169 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -521,6 +521,12 @@ const aura::Window* RootWindowController::GetTopmostFullscreenWindow() const { return NULL; } +aura::Window* RootWindowController::GetTopmostFullscreenWindow() { + return const_cast<aura::Window*>( + const_cast<const RootWindowController*>(this)-> + GetTopmostFullscreenWindow()); +} + void RootWindowController::ActivateKeyboard( keyboard::KeyboardController* keyboard_controller) { if (!keyboard::IsKeyboardEnabled() || diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 0ccc1d3..606cc50 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -219,6 +219,7 @@ class ASH_EXPORT RootWindowController : public ShellObserver { // Returns the window, if any, which is in fullscreen mode. If multiple // windows are in fullscreen state, the topmost one is preferred. const aura::Window* GetTopmostFullscreenWindow() const; + aura::Window* GetTopmostFullscreenWindow(); // Activate virtual keyboard on current root window controller. void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller); diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc index a7818f5..8015f77 100644 --- a/ash/wm/overview/window_selector.cc +++ b/ash/wm/overview/window_selector.cc @@ -347,11 +347,11 @@ void WindowSelector::Step(WindowSelector::Direction direction) { } void WindowSelector::SelectWindow() { - ResetFocusRestoreWindow(false); SelectWindow(windows_[selected_window_]->SelectionWindow()); } void WindowSelector::SelectWindow(aura::Window* window) { + ResetFocusRestoreWindow(false); if (showing_window_ && showing_window_->window() == window) showing_window_->CancelRestore(); ScopedVector<WindowSelectorItem>::iterator iter = diff --git a/ash/wm/overview/window_selector_controller.cc b/ash/wm/overview/window_selector_controller.cc index d56c463..e5ca77d 100644 --- a/ash/wm/overview/window_selector_controller.cc +++ b/ash/wm/overview/window_selector_controller.cc @@ -4,13 +4,16 @@ #include "ash/wm/overview/window_selector_controller.h" +#include "ash/root_window_controller.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/overview/window_selector.h" +#include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "base/metrics/histogram.h" +#include "ui/aura/window.h" namespace ash { @@ -69,6 +72,18 @@ bool WindowSelectorController::IsSelecting() { void WindowSelectorController::OnWindowSelected(aura::Window* window) { window_selector_.reset(); + + // If there is a fullscreen window on this display and it was not selected + // it should exit fullscreen mode. + internal::RootWindowController* controller = + internal::GetRootWindowController(window->GetRootWindow()); + aura::Window* fullscreen_window = NULL; + if (controller) + fullscreen_window = controller->GetTopmostFullscreenWindow(); + if (fullscreen_window && fullscreen_window != window) { + wm::GetWindowState(fullscreen_window)->ToggleFullscreen(); + } + wm::ActivateWindow(window); last_selection_time_ = base::Time::Now(); } diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc index 38916fd..29c8cc7 100644 --- a/ash/wm/overview/window_selector_unittest.cc +++ b/ash/wm/overview/window_selector_unittest.cc @@ -259,6 +259,39 @@ TEST_F(WindowSelectorTest, Basic) { EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); } +// Tests entering overview mode with two windows and selecting one. +TEST_F(WindowSelectorTest, FullscreenWindow) { + gfx::Rect bounds(0, 0, 400, 400); + scoped_ptr<aura::Window> window1(CreateWindow(bounds)); + scoped_ptr<aura::Window> window2(CreateWindow(bounds)); + scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); + wm::ActivateWindow(window1.get()); + + wm::GetWindowState(window1.get())->ToggleFullscreen(); + // The panel is hidden in fullscreen mode. + EXPECT_FALSE(panel1->IsVisible()); + EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); + + // Enter overview and select the fullscreen window. + ToggleOverview(); + + // The panel becomes temporarily visible for the overview. + EXPECT_TRUE(panel1->IsVisible()); + ClickWindow(window1.get()); + + // The window is still fullscreen as it was selected. The panel should again + // be hidden. + EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); + EXPECT_FALSE(panel1->IsVisible()); + + // Entering overview and selecting another window should exit fullscreen. + // TODO(flackr): Currently the panel remains hidden, but should become visible + // again. + ToggleOverview(); + ClickWindow(window2.get()); + EXPECT_FALSE(wm::GetWindowState(window1.get())->IsFullscreen()); +} + // Tests that the shelf dimming state is removed while in overview and restored // on exiting overview. TEST_F(WindowSelectorTest, OverviewUndimsShelf) { diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc index 4d0f0d5..ee6a75e 100644 --- a/ash/wm/panels/panel_layout_manager.cc +++ b/ash/wm/panels/panel_layout_manager.cc @@ -28,6 +28,7 @@ #include "ui/aura/client/window_tree_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" +#include "ui/aura/window_tracker.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/canvas.h" #include "ui/gfx/rect.h" @@ -260,7 +261,6 @@ PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) dragged_panel_(NULL), launcher_(NULL), shelf_layout_manager_(NULL), - shelf_hidden_(false), last_active_panel_(NULL), weak_factory_(this) { DCHECK(panel_container); @@ -461,10 +461,18 @@ void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { void PanelLayoutManager::OnWindowShowTypeChanged( wm::WindowState* window_state, wm::WindowShowType old_type) { - // The window property will still be set, but no actual change will occur - // until WillChangeVisibilityState is called when the shelf is visible again. - if (shelf_hidden_) + // If the shelf is currently hidden then windows will not actually be shown + // but the set to restore when the shelf becomes visible is updated. + if (restore_windows_on_shelf_visible_) { + if (window_state->IsMinimized()) { + MinimizePanel(window_state->window()); + restore_windows_on_shelf_visible_->Remove(window_state->window()); + } else { + restore_windows_on_shelf_visible_->Add(window_state->window()); + } return; + } + if (window_state->IsMinimized()) MinimizePanel(window_state->window()); else @@ -506,17 +514,31 @@ void PanelLayoutManager::WillChangeVisibilityState( // On entering / leaving full screen mode the shelf visibility state is // changed to / from SHELF_HIDDEN. In this state, panel windows should hide // to allow the full-screen application to use the full screen. - shelf_hidden_ = new_state == ash::SHELF_HIDDEN; + bool shelf_hidden = new_state == ash::SHELF_HIDDEN; + if (!shelf_hidden) { + if (restore_windows_on_shelf_visible_) { + scoped_ptr<aura::WindowTracker> restore_windows( + restore_windows_on_shelf_visible_.Pass()); + for (aura::WindowTracker::Windows::const_iterator iter = + restore_windows->windows().begin(); iter != + restore_windows->windows().end(); ++iter) { + RestorePanel(*iter); + } + } + return; + } + + if (restore_windows_on_shelf_visible_) + return; + scoped_ptr<aura::WindowTracker> minimized_windows(new aura::WindowTracker); for (PanelList::iterator iter = panel_windows_.begin(); iter != panel_windows_.end(); ++iter) { - if (shelf_hidden_) { - if (iter->window->IsVisible()) - MinimizePanel(iter->window); - } else { - if (!wm::GetWindowState(iter->window)->IsMinimized()) - RestorePanel(iter->window); + if (iter->window->IsVisible()) { + minimized_windows->Add(iter->window); + wm::GetWindowState(iter->window)->Minimize(); } } + restore_windows_on_shelf_visible_ = minimized_windows.Pass(); } //////////////////////////////////////////////////////////////////////////////// @@ -585,12 +607,11 @@ void PanelLayoutManager::Relayout() { continue; } - // If the shelf is currently hidden (full-screen mode), hide panel until + // If the shelf is currently hidden (full-screen mode), minimize panel until // full-screen mode is exited. - if (shelf_hidden_) { - // The call to Hide does not set the minimize property, so the window will - // be restored when the shelf becomes visible again. - panel->Hide(); + if (restore_windows_on_shelf_visible_) { + wm::GetWindowState(panel)->Minimize(); + restore_windows_on_shelf_visible_->Add(panel); continue; } diff --git a/ash/wm/panels/panel_layout_manager.h b/ash/wm/panels/panel_layout_manager.h index 7ffe81a..042d285 100644 --- a/ash/wm/panels/panel_layout_manager.h +++ b/ash/wm/panels/panel_layout_manager.h @@ -25,6 +25,7 @@ namespace aura { class Window; +class WindowTracker; } namespace gfx { @@ -175,9 +176,12 @@ class ASH_EXPORT PanelLayoutManager Launcher* launcher_; // The shelf layout manager being observed for visibility changes. ShelfLayoutManager* shelf_layout_manager_; - // Tracks the visibility of the shelf. Defaults to false when there is no - // shelf. - bool shelf_hidden_; + + // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the + // set of panel windows which have been temporarily hidden and need to be + // restored when the shelf becomes visible again. + scoped_ptr<aura::WindowTracker> restore_windows_on_shelf_visible_; + // The last active panel. Used to maintain stacking order even if no panels // are currently focused. aura::Window* last_active_panel_; diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc index 4bee3c4..88bba1b 100644 --- a/ash/wm/panels/panel_layout_manager_unittest.cc +++ b/ash/wm/panels/panel_layout_manager_unittest.cc @@ -21,6 +21,7 @@ #include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" +#include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_util.h" #include "base/basictypes.h" #include "base/command_line.h" @@ -771,6 +772,21 @@ TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { EXPECT_FALSE(w2->IsVisible()); EXPECT_FALSE(w3->IsVisible()); + // While in full-screen mode, the panel windows should still be in the + // switchable window list - http://crbug.com/313919. + MruWindowTracker::WindowList switchable_window_list = + Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); + EXPECT_EQ(3u, switchable_window_list.size()); + EXPECT_NE(switchable_window_list.end(), + std::find(switchable_window_list.begin(), switchable_window_list.end(), + w1.get())); + EXPECT_NE(switchable_window_list.end(), + std::find(switchable_window_list.begin(), switchable_window_list.end(), + w2.get())); + EXPECT_NE(switchable_window_list.end(), + std::find(switchable_window_list.begin(), switchable_window_list.end(), + w3.get())); + SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_VISIBLE); RunAllPendingInMessageLoop(); |