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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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/window_resizer.cc ('k') | no next file » | 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) 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>
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 DCHECK(details().is_resizable); 530 DCHECK(details().is_resizable);
531 531
532 // A mousemove should still show the cursor even if the window is 532 // A mousemove should still show the cursor even if the window is
533 // being moved or resized with touch, so do not lock the cursor. 533 // being moved or resized with touch, so do not lock the cursor.
534 if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) { 534 if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
535 Shell* shell = Shell::GetInstance(); 535 Shell* shell = Shell::GetInstance();
536 shell->cursor_manager()->LockCursor(); 536 shell->cursor_manager()->LockCursor();
537 did_lock_cursor_ = true; 537 did_lock_cursor_ = true;
538 } 538 }
539 539
540 aura::Window* dock_container = Shell::GetContainer( 540 dock_layout_ = DockedWindowLayoutManager::Get(GetTarget());
541 GetAuraTarget()->GetRootWindow(), kShellWindowId_DockedContainer);
542 dock_layout_ = static_cast<DockedWindowLayoutManager*>(
543 dock_container->layout_manager());
544 541
545 // Only support attaching to the right/bottom. 542 // Only support attaching to the right/bottom.
546 DCHECK(attached_windows_.empty() || 543 DCHECK(attached_windows_.empty() ||
547 (details().window_component == HTRIGHT || 544 (details().window_component == HTRIGHT ||
548 details().window_component == HTBOTTOM)); 545 details().window_component == HTBOTTOM));
549 546
550 // TODO: figure out how to deal with window going off the edge. 547 // TODO: figure out how to deal with window going off the edge.
551 548
552 // Calculate sizes so that we can maintain the ratios if we need to resize. 549 // Calculate sizes so that we can maintain the ratios if we need to resize.
553 int total_available = 0; 550 int total_available = 0;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 if (snap_type_ == SNAP_NONE) { 916 if (snap_type_ == SNAP_NONE) {
920 SetDraggedWindowDocked(false); 917 SetDraggedWindowDocked(false);
921 return; 918 return;
922 } 919 }
923 } 920 }
924 921
925 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT); 922 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT);
926 DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) ? 923 DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) ?
927 DOCKED_ALIGNMENT_LEFT : DOCKED_ALIGNMENT_RIGHT; 924 DOCKED_ALIGNMENT_LEFT : DOCKED_ALIGNMENT_RIGHT;
928 const bool can_dock = 925 const bool can_dock =
929 dock_layout_->CanDockWindow(GetAuraTarget(), desired_alignment) && 926 dock_layout_->CanDockWindow(GetTarget(), desired_alignment) &&
930 dock_layout_->GetAlignmentOfWindow(GetAuraTarget()) != 927 dock_layout_->GetAlignmentOfWindow(GetTarget()) != DOCKED_ALIGNMENT_NONE;
931 DOCKED_ALIGNMENT_NONE;
932 if (!can_dock) { 928 if (!can_dock) {
933 // If the window cannot be docked, undock the window. This may change the 929 // If the window cannot be docked, undock the window. This may change the
934 // workspace bounds and hence |snap_type_|. 930 // workspace bounds and hence |snap_type_|.
935 SetDraggedWindowDocked(false); 931 SetDraggedWindowDocked(false);
936 snap_type_ = GetSnapType(location); 932 snap_type_ = GetSnapType(location);
937 } 933 }
938 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); 934 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap();
939 if (!can_snap && !can_dock) { 935 if (!can_snap && !can_dock) {
940 snap_type_ = SNAP_NONE; 936 snap_type_ = SNAP_NONE;
941 snap_phantom_window_controller_.reset(); 937 snap_phantom_window_controller_.reset();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 return SNAP_LEFT; 1030 return SNAP_LEFT;
1035 if (location.x() >= area.right() - 1) 1031 if (location.x() >= area.right() - 1)
1036 return SNAP_RIGHT; 1032 return SNAP_RIGHT;
1037 return SNAP_NONE; 1033 return SNAP_NONE;
1038 } 1034 }
1039 1035
1040 void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) { 1036 void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) {
1041 if (should_dock) { 1037 if (should_dock) {
1042 if (!dock_layout_->is_dragged_window_docked()) { 1038 if (!dock_layout_->is_dragged_window_docked()) {
1043 window_state()->set_bounds_changed_by_user(false); 1039 window_state()->set_bounds_changed_by_user(false);
1044 dock_layout_->DockDraggedWindow(GetAuraTarget()); 1040 dock_layout_->DockDraggedWindow(GetTarget());
1045 } 1041 }
1046 } else { 1042 } else {
1047 if (dock_layout_->is_dragged_window_docked()) { 1043 if (dock_layout_->is_dragged_window_docked()) {
1048 dock_layout_->UndockDraggedWindow(); 1044 dock_layout_->UndockDraggedWindow();
1049 window_state()->set_bounds_changed_by_user(true); 1045 window_state()->set_bounds_changed_by_user(true);
1050 } 1046 }
1051 } 1047 }
1052 } 1048 }
1053 1049
1054 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds( 1050 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds(
1055 wm::WindowStateType snapped_type, 1051 wm::WindowStateType snapped_type,
1056 const gfx::Rect& bounds_in_parent) const { 1052 const gfx::Rect& bounds_in_parent) const {
1057 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || 1053 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ||
1058 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1054 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1059 gfx::Rect snapped_bounds = 1055 gfx::Rect snapped_bounds =
1060 ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetAuraTarget()); 1056 ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetAuraTarget());
1061 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1057 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1062 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1058 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1063 snapped_bounds.set_width(bounds_in_parent.width()); 1059 snapped_bounds.set_width(bounds_in_parent.width());
1064 return bounds_in_parent == snapped_bounds; 1060 return bounds_in_parent == snapped_bounds;
1065 } 1061 }
1066 1062
1067 } // namespace ash 1063 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698