Commit 732ef6e5 authored by skuhne@chromium.org's avatar skuhne@chromium.org

Fixing problem with edge swipe exiting immersive mode

BUG=378414
TEST=several unittests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274570 0039d316-1c4b-4281-b951-d872f2087c98
parent 785ff58b
...@@ -274,8 +274,13 @@ void ImmersiveFullscreenController::SetEnabled(WindowType window_type, ...@@ -274,8 +274,13 @@ void ImmersiveFullscreenController::SetEnabled(WindowType window_type,
EnableWindowObservers(enabled_); EnableWindowObservers(enabled_);
ash::wm::WindowState* window_state = wm::GetWindowState(native_window_);
// Auto hide the shelf in immersive fullscreen instead of hiding it. // Auto hide the shelf in immersive fullscreen instead of hiding it.
wm::GetWindowState(native_window_)->set_hide_shelf_when_fullscreen(!enabled); window_state->set_hide_shelf_when_fullscreen(!enabled);
// Update the window's immersive mode state for the window manager.
window_state->set_in_immersive_fullscreen(enabled);
Shell::GetInstance()->UpdateShelfVisibility(); Shell::GetInstance()->UpdateShelfVisibility();
if (enabled_) { if (enabled_) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_types.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -779,6 +780,20 @@ TEST_F(ImmersiveFullscreenControllerTest, EventsDoNotLeakToWindowUnderneath) { ...@@ -779,6 +780,20 @@ TEST_F(ImmersiveFullscreenControllerTest, EventsDoNotLeakToWindowUnderneath) {
EXPECT_EQ(window(), targeter->FindTargetForEvent(root, &touch2)); EXPECT_EQ(window(), targeter->FindTargetForEvent(root, &touch2));
} }
// Check that the window state gets properly marked for immersive fullscreen.
TEST_F(ImmersiveFullscreenControllerTest, WindowStateImmersiveFullscreen) {
ash::wm::WindowState* window_state = ash::wm::GetWindowState(window());
EXPECT_FALSE(window_state->in_immersive_fullscreen());
SetEnabled(true);
ASSERT_TRUE(controller()->IsEnabled());
EXPECT_TRUE(window_state->in_immersive_fullscreen());
SetEnabled(false);
ASSERT_FALSE(controller()->IsEnabled());
EXPECT_FALSE(window_state->in_immersive_fullscreen());
}
// Do not test under windows because focus testing is not reliable on // Do not test under windows because focus testing is not reliable on
// Windows. (crbug.com/79493) // Windows. (crbug.com/79493)
#if !defined(OS_WIN) #if !defined(OS_WIN)
......
...@@ -138,7 +138,7 @@ void MaximizeModeWindowManager::OnTouchEvent(ui::TouchEvent* event) { ...@@ -138,7 +138,7 @@ void MaximizeModeWindowManager::OnTouchEvent(ui::TouchEvent* event) {
return; return;
wm::WindowState* window_state = wm::GetWindowState(window); wm::WindowState* window_state = wm::GetWindowState(window);
if (!window_state->IsFullscreen()) if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen())
return; return;
// Test that the touch happened in the top or bottom lines. // Test that the touch happened in the top or bottom lines.
......
...@@ -1155,6 +1155,71 @@ TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) { ...@@ -1155,6 +1155,71 @@ TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) {
DestroyMaximizeModeWindowManager(); DestroyMaximizeModeWindowManager();
} }
// Test that an edge swipe from the top on an immersive mode window will not end
// full screen mode.
TEST_F(MaximizeModeWindowManagerTest, NoExitImmersiveModeWithEdgeSwipeFromTop) {
scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL,
gfx::Rect(10, 10, 200, 50)));
wm::WindowState* window_state = wm::GetWindowState(window.get());
wm::ActivateWindow(window.get());
CreateMaximizeModeWindowManager();
// Fullscreen the window.
wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
window_state->OnWMEvent(&event);
EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_FALSE(window_state->in_immersive_fullscreen());
EXPECT_EQ(window.get(), wm::GetActiveWindow());
window_state->set_in_immersive_fullscreen(true);
// Do an edge swipe top into screen.
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.GestureScrollSequence(gfx::Point(50, 0),
gfx::Point(50, 100),
base::TimeDelta::FromMilliseconds(20),
10);
// It should have not exited full screen or immersive mode.
EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_TRUE(window_state->in_immersive_fullscreen());
DestroyMaximizeModeWindowManager();
}
// Test that an edge swipe from the bottom will not end immersive mode.
TEST_F(MaximizeModeWindowManagerTest,
NoExitImmersiveModeWithEdgeSwipeFromBottom) {
scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL,
gfx::Rect(10, 10, 200, 50)));
wm::WindowState* window_state = wm::GetWindowState(window.get());
wm::ActivateWindow(window.get());
CreateMaximizeModeWindowManager();
// Fullscreen the window.
wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
window_state->OnWMEvent(&event);
EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_FALSE(window_state->in_immersive_fullscreen());
EXPECT_EQ(window.get(), wm::GetActiveWindow());
window_state->set_in_immersive_fullscreen(true);
EXPECT_TRUE(window_state->in_immersive_fullscreen());
// Do an edge swipe bottom into screen.
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
int y = Shell::GetPrimaryRootWindow()->bounds().bottom();
generator.GestureScrollSequence(gfx::Point(50, y),
gfx::Point(50, y - 100),
base::TimeDelta::FromMilliseconds(20),
10);
// The window should still be full screen and immersive.
EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_TRUE(window_state->in_immersive_fullscreen());
DestroyMaximizeModeWindowManager();
}
#endif // OS_WIN #endif // OS_WIN
} // namespace ash } // namespace ash
...@@ -90,6 +90,7 @@ WindowState::WindowState(aura::Window* window) ...@@ -90,6 +90,7 @@ WindowState::WindowState(aura::Window* window)
can_consume_system_keys_(false), can_consume_system_keys_(false),
top_row_keys_are_function_keys_(false), top_row_keys_are_function_keys_(false),
unminimize_to_restore_bounds_(false), unminimize_to_restore_bounds_(false),
in_immersive_fullscreen_(false),
hide_shelf_when_fullscreen_(true), hide_shelf_when_fullscreen_(true),
minimum_visibility_(false), minimum_visibility_(false),
can_be_dragged_(true), can_be_dragged_(true),
......
...@@ -267,6 +267,17 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -267,6 +267,17 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
top_row_keys_are_function_keys_ = value; top_row_keys_are_function_keys_ = value;
} }
// True if the window is in "immersive full screen mode" which is slightly
// different from the normal fullscreen mode by allowing the user to reveal
// the top portion of the window through a touch / mouse gesture. It might
// also allow the shelf to be shown in some situations.
bool in_immersive_fullscreen() const {
return in_immersive_fullscreen_;
}
void set_in_immersive_fullscreen(bool enable) {
in_immersive_fullscreen_ = enable;
}
// Creates and takes ownership of a pointer to DragDetails when resizing is // Creates and takes ownership of a pointer to DragDetails when resizing is
// active. This should be done before a resizer gets created. // active. This should be done before a resizer gets created.
void CreateDragDetails(aura::Window* window, void CreateDragDetails(aura::Window* window,
...@@ -342,6 +353,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -342,6 +353,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
scoped_ptr<DragDetails> drag_details_; scoped_ptr<DragDetails> drag_details_;
bool unminimize_to_restore_bounds_; bool unminimize_to_restore_bounds_;
bool in_immersive_fullscreen_;
bool hide_shelf_when_fullscreen_; bool hide_shelf_when_fullscreen_;
bool minimum_visibility_; bool minimum_visibility_;
bool can_be_dragged_; bool can_be_dragged_;
......
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