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

Unified Diff: ash/wm/default_state.cc

Issue 597683003: Add window states docked; and docked minimized. Add wm window event to set docked and undocked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dock
Patch Set: Address Restore of App Windows and DockLeft/Dock Right issues Created 6 years, 3 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/default_state.cc
diff --git a/ash/wm/default_state.cc b/ash/wm/default_state.cc
index a6e0ee291bf6b81ef6533a8f00f14425ee2d05f4..cc5db315382cd1e1c191af242763bb1e5aba9598 100644
--- a/ash/wm/default_state.cc
+++ b/ash/wm/default_state.cc
@@ -78,16 +78,21 @@ void DefaultState::OnWMEvent(WindowState* window_state,
if (ProcessCompoundEvents(window_state, event))
return;
+ WindowStateType current_state_type = window_state->GetStateType();
WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL;
switch (event->type()) {
case WM_EVENT_NORMAL:
- next_state_type = WINDOW_STATE_TYPE_NORMAL;
+ next_state_type =
+ current_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED ?
+ WINDOW_STATE_TYPE_DOCKED : WINDOW_STATE_TYPE_NORMAL;
varkha 2014/09/29 18:59:28 nit: indent 4.
dtapuska 2014/09/29 20:59:56 Done.
break;
case WM_EVENT_MAXIMIZE:
next_state_type = WINDOW_STATE_TYPE_MAXIMIZED;
break;
case WM_EVENT_MINIMIZE:
- next_state_type = WINDOW_STATE_TYPE_MINIMIZED;
+ next_state_type =
+ current_state_type == WINDOW_STATE_TYPE_DOCKED ?
+ WINDOW_STATE_TYPE_DOCKED_MINIMIZED : WINDOW_STATE_TYPE_MINIMIZED;
varkha 2014/09/29 18:59:28 nit: indent 4.
dtapuska 2014/09/29 20:59:56 Done.
break;
case WM_EVENT_FULLSCREEN:
next_state_type = WINDOW_STATE_TYPE_FULLSCREEN;
@@ -98,6 +103,9 @@ void DefaultState::OnWMEvent(WindowState* window_state,
case WM_EVENT_SNAP_RIGHT:
next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED;
break;
+ case WM_EVENT_DOCK:
+ next_state_type = WINDOW_STATE_TYPE_DOCKED;
+ break;
case WM_EVENT_SET_BOUNDS:
SetBounds(window_state, static_cast<const SetBoundsEvent*>(event));
return;
@@ -119,9 +127,7 @@ void DefaultState::OnWMEvent(WindowState* window_state,
return;
}
- WindowStateType current = window_state->GetStateType();
-
- if (next_state_type == current && window_state->IsSnapped()) {
+ if (next_state_type == current_state_type && window_state->IsSnapped()) {
gfx::Rect snapped_bounds = event->type() == WM_EVENT_SNAP_LEFT ?
GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) :
GetDefaultRightSnappedWindowBoundsInParent(window_state->window());
@@ -273,6 +279,7 @@ bool DefaultState::ProcessCompoundEvents(WindowState* window_state,
case WM_EVENT_SNAP_RIGHT:
case WM_EVENT_SET_BOUNDS:
case WM_EVENT_SHOW_INACTIVE:
+ case WM_EVENT_DOCK:
break;
case WM_EVENT_ADDED_TO_WORKSPACE:
case WM_EVENT_WORKAREA_BOUNDS_CHANGED:
@@ -372,6 +379,7 @@ bool DefaultState::ProcessWorkspaceEvents(WindowState* window_state,
case WM_EVENT_SNAP_RIGHT:
case WM_EVENT_SET_BOUNDS:
case WM_EVENT_SHOW_INACTIVE:
+ case WM_EVENT_DOCK:
break;
}
return false;
@@ -422,44 +430,50 @@ void DefaultState::EnterToNextState(WindowState* window_state,
window_state->UpdateWindowShowStateFromStateType();
window_state->NotifyPreStateTypeChange(previous_state_type);
- // This Docked/Snapped hack is due to the issue that IsDocked returns
- // true for dragging window. TODO(oshima): Make docked window a state
- // and remove this hack.
- if (window_state->window()->parent() &&
- (window_state->IsSnapped() ||
- (!window_state->IsDocked() && !IsPanel(window_state->window())))) {
+ if (window_state->window()->parent()) {
if (!window_state->HasRestoreBounds() &&
(previous_state_type == WINDOW_STATE_TYPE_DEFAULT ||
previous_state_type == WINDOW_STATE_TYPE_NORMAL) &&
!window_state->IsMinimized() &&
!window_state->IsNormalStateType()) {
window_state->SaveCurrentBoundsForRestore();
- }
+ } else if (window_state->HasRestoreBounds() &&
+ window_state->IsNormalStateType() &&
+ previous_state_type == WINDOW_STATE_TYPE_DOCKED) {
+ UpdateBoundsFromState(window_state, previous_state_type);
- // When restoring from a minimized state, we want to restore to the previous
- // bounds. However, we want to maintain the restore bounds. (The restore
- // bounds are set if a user maximized the window in one axis by double
- // clicking the window border for example).
- gfx::Rect restore_bounds_in_screen;
- if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED &&
- window_state->IsNormalStateType() &&
- window_state->HasRestoreBounds() &&
- !window_state->unminimize_to_restore_bounds()) {
- restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen();
- window_state->SaveCurrentBoundsForRestore();
}
- if (window_state->IsMaximizedOrFullscreen())
- MoveToDisplayForRestore(window_state);
+ // This Docked/Snapped hack is due to the issue that IsDocked returns
+ // true for dragging window. TODO(oshima): Make docked window a state
+ // and remove this hack.
varkha 2014/09/29 18:59:28 Maybe rephrase a bit now that the docked state is
dtapuska 2014/09/29 20:59:56 Done.
+ if (window_state->IsSnapped() ||
+ (!window_state->IsDocked() && !IsPanel(window_state->window()))) {
+ // When restoring from a minimized state, we want to restore to the
+ // previous bounds. However, we want to maintain the restore bounds.
+ // (The restore bounds are set if a user maximized the window in one
+ // axis by double clicking the window border for example).
+ gfx::Rect restore_bounds_in_screen;
+ if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED &&
+ window_state->IsNormalStateType() &&
+ window_state->HasRestoreBounds() &&
+ !window_state->unminimize_to_restore_bounds()) {
+ restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen();
+ window_state->SaveCurrentBoundsForRestore();
+ }
- UpdateBoundsFromState(window_state, previous_state_type);
+ if (window_state->IsMaximizedOrFullscreen())
+ MoveToDisplayForRestore(window_state);
- // Normal state should have no restore bounds unless it's
- // unminimzied.
- if (!restore_bounds_in_screen.IsEmpty())
- window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen);
- else if (window_state->IsNormalStateType())
- window_state->ClearRestoreBounds();
+ UpdateBoundsFromState(window_state, previous_state_type);
+
+ // Normal state should have no restore bounds unless it's
+ // unminimized.
+ if (!restore_bounds_in_screen.IsEmpty())
+ window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen);
+ else if (window_state->IsNormalStateType())
+ window_state->ClearRestoreBounds();
+ }
}
window_state->NotifyPostStateTypeChange(previous_state_type);
}
@@ -507,6 +521,7 @@ void DefaultState::UpdateBoundsFromState(WindowState* window_state,
GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) :
GetDefaultRightSnappedWindowBoundsInParent(window_state->window());
break;
+ case WINDOW_STATE_TYPE_DOCKED:
case WINDOW_STATE_TYPE_DEFAULT:
case WINDOW_STATE_TYPE_NORMAL: {
gfx::Rect work_area_in_parent =
@@ -540,6 +555,7 @@ void DefaultState::UpdateBoundsFromState(WindowState* window_state,
bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window);
break;
+ case WINDOW_STATE_TYPE_DOCKED_MINIMIZED:
case WINDOW_STATE_TYPE_MINIMIZED:
break;
case WINDOW_STATE_TYPE_INACTIVE:
@@ -548,8 +564,9 @@ void DefaultState::UpdateBoundsFromState(WindowState* window_state,
return;
}
- if (state_type_ != WINDOW_STATE_TYPE_MINIMIZED) {
+ if (!window_state->IsMinimized()) {
if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED ||
+ previous_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED ||
varkha 2014/09/29 18:59:28 nit: consider a variable or function to compare to
dtapuska 2014/09/29 20:59:56 Done.
window_state->IsFullscreen()) {
window_state->SetBoundsDirect(bounds_in_parent);
} else if (window_state->IsMaximized() ||
@@ -577,12 +594,14 @@ void DefaultState::UpdateBoundsFromState(WindowState* window_state,
if (window_state->IsActive())
window_state->Deactivate();
} else if ((window_state->window()->TargetVisibility() ||
- previous_state_type == WINDOW_STATE_TYPE_MINIMIZED) &&
+ (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED ||
+ previous_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) &&
!window_state->window()->layer()->visible()) {
// The layer may be hidden if the window was previously minimized. Make
// sure it's visible.
window_state->window()->Show();
- if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED &&
+ if ((previous_state_type == WINDOW_STATE_TYPE_MINIMIZED ||
+ previous_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED) &&
!window_state->IsMaximizedOrFullscreen()) {
window_state->set_unminimize_to_restore_bounds(false);
}

Powered by Google App Engine
This is Rietveld 408576698