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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 1149153007: Ignores programmatic bounds changes for docked windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignores programmatic bounds changes for docked windows (comments) Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 }; 203 };
204 204
205 namespace { 205 namespace {
206 206
207 // Returns true if a window is a popup or a transient child. 207 // Returns true if a window is a popup or a transient child.
208 bool IsPopupOrTransient(const aura::Window* window) { 208 bool IsPopupOrTransient(const aura::Window* window) {
209 return (window->type() == ui::wm::WINDOW_TYPE_POPUP || 209 return (window->type() == ui::wm::WINDOW_TYPE_POPUP ||
210 ::wm::GetTransientParent(window)); 210 ::wm::GetTransientParent(window));
211 } 211 }
212 212
213 // Certain windows (minimized, hidden or popups) do not matter to docking. 213 // Certain windows (minimized, hidden or popups) are ignored by layout logic.
214 bool IsUsedByLayout(const aura::Window* window) { 214 bool IsIgnoredForDocking(const aura::Window* window) {
oshima 2015/06/05 23:08:36 This is still confusing to me. If this is to indi
varkha 2015/06/07 02:53:24 Done. You are right, haven't noticed that I had re
215 return (window->IsVisible() && 215 return (window->IsVisible() &&
216 !wm::GetWindowState(window)->IsMinimized() && 216 !wm::GetWindowState(window)->IsMinimized() &&
217 !IsPopupOrTransient(window)); 217 !IsPopupOrTransient(window));
218 } 218 }
219 219
220 void UndockWindow(aura::Window* window) { 220 void UndockWindow(aura::Window* window) {
221 gfx::Rect previous_bounds = window->bounds(); 221 gfx::Rect previous_bounds = window->bounds();
222 aura::Window* old_parent = window->parent(); 222 aura::Window* old_parent = window->parent();
223 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); 223 aura::client::ParentWindowWithContext(window, window, gfx::Rect());
224 if (window->parent() != old_parent) 224 if (window->parent() != old_parent)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 // Resize all windows that are flush with the dock edge together if one of 473 // Resize all windows that are flush with the dock edge together if one of
474 // them gets resized. 474 // them gets resized.
475 if (dragged_window_->bounds().width() == docked_width_ && 475 if (dragged_window_->bounds().width() == docked_width_ &&
476 (dragged_state->drag_details()->bounds_change & 476 (dragged_state->drag_details()->bounds_change &
477 WindowResizer::kBoundsChange_Resizes) && 477 WindowResizer::kBoundsChange_Resizes) &&
478 (dragged_state->drag_details()->size_change_direction & 478 (dragged_state->drag_details()->size_change_direction &
479 WindowResizer::kBoundsChangeDirection_Horizontal)) { 479 WindowResizer::kBoundsChangeDirection_Horizontal)) {
480 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 480 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
481 aura::Window* window1(dock_container_->children()[i]); 481 aura::Window* window1(dock_container_->children()[i]);
482 if (IsUsedByLayout(window1) && 482 if (IsIgnoredForDocking(window1) && window1 != dragged_window_ &&
483 window1 != dragged_window_ &&
484 window1->bounds().width() == docked_width_) { 483 window1->bounds().width() == docked_width_) {
485 wm::GetWindowState(window1)->set_bounds_changed_by_user(false); 484 wm::GetWindowState(window1)->set_bounds_changed_by_user(false);
486 } 485 }
487 } 486 }
488 } 487 }
489 } 488 }
490 489
491 void DockedWindowLayoutManager::DockDraggedWindow(aura::Window* window) { 490 void DockedWindowLayoutManager::DockDraggedWindow(aura::Window* window) {
492 DCHECK(!IsPopupOrTransient(window)); 491 DCHECK(!IsPopupOrTransient(window));
493 OnDraggedWindowDocked(window); 492 OnDraggedWindowDocked(window);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 const gfx::Rect& requested_bounds) { 737 const gfx::Rect& requested_bounds) {
739 // The minimum constraints have to be applied first by the layout manager. 738 // The minimum constraints have to be applied first by the layout manager.
740 gfx::Rect actual_new_bounds(requested_bounds); 739 gfx::Rect actual_new_bounds(requested_bounds);
741 if (child->delegate()) { 740 if (child->delegate()) {
742 const gfx::Size& min_size = child->delegate()->GetMinimumSize(); 741 const gfx::Size& min_size = child->delegate()->GetMinimumSize();
743 actual_new_bounds.set_width( 742 actual_new_bounds.set_width(
744 std::max(min_size.width(), actual_new_bounds.width())); 743 std::max(min_size.width(), actual_new_bounds.width()));
745 actual_new_bounds.set_height( 744 actual_new_bounds.set_height(
746 std::max(min_size.height(), actual_new_bounds.height())); 745 std::max(min_size.height(), actual_new_bounds.height()));
747 } 746 }
747 if (IsIgnoredForDocking(child) && child != dragged_window_)
748 return;
748 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); 749 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds);
749 if (IsPopupOrTransient(child)) 750 if (IsPopupOrTransient(child))
750 return; 751 return;
751 // Whenever one of our windows is moved or resized enforce layout. 752 // Whenever one of our windows is moved or resized enforce layout.
752 ShelfLayoutManager* shelf_layout = 753 ShelfLayoutManager* shelf_layout =
753 ShelfLayoutManager::ForShelf(dock_container_); 754 ShelfLayoutManager::ForShelf(dock_container_);
754 if (shelf_layout) 755 if (shelf_layout)
755 shelf_layout->UpdateVisibilityState(); 756 shelf_layout->UpdateVisibilityState();
756 } 757 }
757 758
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); 930 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area();
930 int available_room = work_area.height(); 931 int available_room = work_area.height();
931 bool gap_needed = !!child; 932 bool gap_needed = !!child;
932 if (child) 933 if (child)
933 available_room -= GetWindowHeightCloseTo(child, 0); 934 available_room -= GetWindowHeightCloseTo(child, 0);
934 // Use a copy of children array because a call to Minimize can change order. 935 // Use a copy of children array because a call to Minimize can change order.
935 aura::Window::Windows children(dock_container_->children()); 936 aura::Window::Windows children(dock_container_->children());
936 aura::Window::Windows::const_reverse_iterator iter = children.rbegin(); 937 aura::Window::Windows::const_reverse_iterator iter = children.rbegin();
937 while (iter != children.rend()) { 938 while (iter != children.rend()) {
938 aura::Window* window(*iter++); 939 aura::Window* window(*iter++);
939 if (window == child || !IsUsedByLayout(window)) 940 if (window == child || !IsIgnoredForDocking(window))
940 continue; 941 continue;
941 int room_needed = GetWindowHeightCloseTo(window, 0) + 942 int room_needed = GetWindowHeightCloseTo(window, 0) +
942 (gap_needed ? kMinDockGap : 0); 943 (gap_needed ? kMinDockGap : 0);
943 gap_needed = true; 944 gap_needed = true;
944 if (available_room > room_needed) { 945 if (available_room > room_needed) {
945 available_room -= room_needed; 946 available_room -= room_needed;
946 } else { 947 } else {
947 // Slow down minimizing animations. Lock duration so that it is not 948 // Slow down minimizing animations. Lock duration so that it is not
948 // overridden by other ScopedLayerAnimationSettings down the stack. 949 // overridden by other ScopedLayerAnimationSettings down the stack.
949 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 950 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 last_action_time_ = time_now; 1007 last_action_time_ = time_now;
1007 int docked_all_count = 0; 1008 int docked_all_count = 0;
1008 int docked_visible_count = 0; 1009 int docked_visible_count = 0;
1009 int docked_panels_count = 0; 1010 int docked_panels_count = 0;
1010 int large_windows_count = 0; 1011 int large_windows_count = 0;
1011 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 1012 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
1012 const aura::Window* window(dock_container_->children()[i]); 1013 const aura::Window* window(dock_container_->children()[i]);
1013 if (IsPopupOrTransient(window)) 1014 if (IsPopupOrTransient(window))
1014 continue; 1015 continue;
1015 docked_all_count++; 1016 docked_all_count++;
1016 if (!IsUsedByLayout(window)) 1017 if (!IsIgnoredForDocking(window))
1017 continue; 1018 continue;
1018 docked_visible_count++; 1019 docked_visible_count++;
1019 if (window->type() == ui::wm::WINDOW_TYPE_PANEL) 1020 if (window->type() == ui::wm::WINDOW_TYPE_PANEL)
1020 docked_panels_count++; 1021 docked_panels_count++;
1021 const wm::WindowState* window_state = wm::GetWindowState(window); 1022 const wm::WindowState* window_state = wm::GetWindowState(window);
1022 if (window_state->HasRestoreBounds()) { 1023 if (window_state->HasRestoreBounds()) {
1023 const gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); 1024 const gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
1024 if (restore_bounds.width() > kMaxDockWidth) 1025 if (restore_bounds.width() > kMaxDockWidth)
1025 large_windows_count++; 1026 large_windows_count++;
1026 } 1027 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (alignment_ == DOCKED_ALIGNMENT_NONE && !is_dragged_window_docked_) 1068 if (alignment_ == DOCKED_ALIGNMENT_NONE && !is_dragged_window_docked_)
1068 return; 1069 return;
1069 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 1070 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
1070 1071
1071 gfx::Rect dock_bounds = dock_container_->GetBoundsInScreen(); 1072 gfx::Rect dock_bounds = dock_container_->GetBoundsInScreen();
1072 aura::Window* active_window = NULL; 1073 aura::Window* active_window = NULL;
1073 std::vector<WindowWithHeight> visible_windows; 1074 std::vector<WindowWithHeight> visible_windows;
1074 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 1075 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
1075 aura::Window* window(dock_container_->children()[i]); 1076 aura::Window* window(dock_container_->children()[i]);
1076 1077
1077 if (!IsUsedByLayout(window) || window == dragged_window_) 1078 if (!IsIgnoredForDocking(window) || window == dragged_window_)
1078 continue; 1079 continue;
1079 1080
1080 // If the shelf is currently hidden (full-screen mode), hide window until 1081 // If the shelf is currently hidden (full-screen mode), hide window until
1081 // full-screen mode is exited. 1082 // full-screen mode is exited.
1082 if (in_fullscreen_) { 1083 if (in_fullscreen_) {
1083 // The call to Hide does not set the minimize property, so the window will 1084 // The call to Hide does not set the minimize property, so the window will
1084 // be restored when the shelf becomes visible again. 1085 // be restored when the shelf becomes visible again.
1085 window->Hide(); 1086 window->Hide();
1086 continue; 1087 continue;
1087 } 1088 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // |`------'| 1308 // |`------'|
1308 // |`------'| 1309 // |`------'|
1309 // `------' 1310 // `------'
1310 // Use the middle of each window to figure out how to stack the window. 1311 // Use the middle of each window to figure out how to stack the window.
1311 // This allows us to update the stacking when a window is being dragged around 1312 // This allows us to update the stacking when a window is being dragged around
1312 // by the titlebar. 1313 // by the titlebar.
1313 std::map<int, aura::Window*> window_ordering; 1314 std::map<int, aura::Window*> window_ordering;
1314 for (aura::Window::Windows::const_iterator it = 1315 for (aura::Window::Windows::const_iterator it =
1315 dock_container_->children().begin(); 1316 dock_container_->children().begin();
1316 it != dock_container_->children().end(); ++it) { 1317 it != dock_container_->children().end(); ++it) {
1317 if (!IsUsedByLayout(*it) || 1318 if (!IsIgnoredForDocking(*it) ||
1318 ((*it) == dragged_window_ && !is_dragged_window_docked_)) { 1319 ((*it) == dragged_window_ && !is_dragged_window_docked_)) {
1319 continue; 1320 continue;
1320 } 1321 }
1321 gfx::Rect bounds = (*it)->bounds(); 1322 gfx::Rect bounds = (*it)->bounds();
1322 window_ordering.insert(std::make_pair(bounds.y() + bounds.height() / 2, 1323 window_ordering.insert(std::make_pair(bounds.y() + bounds.height() / 2,
1323 *it)); 1324 *it));
1324 } 1325 }
1325 int active_center_y = active_window->bounds().CenterPoint().y(); 1326 int active_center_y = active_window->bounds().CenterPoint().y();
1326 1327
1327 aura::Window* previous_window = NULL; 1328 aura::Window* previous_window = NULL;
(...skipping 23 matching lines...) Expand all
1351 1352
1352 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1353 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1353 const gfx::Rect& keyboard_bounds) { 1354 const gfx::Rect& keyboard_bounds) {
1354 // This bounds change will have caused a change to the Shelf which does not 1355 // This bounds change will have caused a change to the Shelf which does not
1355 // propagate automatically to this class, so manually recalculate bounds. 1356 // propagate automatically to this class, so manually recalculate bounds.
1356 Relayout(); 1357 Relayout();
1357 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1358 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1358 } 1359 }
1359 1360
1360 } // namespace ash 1361 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698