Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1588)

Unified Diff: ash/wm/maximize_mode/maximize_mode_window_state.cc

Issue 2918403006: CrOS Tablet Window management - Split Screen part I (Closed)
Patch Set: Add unittests. Will split the CL into two CLs. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_state.h ('k') | ash/wm/overview/overview_animation_type.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_mode/maximize_mode_window_state.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc
index 989fff71822c8b40e44aafde767fd93ab2670b50..8befd20fc28e0da4d7b7e1910a184983bc7c25c7 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc
@@ -11,6 +11,7 @@
#include "ash/shell.h"
#include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
#include "ash/wm/screen_pinning_controller.h"
+#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/window_animation_types.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state_util.h"
@@ -67,11 +68,36 @@ gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent,
return work_area_in_parent;
}
+// Returns true if the window can snap in maximized mode.
+bool CanSnap(wm::WindowState* window_state) {
+ // If split view mode is not allowed in maximized mode, do not allow snap
+ // window.
+ if (!SplitViewController::ShouldAllowSplitView())
+ return false;
+ return window_state->CanSnap();
+}
+
// Returns the maximized/full screen and/or centered bounds of a window.
gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) {
if (state_object->IsFullscreen() || state_object->IsPinned())
return ScreenUtil::GetDisplayBoundsInParent(state_object->window());
+ if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) {
+ DCHECK(CanSnap(state_object));
+ return Shell::Get()
+ ->split_view_controller()
+ ->GetSnappedWindowBoundsInParent(state_object->window(),
+ SplitViewController::LEFT_SNAPPED);
+ }
+
+ if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) {
+ DCHECK(CanSnap(state_object));
+ return Shell::Get()
+ ->split_view_controller()
+ ->GetSnappedWindowBoundsInParent(state_object->window(),
+ SplitViewController::RIGHT_SNAPPED);
+ }
+
gfx::Rect bounds_in_parent;
// Make the window as big as possible.
if (state_object->CanMaximize() || state_object->CanResize()) {
@@ -169,13 +195,23 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
case wm::WM_EVENT_CYCLE_SNAP_LEFT:
case wm::WM_EVENT_CYCLE_SNAP_RIGHT:
case wm::WM_EVENT_CENTER:
- case wm::WM_EVENT_SNAP_LEFT:
- case wm::WM_EVENT_SNAP_RIGHT:
case wm::WM_EVENT_NORMAL:
case wm::WM_EVENT_MAXIMIZE:
UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state),
true);
return;
+ case wm::WM_EVENT_SNAP_LEFT:
+ UpdateWindow(window_state,
+ GetSnappedWindowStateType(
+ window_state, wm::WINDOW_STATE_TYPE_LEFT_SNAPPED),
+ true);
+ return;
+ case wm::WM_EVENT_SNAP_RIGHT:
+ UpdateWindow(window_state,
+ GetSnappedWindowStateType(
+ window_state, wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED),
+ true);
+ return;
case wm::WM_EVENT_MINIMIZE:
UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_MINIMIZED, true);
return;
@@ -274,7 +310,9 @@ void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state,
target_state == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED ||
(target_state == wm::WINDOW_STATE_TYPE_NORMAL &&
!window_state->CanMaximize()) ||
- target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN);
+ target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN ||
+ target_state == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ||
+ target_state == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
if (current_state_type_ == target_state) {
if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED)
@@ -295,6 +333,14 @@ void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state,
window_state->window()->Hide();
if (window_state->IsActive())
window_state->Deactivate();
+ } else if (target_state == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) {
+ window_state->SetBoundsDirectAnimated(
+ Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent(
+ window_state->window(), SplitViewController::LEFT_SNAPPED));
+ } else if (target_state == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) {
+ window_state->SetBoundsDirectAnimated(
+ Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent(
+ window_state->window(), SplitViewController::RIGHT_SNAPPED));
} else {
UpdateBounds(window_state, animated);
}
@@ -324,6 +370,15 @@ wm::WindowStateType MaximizeModeWindowState::GetMaximizedOrCenteredWindowType(
: wm::WINDOW_STATE_TYPE_NORMAL;
}
+wm::WindowStateType MaximizeModeWindowState::GetSnappedWindowStateType(
+ wm::WindowState* window_state,
+ wm::WindowStateType target_state) {
+ DCHECK(target_state == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ||
+ target_state == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
+ return CanSnap(window_state) ? target_state
+ : GetMaximizedOrCenteredWindowType(window_state);
+}
+
void MaximizeModeWindowState::UpdateBounds(wm::WindowState* window_state,
bool animated) {
if (defer_bounds_updates_)
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_state.h ('k') | ash/wm/overview/overview_animation_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698