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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 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 | « ash/wm/default_state.cc ('k') | 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // See http://crbug.com/307792. 607 // See http://crbug.com/307792.
608 if (window->bounds().width() > kMaxDockWidth && 608 if (window->bounds().width() > kMaxDockWidth &&
609 (!window_state->CanResize() || 609 (!window_state->CanResize() ||
610 (window->delegate() && 610 (window->delegate() &&
611 window->delegate()->GetMinimumSize().width() != 0 && 611 window->delegate()->GetMinimumSize().width() != 0 &&
612 window->delegate()->GetMinimumSize().width() > kMaxDockWidth))) { 612 window->delegate()->GetMinimumSize().width() > kMaxDockWidth))) {
613 return false; 613 return false;
614 } 614 }
615 // If a window is tall and cannot be resized down to maximum height allowed 615 // If a window is tall and cannot be resized down to maximum height allowed
616 // then it cannot be docked. 616 // then it cannot be docked.
617 const gfx::Rect work_area = 617 const gfx::Rect work_area = gfx::Screen::GetScreen()
618 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); 618 ->GetDisplayNearestWindow(dock_container_)
619 .work_area();
619 if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height()) 620 if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height())
620 return false; 621 return false;
621 // Cannot dock on the other size from an existing dock. 622 // Cannot dock on the other size from an existing dock.
622 const DockedAlignment alignment = CalculateAlignmentExcept(window); 623 const DockedAlignment alignment = CalculateAlignmentExcept(window);
623 if (desired_alignment != DOCKED_ALIGNMENT_NONE && 624 if (desired_alignment != DOCKED_ALIGNMENT_NONE &&
624 alignment != DOCKED_ALIGNMENT_NONE && 625 alignment != DOCKED_ALIGNMENT_NONE &&
625 alignment != desired_alignment) { 626 alignment != desired_alignment) {
626 return false; 627 return false;
627 } 628 }
628 // Do not allow docking on the same side as shelf. 629 // Do not allow docking on the same side as shelf.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (ancestor) 926 if (ancestor)
926 UpdateStacking(ancestor); 927 UpdateStacking(ancestor);
927 } 928 }
928 929
929 //////////////////////////////////////////////////////////////////////////////// 930 ////////////////////////////////////////////////////////////////////////////////
930 // DockedWindowLayoutManager private implementation: 931 // DockedWindowLayoutManager private implementation:
931 932
932 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept( 933 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept(
933 aura::Window* child) { 934 aura::Window* child) {
934 // Minimize any windows that don't fit without overlap. 935 // Minimize any windows that don't fit without overlap.
935 const gfx::Rect work_area = 936 const gfx::Rect work_area = gfx::Screen::GetScreen()
936 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); 937 ->GetDisplayNearestWindow(dock_container_)
938 .work_area();
937 int available_room = work_area.height(); 939 int available_room = work_area.height();
938 bool gap_needed = !!child; 940 bool gap_needed = !!child;
939 if (child) 941 if (child)
940 available_room -= GetWindowHeightCloseTo(child, 0); 942 available_room -= GetWindowHeightCloseTo(child, 0);
941 // Use a copy of children array because a call to Minimize can change order. 943 // Use a copy of children array because a call to Minimize can change order.
942 aura::Window::Windows children(dock_container_->children()); 944 aura::Window::Windows children(dock_container_->children());
943 aura::Window::Windows::const_reverse_iterator iter = children.rbegin(); 945 aura::Window::Windows::const_reverse_iterator iter = children.rbegin();
944 while (iter != children.rend()) { 946 while (iter != children.rend()) {
945 aura::Window* window(*iter++); 947 aura::Window* window(*iter++);
946 if (window == child || !IsWindowDocked(window)) 948 if (window == child || !IsWindowDocked(window))
(...skipping 24 matching lines...) Expand all
971 RecordUmaAction(DOCKED_ACTION_MINIMIZE, event_source_); 973 RecordUmaAction(DOCKED_ACTION_MINIMIZE, event_source_);
972 } 974 }
973 975
974 void DockedWindowLayoutManager::RestoreDockedWindow( 976 void DockedWindowLayoutManager::RestoreDockedWindow(
975 wm::WindowState* window_state) { 977 wm::WindowState* window_state) {
976 aura::Window* window = window_state->window(); 978 aura::Window* window = window_state->window();
977 DCHECK(!IsPopupOrTransient(window)); 979 DCHECK(!IsPopupOrTransient(window));
978 // Always place restored window at the bottom shuffling the other windows up. 980 // Always place restored window at the bottom shuffling the other windows up.
979 // TODO(varkha): add a separate container for docked windows to keep track 981 // TODO(varkha): add a separate container for docked windows to keep track
980 // of ordering. 982 // of ordering.
981 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( 983 gfx::Display display =
982 dock_container_); 984 gfx::Screen::GetScreen()->GetDisplayNearestWindow(dock_container_);
983 const gfx::Rect work_area = display.work_area(); 985 const gfx::Rect work_area = display.work_area();
984 986
985 // Evict the window if it can no longer be docked because of its height. 987 // Evict the window if it can no longer be docked because of its height.
986 if (!CanDockWindow(window, DOCKED_ALIGNMENT_NONE)) { 988 if (!CanDockWindow(window, DOCKED_ALIGNMENT_NONE)) {
987 window_state->Restore(); 989 window_state->Restore();
988 RecordUmaAction(DOCKED_ACTION_EVICT, event_source_); 990 RecordUmaAction(DOCKED_ACTION_EVICT, event_source_);
989 return; 991 return;
990 } 992 }
991 gfx::Rect bounds(window->bounds()); 993 gfx::Rect bounds(window->bounds());
992 bounds.set_y(work_area.bottom()); 994 bounds.set_y(work_area.bottom());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 visible_windows.push_back(WindowWithHeight(window)); 1107 visible_windows.push_back(WindowWithHeight(window));
1106 } 1108 }
1107 // Consider docked dragged_window_ when fanning out other child windows. 1109 // Consider docked dragged_window_ when fanning out other child windows.
1108 if (is_dragged_window_docked_) { 1110 if (is_dragged_window_docked_) {
1109 visible_windows.push_back(WindowWithHeight(dragged_window_)); 1111 visible_windows.push_back(WindowWithHeight(dragged_window_));
1110 DCHECK(!active_window); 1112 DCHECK(!active_window);
1111 active_window = dragged_window_; 1113 active_window = dragged_window_;
1112 } 1114 }
1113 1115
1114 // Position docked windows as well as the window being dragged. 1116 // Position docked windows as well as the window being dragged.
1115 gfx::Rect work_area = 1117 gfx::Rect work_area = gfx::Screen::GetScreen()
1116 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); 1118 ->GetDisplayNearestWindow(dock_container_)
1119 .work_area();
1117 if (shelf_observer_) 1120 if (shelf_observer_)
1118 work_area.Subtract(shelf_observer_->shelf_bounds_in_screen()); 1121 work_area.Subtract(shelf_observer_->shelf_bounds_in_screen());
1119 int available_room = CalculateWindowHeightsAndRemainingRoom(work_area, 1122 int available_room = CalculateWindowHeightsAndRemainingRoom(work_area,
1120 &visible_windows); 1123 &visible_windows);
1121 FanOutChildren(work_area, 1124 FanOutChildren(work_area,
1122 CalculateIdealWidth(visible_windows), 1125 CalculateIdealWidth(visible_windows),
1123 available_room, 1126 available_room,
1124 &visible_windows); 1127 &visible_windows);
1125 1128
1126 // After the first Relayout allow the windows to change their order easier 1129 // After the first Relayout allow the windows to change their order easier
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 slide_settings.SetTransitionDuration( 1272 slide_settings.SetTransitionDuration(
1270 base::TimeDelta::FromMilliseconds(kSlideDurationMs)); 1273 base::TimeDelta::FromMilliseconds(kSlideDurationMs));
1271 SetChildBoundsDirect(window, bounds); 1274 SetChildBoundsDirect(window, bounds);
1272 } 1275 }
1273 } 1276 }
1274 } 1277 }
1275 1278
1276 void DockedWindowLayoutManager::UpdateDockBounds( 1279 void DockedWindowLayoutManager::UpdateDockBounds(
1277 DockedWindowLayoutManagerObserver::Reason reason) { 1280 DockedWindowLayoutManagerObserver::Reason reason) {
1278 int dock_inset = docked_width_ + (docked_width_ > 0 ? kMinDockGap : 0); 1281 int dock_inset = docked_width_ + (docked_width_ > 0 ? kMinDockGap : 0);
1279 const gfx::Rect work_area = 1282 const gfx::Rect work_area = gfx::Screen::GetScreen()
1280 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); 1283 ->GetDisplayNearestWindow(dock_container_)
1284 .work_area();
1281 gfx::Rect bounds = gfx::Rect( 1285 gfx::Rect bounds = gfx::Rect(
1282 alignment_ == DOCKED_ALIGNMENT_RIGHT && dock_inset > 0 ? 1286 alignment_ == DOCKED_ALIGNMENT_RIGHT && dock_inset > 0 ?
1283 dock_container_->bounds().right() - dock_inset: 1287 dock_container_->bounds().right() - dock_inset:
1284 dock_container_->bounds().x(), 1288 dock_container_->bounds().x(),
1285 dock_container_->bounds().y(), 1289 dock_container_->bounds().y(),
1286 dock_inset, 1290 dock_inset,
1287 work_area.height()); 1291 work_area.height());
1288 docked_bounds_ = bounds + 1292 docked_bounds_ = bounds +
1289 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); 1293 dock_container_->GetBoundsInScreen().OffsetFromOrigin();
1290 FOR_EACH_OBSERVER( 1294 FOR_EACH_OBSERVER(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 1366
1363 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1367 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1364 const gfx::Rect& keyboard_bounds) { 1368 const gfx::Rect& keyboard_bounds) {
1365 // This bounds change will have caused a change to the Shelf which does not 1369 // This bounds change will have caused a change to the Shelf which does not
1366 // propagate automatically to this class, so manually recalculate bounds. 1370 // propagate automatically to this class, so manually recalculate bounds.
1367 Relayout(); 1371 Relayout();
1368 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1372 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1369 } 1373 }
1370 1374
1371 } // namespace ash 1375 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/default_state.cc ('k') | ash/wm/dock/docked_window_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698