OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/metrics/user_metrics_action.h" | 12 #include "ash/metrics/user_metrics_action.h" |
13 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/screen_util.h" |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ash/shell_port.h" | 17 #include "ash/shell_port.h" |
17 #include "ash/wm/default_window_resizer.h" | 18 #include "ash/wm/default_window_resizer.h" |
18 #include "ash/wm/panels/panel_window_resizer.h" | 19 #include "ash/wm/panels/panel_window_resizer.h" |
19 #include "ash/wm/window_positioning_utils.h" | 20 #include "ash/wm/window_positioning_utils.h" |
20 #include "ash/wm/window_state.h" | 21 #include "ash/wm/window_state.h" |
21 #include "ash/wm/wm_event.h" | 22 #include "ash/wm/wm_event.h" |
22 #include "ash/wm/wm_screen_util.h" | |
23 #include "ash/wm/workspace/phantom_window_controller.h" | 23 #include "ash/wm/workspace/phantom_window_controller.h" |
24 #include "ash/wm/workspace/two_step_edge_cycler.h" | 24 #include "ash/wm/workspace/two_step_edge_cycler.h" |
25 #include "ash/wm_window.h" | 25 #include "ash/wm_window.h" |
26 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
27 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
29 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
30 #include "ui/display/display.h" | 30 #include "ui/display/display.h" |
31 #include "ui/display/screen.h" | 31 #include "ui/display/screen.h" |
32 #include "ui/gfx/transform.h" | 32 #include "ui/gfx/transform.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 int min_size = std::min(initial_size, | 509 int min_size = std::min(initial_size, |
510 std::max(PrimaryAxisSize(min), kMinOnscreenSize)); | 510 std::max(PrimaryAxisSize(min), kMinOnscreenSize)); |
511 total_min_ += min_size; | 511 total_min_ += min_size; |
512 total_initial_size_ += initial_size; | 512 total_initial_size_ += initial_size; |
513 total_available += std::max(min_size, initial_size) - min_size; | 513 total_available += std::max(min_size, initial_size) - min_size; |
514 } | 514 } |
515 instance = this; | 515 instance = this; |
516 } | 516 } |
517 | 517 |
518 void WorkspaceWindowResizer::LayoutAttachedWindows(gfx::Rect* bounds) { | 518 void WorkspaceWindowResizer::LayoutAttachedWindows(gfx::Rect* bounds) { |
519 gfx::Rect work_area(wm::GetDisplayWorkAreaBoundsInParent(GetTarget())); | 519 gfx::Rect work_area( |
| 520 ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget()->aura_window())); |
520 int initial_size = PrimaryAxisSize(details().initial_bounds_in_parent.size()); | 521 int initial_size = PrimaryAxisSize(details().initial_bounds_in_parent.size()); |
521 int current_size = PrimaryAxisSize(bounds->size()); | 522 int current_size = PrimaryAxisSize(bounds->size()); |
522 int start = PrimaryAxisCoordinate(bounds->right(), bounds->bottom()); | 523 int start = PrimaryAxisCoordinate(bounds->right(), bounds->bottom()); |
523 int end = PrimaryAxisCoordinate(work_area.right(), work_area.bottom()); | 524 int end = PrimaryAxisCoordinate(work_area.right(), work_area.bottom()); |
524 | 525 |
525 int delta = current_size - initial_size; | 526 int delta = current_size - initial_size; |
526 int available_size = end - start; | 527 int available_size = end - start; |
527 std::vector<int> sizes; | 528 std::vector<int> sizes; |
528 int leftovers = CalculateAttachedSizes(delta, available_size, &sizes); | 529 int leftovers = CalculateAttachedSizes(delta, available_size, &sizes); |
529 | 530 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 ++i; | 916 ++i; |
916 if (i != map.rend()) | 917 if (i != map.rend()) |
917 parent->StackChildBelow(i->second, window); | 918 parent->StackChildBelow(i->second, window); |
918 } | 919 } |
919 } | 920 } |
920 | 921 |
921 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( | 922 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( |
922 const gfx::Point& location) const { | 923 const gfx::Point& location) const { |
923 // TODO: this likely only wants total display area, not the area of a single | 924 // TODO: this likely only wants total display area, not the area of a single |
924 // display. | 925 // display. |
925 gfx::Rect area(wm::GetDisplayWorkAreaBoundsInParent(GetTarget())); | 926 gfx::Rect area( |
| 927 ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget()->aura_window())); |
926 if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { | 928 if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { |
927 // Increase tolerance for touch-snapping near the screen edges. This is only | 929 // Increase tolerance for touch-snapping near the screen edges. This is only |
928 // necessary when the work area left or right edge is same as screen edge. | 930 // necessary when the work area left or right edge is same as screen edge. |
929 gfx::Rect display_bounds(wm::GetDisplayBoundsInParent(GetTarget())); | 931 gfx::Rect display_bounds( |
| 932 ScreenUtil::GetDisplayBoundsInParent(GetTarget()->aura_window())); |
930 int inset_left = 0; | 933 int inset_left = 0; |
931 if (area.x() == display_bounds.x()) | 934 if (area.x() == display_bounds.x()) |
932 inset_left = kScreenEdgeInsetForTouchDrag; | 935 inset_left = kScreenEdgeInsetForTouchDrag; |
933 int inset_right = 0; | 936 int inset_right = 0; |
934 if (area.right() == display_bounds.right()) | 937 if (area.right() == display_bounds.right()) |
935 inset_right = kScreenEdgeInsetForTouchDrag; | 938 inset_right = kScreenEdgeInsetForTouchDrag; |
936 area.Inset(inset_left, 0, inset_right, 0); | 939 area.Inset(inset_left, 0, inset_right, 0); |
937 } | 940 } |
938 if (location.x() <= area.x()) | 941 if (location.x() <= area.x()) |
939 return SNAP_LEFT; | 942 return SNAP_LEFT; |
940 if (location.x() >= area.right() - 1) | 943 if (location.x() >= area.right() - 1) |
941 return SNAP_RIGHT; | 944 return SNAP_RIGHT; |
942 return SNAP_NONE; | 945 return SNAP_NONE; |
943 } | 946 } |
944 | 947 |
945 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds( | 948 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds( |
946 wm::WindowStateType snapped_type, | 949 wm::WindowStateType snapped_type, |
947 const gfx::Rect& bounds_in_parent) const { | 950 const gfx::Rect& bounds_in_parent) const { |
948 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 951 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
949 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 952 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
950 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); | 953 gfx::Rect snapped_bounds = |
| 954 ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget()->aura_window()); |
951 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 955 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
952 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 956 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
953 snapped_bounds.set_width(bounds_in_parent.width()); | 957 snapped_bounds.set_width(bounds_in_parent.width()); |
954 return bounds_in_parent == snapped_bounds; | 958 return bounds_in_parent == snapped_bounds; |
955 } | 959 } |
956 | 960 |
957 } // namespace ash | 961 } // namespace ash |
OLD | NEW |