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

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

Issue 2960843004: CrOS Tablet Window management - Split Screen part I (Closed)
Patch Set: nit. 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
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..4780d7125ee35e0748718896c5f0a742a1c1ff4a 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
varkha 2017/06/30 14:29:34 nit: 'do not snap the window' or 'do not allow sna
xdai1 2017/07/05 20:18:22 Done.
+ // 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;
@@ -193,7 +229,9 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
} else if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN &&
current_state_type_ != wm::WINDOW_STATE_TYPE_PINNED &&
- current_state_type_ != wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) {
+ current_state_type_ != wm::WINDOW_STATE_TYPE_TRUSTED_PINNED &&
+ current_state_type_ != wm::WINDOW_STATE_TYPE_LEFT_SNAPPED &&
+ current_state_type_ != wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) {
// In all other cases (except for minimized windows) we respect the
// requested bounds and center it to a fully visible area on the screen.
gfx::Rect bounds_in_parent =
@@ -274,7 +312,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 +335,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 +372,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_)

Powered by Google App Engine
This is Rietveld 408576698