Commit e302f085 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

workspace: End clamshell split view on double clicking window inner edge

Overview and clamshell split view shall end if you double click the edge
of the split view window where it meets the overview grid.

Fixed: 1006950
Change-Id: I24c1901814724cf24275e947749baf5a408bb648
Bug: 1006950
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1951124
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722630}
parent 3288ac49
......@@ -5541,6 +5541,24 @@ TEST_P(SplitViewOverviewSessionInClamshellTest, ResizeWindowTest) {
EXPECT_FALSE(split_view_controller()->InSplitViewMode());
}
// Test that overview and clamshell split view end if you double click the edge
// of the split view window where it meets the overview grid.
TEST_P(SplitViewOverviewSessionInClamshellTest, HorizontalMaximizeTest) {
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> snapped_window(
CreateWindowWithHitTestComponent(HTRIGHT, bounds));
std::unique_ptr<aura::Window> overview_window = CreateTestWindow(bounds);
ToggleOverview();
split_view_controller()->SnapWindow(snapped_window.get(),
SplitViewController::LEFT);
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
ui::test::EventGenerator(Shell::GetPrimaryRootWindow(), snapped_window.get())
.DoubleClickLeftButton();
EXPECT_FALSE(overview_controller()->InOverviewSession());
EXPECT_FALSE(split_view_controller()->InSplitViewMode());
}
// Test that when laptop splitview mode is active, moving the snapped window
// will end splitview and overview at the same time.
TEST_P(SplitViewOverviewSessionInClamshellTest, MoveWindowTest) {
......
......@@ -5,6 +5,10 @@
#include "ash/wm/workspace/workspace_event_handler.h"
#include "ash/public/cpp/touch_uma.h"
#include "ash/shell.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_session.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/wm_event.h"
......@@ -118,12 +122,34 @@ void WorkspaceEventHandler::HandleResizeDoubleClick(WindowState* target_state,
if (component == HTBOTTOM || component == HTTOP) {
base::RecordAction(base::UserMetricsAction(
"WindowBorder_ClickTogglesSingleAxisMaximize"));
const WMEvent wm_event(WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE);
target_state->OnWMEvent(&wm_event);
event->StopPropagation();
} else if (component == HTLEFT || component == HTRIGHT) {
base::RecordAction(base::UserMetricsAction(
"WindowBorder_ClickTogglesSingleAxisMaximize"));
// If overview is in session, meaning that |target| is a clamshell split
// view window, then end overview (thereby ending clamshell split view).
OverviewController* overview_controller =
Shell::Get()->overview_controller();
if (overview_controller->InOverviewSession()) {
DCHECK(SplitViewController::Get(target)->InClamshellSplitViewMode());
DCHECK(SplitViewController::Get(target)->IsWindowInSplitView(target));
// For |target| to have a snapped window state (in split view or not),
// it must have no maximum size (see |WindowState::CanSnap|). That is
// important here because when |target| has a maximum width, the
// |WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE| event will do nothing, meaning
// it would be rather inappropriate to end overview as below, and of
// course it would be blatantly inappropriate to make the following call
// to |OverviewSession::SetWindowListNotAnimatedWhenExiting|.
DCHECK_EQ(gfx::Size(), target->delegate()->GetMaximumSize());
overview_controller->overview_session()
->SetWindowListNotAnimatedWhenExiting(target->GetRootWindow());
overview_controller->EndOverview();
}
const WMEvent wm_event(WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE);
target_state->OnWMEvent(&wm_event);
event->StopPropagation();
......
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