| 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/common/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/common/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/common/ash_switches.h" |
| 12 #include "ash/common/metrics/user_metrics_action.h" | 13 #include "ash/common/metrics/user_metrics_action.h" |
| 13 #include "ash/common/wm/default_window_resizer.h" | 14 #include "ash/common/wm/default_window_resizer.h" |
| 14 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 15 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 15 #include "ash/common/wm/dock/docked_window_resizer.h" | 16 #include "ash/common/wm/dock/docked_window_resizer.h" |
| 16 #include "ash/common/wm/panels/panel_window_resizer.h" | 17 #include "ash/common/wm/panels/panel_window_resizer.h" |
| 17 #include "ash/common/wm/window_positioning_utils.h" | 18 #include "ash/common/wm/window_positioning_utils.h" |
| 18 #include "ash/common/wm/window_state.h" | 19 #include "ash/common/wm/window_state.h" |
| 19 #include "ash/common/wm/wm_event.h" | 20 #include "ash/common/wm/wm_event.h" |
| 20 #include "ash/common/wm/wm_screen_util.h" | 21 #include "ash/common/wm/wm_screen_util.h" |
| 21 #include "ash/common/wm/workspace/phantom_window_controller.h" | 22 #include "ash/common/wm/workspace/phantom_window_controller.h" |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 SetDraggedWindowDocked(false); | 879 SetDraggedWindowDocked(false); |
| 879 return; | 880 return; |
| 880 } | 881 } |
| 881 } | 882 } |
| 882 | 883 |
| 883 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT); | 884 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT); |
| 884 DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) | 885 DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) |
| 885 ? DOCKED_ALIGNMENT_LEFT | 886 ? DOCKED_ALIGNMENT_LEFT |
| 886 : DOCKED_ALIGNMENT_RIGHT; | 887 : DOCKED_ALIGNMENT_RIGHT; |
| 887 const bool can_dock = | 888 const bool can_dock = |
| 889 ash::switches::DockedWindowsEnabled() && |
| 888 dock_layout_->CanDockWindow(GetTarget(), desired_alignment) && | 890 dock_layout_->CanDockWindow(GetTarget(), desired_alignment) && |
| 889 dock_layout_->GetAlignmentOfWindow(GetTarget()) != DOCKED_ALIGNMENT_NONE; | 891 dock_layout_->GetAlignmentOfWindow(GetTarget()) != DOCKED_ALIGNMENT_NONE; |
| 890 if (!can_dock) { | 892 if (!can_dock) { |
| 891 // If the window cannot be docked, undock the window. This may change the | 893 // If the window cannot be docked, undock the window. This may change the |
| 892 // workspace bounds and hence |snap_type_|. | 894 // workspace bounds and hence |snap_type_|. |
| 893 SetDraggedWindowDocked(false); | 895 SetDraggedWindowDocked(false); |
| 894 snap_type_ = GetSnapType(location); | 896 snap_type_ = GetSnapType(location); |
| 895 } | 897 } |
| 896 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); | 898 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); |
| 897 if (!can_snap && !can_dock) { | 899 if (!can_snap && !can_dock) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 1013 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
| 1012 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1014 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1013 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); | 1015 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); |
| 1014 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1016 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1015 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1017 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1016 snapped_bounds.set_width(bounds_in_parent.width()); | 1018 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1017 return bounds_in_parent == snapped_bounds; | 1019 return bounds_in_parent == snapped_bounds; |
| 1018 } | 1020 } |
| 1019 | 1021 |
| 1020 } // namespace ash | 1022 } // namespace ash |
| OLD | NEW |