Commit 00cfda9f authored by skuhne@chromium.org's avatar skuhne@chromium.org

Fixing problem with the maximize mode where MultiProfile windows do not get properly handled

BUG=391334
TEST=visual

Review URL: https://codereview.chromium.org/437213005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287949 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f9980eb
...@@ -220,6 +220,11 @@ bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const { ...@@ -220,6 +220,11 @@ bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const {
return maximize_mode_window_manager_.get() != NULL; return maximize_mode_window_manager_.get() != NULL;
} }
void MaximizeModeController::AddWindow(aura::Window* window) {
if (IsMaximizeModeWindowManagerEnabled())
maximize_mode_window_manager_->AddWindow(window);
}
void MaximizeModeController::Shutdown() { void MaximizeModeController::Shutdown() {
maximize_mode_window_manager_.reset(); maximize_mode_window_manager_.reset();
Shell::GetInstance()->OnMaximizeModeEnded(); Shell::GetInstance()->OnMaximizeModeEnded();
......
...@@ -33,6 +33,9 @@ class MaximizeModeControllerTest; ...@@ -33,6 +33,9 @@ class MaximizeModeControllerTest;
class ScopedDisableInternalMouseAndKeyboard; class ScopedDisableInternalMouseAndKeyboard;
class MaximizeModeWindowManager; class MaximizeModeWindowManager;
class MaximizeModeWindowManagerTest; class MaximizeModeWindowManagerTest;
namespace test {
class MultiUserWindowManagerChromeOSTest;
}
// MaximizeModeController listens to accelerometer events and automatically // MaximizeModeController listens to accelerometer events and automatically
// enters and exits maximize mode when the lid is opened beyond the triggering // enters and exits maximize mode when the lid is opened beyond the triggering
...@@ -92,6 +95,12 @@ class ASH_EXPORT MaximizeModeController ...@@ -92,6 +95,12 @@ class ASH_EXPORT MaximizeModeController
// Test if the MaximizeModeWindowManager is enabled or not. // Test if the MaximizeModeWindowManager is enabled or not.
bool IsMaximizeModeWindowManagerEnabled() const; bool IsMaximizeModeWindowManagerEnabled() const;
// Add a special window to the MaximizeModeWindowManager for tracking. This is
// only required for special windows which are handled by other window
// managers like the |MultiUserWindowManager|.
// If the maximize mode is not enabled no action will be performed.
void AddWindow(aura::Window* window);
// TODO(jonross): move this into the destructor. Currently separated as // TODO(jonross): move this into the destructor. Currently separated as
// ShellOberver notifies of maximize mode ending, and the observers end up // ShellOberver notifies of maximize mode ending, and the observers end up
// attempting to access MaximizeModeController via the Shell. If done in // attempting to access MaximizeModeController via the Shell. If done in
...@@ -122,6 +131,7 @@ class ASH_EXPORT MaximizeModeController ...@@ -122,6 +131,7 @@ class ASH_EXPORT MaximizeModeController
private: private:
friend class MaximizeModeControllerTest; friend class MaximizeModeControllerTest;
friend class MaximizeModeWindowManagerTest; friend class MaximizeModeWindowManagerTest;
friend class test::MultiUserWindowManagerChromeOSTest;
// Set the TickClock. This is only to be used by tests that need to // Set the TickClock. This is only to be used by tests that need to
// artificially and deterministically control the current time. // artificially and deterministically control the current time.
......
...@@ -54,6 +54,18 @@ int MaximizeModeWindowManager::GetNumberOfManagedWindows() { ...@@ -54,6 +54,18 @@ int MaximizeModeWindowManager::GetNumberOfManagedWindows() {
return window_state_map_.size(); return window_state_map_.size();
} }
void MaximizeModeWindowManager::AddWindow(aura::Window* window) {
// Only add the window if it is a direct dependent of a container window
// and not yet tracked.
if (!ShouldHandleWindow(window) ||
window_state_map_.find(window) != window_state_map_.end() ||
!IsContainerWindow(window->parent())) {
return;
}
MaximizeAndTrackWindow(window);
}
void MaximizeModeWindowManager::WindowStateDestroyed(aura::Window* window) { void MaximizeModeWindowManager::WindowStateDestroyed(aura::Window* window) {
// At this time ForgetWindow() should already have been called. If not, // At this time ForgetWindow() should already have been called. If not,
// someone else must have replaced the "window manager's state object". // someone else must have replaced the "window manager's state object".
......
...@@ -42,6 +42,12 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver, ...@@ -42,6 +42,12 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
// Returns the number of maximized & tracked windows by this manager. // Returns the number of maximized & tracked windows by this manager.
int GetNumberOfManagedWindows(); int GetNumberOfManagedWindows();
// Adds a window which needs to be maximized. This is used by other window
// managers for windows which needs to get tracked due to (upcoming) state
// changes.
// The call gets ignored if the window was already or should not be handled.
void AddWindow(aura::Window* window);
// Called from a window state object when it gets destroyed. // Called from a window state object when it gets destroyed.
void WindowStateDestroyed(aura::Window* window); void WindowStateDestroyed(aura::Window* window);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray_notifier.h" #include "ash/system/tray/system_tray_notifier.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
...@@ -692,6 +693,13 @@ void MultiUserWindowManagerChromeOS::SetWindowVisible( ...@@ -692,6 +693,13 @@ void MultiUserWindowManagerChromeOS::SetWindowVisible(
aura::Window* window, aura::Window* window,
bool visible, bool visible,
int animation_time_in_ms) { int animation_time_in_ms) {
// The MaximizeModeWindowManager will not handle invisible windows since they
// are not user activatable. Since invisible windows are not being tracked,
// we tell it to maximize / track this window now before it gets shown, to
// reduce animation jank from multiple resizes.
if (visible)
ash::Shell::GetInstance()->maximize_mode_controller()->AddWindow(window);
AnimationSetter animation_setter( AnimationSetter animation_setter(
window, window,
GetAdjustedAnimationTimeInMS(animation_time_in_ms)); GetAdjustedAnimationTimeInMS(animation_time_in_ms));
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/test_session_state_delegate.h" #include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h" #include "ash/test/test_shell_delegate.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h" #include "ash/wm/wm_event.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -132,6 +134,19 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase { ...@@ -132,6 +134,19 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase {
window); window);
} }
// Create a maximize mode window manager.
ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
EXPECT_FALSE(maximize_mode_window_manager());
Shell::GetInstance()->maximize_mode_controller()->
EnableMaximizeModeWindowManager(true);
return maximize_mode_window_manager();
}
ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
return Shell::GetInstance()->maximize_mode_controller()->
maximize_mode_window_manager_.get();
}
private: private:
// These get created for each session. // These get created for each session.
std::vector<aura::Window*> window_; std::vector<aura::Window*> window_;
...@@ -142,6 +157,9 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase { ...@@ -142,6 +157,9 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase {
// The session state delegate. // The session state delegate.
ash::test::TestSessionStateDelegate* session_state_delegate_; ash::test::TestSessionStateDelegate* session_state_delegate_;
// The maximized window manager (if enabled).
scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_;
DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest); DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest);
}; };
...@@ -640,6 +658,30 @@ TEST_F(MultiUserWindowManagerChromeOSTest, PreserveInitialVisibility) { ...@@ -640,6 +658,30 @@ TEST_F(MultiUserWindowManagerChromeOSTest, PreserveInitialVisibility) {
EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus()); EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus());
} }
// Test that in case of an activated maximize mode, windows from other users get
// maximized after a user switch.
TEST_F(MultiUserWindowManagerChromeOSTest, MaximizeModeInteraction) {
SetUpForThisManyWindows(2);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
EXPECT_FALSE(wm::GetWindowState(window(0))->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized());
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized());
// After we start switching to B, the windows of user B should maximize.
StartUserTransitionAnimation("B");
EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(window(1))->IsMaximized());
}
// Test that a system modal dialog will switch to the desktop of the owning // Test that a system modal dialog will switch to the desktop of the owning
// user. // user.
TEST_F(MultiUserWindowManagerChromeOSTest, SwitchUsersUponModalityChange) { TEST_F(MultiUserWindowManagerChromeOSTest, SwitchUsersUponModalityChange) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment