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

Unified Diff: ash/wm/dock/docked_window_layout_manager.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 varkha's comments from patch set 4. 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/dock/docked_window_layout_manager.cc
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index 14ccaa37329ea6a35b616c08f37d6c41097d51dd..8ffdf609fc3ca3c3c73430dafc710986e92c9bdb 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -576,16 +576,21 @@ DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow(
}
DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const {
- // Find a child that is not being dragged and is not a popup.
+ return CalculateDockedAlignmentExcept(dragged_window_);
+}
+
+DockedAlignment DockedWindowLayoutManager::CalculateDockedAlignmentExcept(
+ const aura::Window* window) const {
+ // Find a child that is not the window being queried and is not a popup.
// If such exists the current alignment is returned - even if some of the
// children are hidden or minimized (so they can be restored without losing
// the docked state).
for (size_t i = 0; i < dock_container_->children().size(); ++i) {
- aura::Window* window(dock_container_->children()[i]);
- if (window != dragged_window_ && !IsPopupOrTransient(window))
+ aura::Window* child(dock_container_->children()[i]);
+ if (window != child && !IsPopupOrTransient(child))
return alignment_;
}
- // No docked windows remain other than possibly the window being dragged.
+ // No docked windows remain other than possibly the window being queried.
// Return |NONE| to indicate that windows may get docked on either side.
return DOCKED_ALIGNMENT_NONE;
}
@@ -620,13 +625,18 @@ bool DockedWindowLayoutManager::CanDockWindow(
if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height())
return false;
// Cannot dock on the other size from an existing dock.
- const DockedAlignment alignment = CalculateAlignment();
+ const DockedAlignment alignment = CalculateDockedAlignmentExcept(window);
if (desired_alignment != DOCKED_ALIGNMENT_NONE &&
varkha 2014/09/30 20:15:19 Can this part be also checked inside IsDockedAlign
dtapuska 2014/10/01 15:01:33 No it can't be. If it look at the conditionals the
varkha 2014/10/01 18:16:34 I see. Couldn't you pass pass a second argument (c
varkha 2014/10/01 18:43:02 Right. I see my mistake now. Maybe just add a comm
dtapuska 2014/10/01 20:05:08 Done.
alignment != DOCKED_ALIGNMENT_NONE &&
alignment != desired_alignment) {
return false;
}
// Do not allow docking on the same side as shelf.
+ return IsDockedAlignmentApplicable(desired_alignment);
+}
+
+bool DockedWindowLayoutManager::IsDockedAlignmentApplicable(
+ DockedAlignment desired_alignment) const {
ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM;
if (shelf_)
shelf_alignment = shelf_->alignment();
@@ -639,6 +649,20 @@ bool DockedWindowLayoutManager::CanDockWindow(
return true;
}
+void DockedWindowLayoutManager::RequestDesiredDockedAlignment(
+ DockedAlignment desired_alignment) {
+ if (desired_alignment == alignment_ ||
+ desired_alignment == DOCKED_ALIGNMENT_NONE ||
+ alignment_ == DOCKED_ALIGNMENT_NONE ||
+ !IsDockedAlignmentApplicable(desired_alignment)) {
+ return;
+ }
+ alignment_ = desired_alignment;
+
+ Relayout();
+ UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
+}
+
void DockedWindowLayoutManager::OnShelfBoundsChanged() {
Relayout();
UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED);
@@ -700,8 +724,10 @@ void DockedWindowLayoutManager::OnChildWindowVisibilityChanged(
bool visible) {
if (IsPopupOrTransient(child))
return;
- if (visible)
- wm::GetWindowState(child)->Restore();
+
+ wm::WindowState* window_state = wm::GetWindowState(child);
+ if (visible && window_state->IsMinimized())
+ window_state->Restore();
Relayout();
UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
}
@@ -815,15 +841,15 @@ void DockedWindowLayoutManager::OnPreWindowStateTypeChange(
// until OnFullscreenStateChange is called when exiting fullscreen.
if (in_fullscreen_)
return;
- if (window_state->IsMinimized()) {
- MinimizeDockedWindow(window_state);
- } else if (window_state->IsMaximizedOrFullscreen() ||
- window_state->IsSnapped()) {
+ if (!window_state->IsDocked()) {
if (window != dragged_window_) {
UndockWindow(window);
- RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
+ if (window_state->IsMaximizedOrFullscreen())
+ RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
}
- } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) {
+ } else if (window_state->IsMinimized()) {
+ MinimizeDockedWindow(window_state);
+ } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) {
RestoreDockedWindow(window_state);
}
}
@@ -946,7 +972,7 @@ void DockedWindowLayoutManager::RestoreDockedWindow(
// Evict the window if it can no longer be docked because of its height.
if (!CanDockWindow(window, DOCKED_ALIGNMENT_NONE)) {
- UndockWindow(window);
+ window_state->Restore();
RecordUmaAction(DOCKED_ACTION_EVICT, DOCKED_ACTION_SOURCE_UNKNOWN);
return;
}

Powered by Google App Engine
This is Rietveld 408576698