| 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" | |
| 13 #include "ash/common/metrics/user_metrics_action.h" | 12 #include "ash/common/metrics/user_metrics_action.h" |
| 14 #include "ash/common/wm/default_window_resizer.h" | 13 #include "ash/common/wm/default_window_resizer.h" |
| 15 #include "ash/common/wm/dock/docked_window_layout_manager.h" | |
| 16 #include "ash/common/wm/dock/docked_window_resizer.h" | |
| 17 #include "ash/common/wm/panels/panel_window_resizer.h" | 14 #include "ash/common/wm/panels/panel_window_resizer.h" |
| 18 #include "ash/common/wm/window_positioning_utils.h" | 15 #include "ash/common/wm/window_positioning_utils.h" |
| 19 #include "ash/common/wm/window_state.h" | 16 #include "ash/common/wm/window_state.h" |
| 20 #include "ash/common/wm/wm_event.h" | 17 #include "ash/common/wm/wm_event.h" |
| 21 #include "ash/common/wm/wm_screen_util.h" | 18 #include "ash/common/wm/wm_screen_util.h" |
| 22 #include "ash/common/wm/workspace/phantom_window_controller.h" | 19 #include "ash/common/wm/workspace/phantom_window_controller.h" |
| 23 #include "ash/common/wm/workspace/two_step_edge_cycler.h" | 20 #include "ash/common/wm/workspace/two_step_edge_cycler.h" |
| 24 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 25 #include "ash/common/wm_window.h" | 22 #include "ash/common/wm_window.h" |
| 26 #include "ash/public/cpp/shell_window_ids.h" | 23 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 52 } | 49 } |
| 53 | 50 |
| 54 if (window_component == HTCAPTION && !window_state->can_be_dragged()) | 51 if (window_component == HTCAPTION && !window_state->can_be_dragged()) |
| 55 return nullptr; | 52 return nullptr; |
| 56 | 53 |
| 57 // TODO(varkha): The chaining of window resizers causes some of the logic | 54 // TODO(varkha): The chaining of window resizers causes some of the logic |
| 58 // to be repeated and the logic flow difficult to control. With some windows | 55 // to be repeated and the logic flow difficult to control. With some windows |
| 59 // classes using reparenting during drag operations it becomes challenging to | 56 // classes using reparenting during drag operations it becomes challenging to |
| 60 // implement proper transition from one resizer to another during or at the | 57 // implement proper transition from one resizer to another during or at the |
| 61 // end of the drag. This also causes http://crbug.com/247085. | 58 // end of the drag. This also causes http://crbug.com/247085. |
| 62 // It seems the only thing the panel or dock resizer needs to do is notify the | 59 // We should have a better way of doing this, perhaps by having a way of |
| 63 // layout manager when a docked window is being dragged. We should have a | 60 // observing drags or having a generic drag window wrapper which informs a |
| 64 // better way of doing this, perhaps by having a way of observing drags or | 61 // layout manager that a drag has started or stopped. It may be possible to |
| 65 // having a generic drag window wrapper which informs a layout manager that a | 62 // refactor and eliminate chaining. |
| 66 // drag has started or stopped. | |
| 67 // It may be possible to refactor and eliminate chaining. | |
| 68 std::unique_ptr<WindowResizer> window_resizer; | 63 std::unique_ptr<WindowResizer> window_resizer; |
| 69 | 64 |
| 70 if (!window_state->IsNormalOrSnapped() && !window_state->IsDocked()) | 65 if (!window_state->IsNormalOrSnapped()) |
| 71 return std::unique_ptr<WindowResizer>(); | 66 return std::unique_ptr<WindowResizer>(); |
| 72 | 67 |
| 73 int bounds_change = | 68 int bounds_change = |
| 74 WindowResizer::GetBoundsChangeForWindowComponent(window_component); | 69 WindowResizer::GetBoundsChangeForWindowComponent(window_component); |
| 75 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) | 70 if (bounds_change == WindowResizer::kBoundsChangeDirection_None) |
| 76 return std::unique_ptr<WindowResizer>(); | 71 return std::unique_ptr<WindowResizer>(); |
| 77 | 72 |
| 78 window_state->CreateDragDetails(point_in_parent, window_component, source); | 73 window_state->CreateDragDetails(point_in_parent, window_component, source); |
| 79 const int parent_shell_window_id = | 74 const int parent_shell_window_id = |
| 80 window->GetParent() ? window->GetParent()->GetShellWindowId() : -1; | 75 window->GetParent() ? window->GetParent()->GetShellWindowId() : -1; |
| 81 if (window->GetParent() && | 76 if (window->GetParent() && |
| 82 (parent_shell_window_id == kShellWindowId_DefaultContainer || | 77 (parent_shell_window_id == kShellWindowId_DefaultContainer || |
| 83 parent_shell_window_id == kShellWindowId_DockedContainer || | |
| 84 parent_shell_window_id == kShellWindowId_PanelContainer)) { | 78 parent_shell_window_id == kShellWindowId_PanelContainer)) { |
| 85 window_resizer.reset( | 79 window_resizer.reset( |
| 86 WorkspaceWindowResizer::Create(window_state, std::vector<WmWindow*>())); | 80 WorkspaceWindowResizer::Create(window_state, std::vector<WmWindow*>())); |
| 87 } else { | 81 } else { |
| 88 window_resizer.reset(DefaultWindowResizer::Create(window_state)); | 82 window_resizer.reset(DefaultWindowResizer::Create(window_state)); |
| 89 } | 83 } |
| 90 window_resizer = window->GetShell()->CreateDragWindowResizer( | 84 window_resizer = window->GetShell()->CreateDragWindowResizer( |
| 91 std::move(window_resizer), window_state); | 85 std::move(window_resizer), window_state); |
| 92 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL) | 86 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL) { |
| 93 window_resizer.reset( | 87 window_resizer.reset( |
| 94 PanelWindowResizer::Create(window_resizer.release(), window_state)); | 88 PanelWindowResizer::Create(window_resizer.release(), window_state)); |
| 95 if (window_resizer && window->GetParent() && !window->GetTransientParent() && | |
| 96 (parent_shell_window_id == kShellWindowId_DefaultContainer || | |
| 97 parent_shell_window_id == kShellWindowId_DockedContainer || | |
| 98 parent_shell_window_id == kShellWindowId_PanelContainer)) { | |
| 99 window_resizer.reset( | |
| 100 DockedWindowResizer::Create(window_resizer.release(), window_state)); | |
| 101 } | 89 } |
| 102 return window_resizer; | 90 return window_resizer; |
| 103 } | 91 } |
| 104 | 92 |
| 105 namespace { | 93 namespace { |
| 106 | 94 |
| 107 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset | 95 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset |
| 108 // when resizing a window using touchscreen. | 96 // when resizing a window using touchscreen. |
| 109 const int kScreenEdgeInsetForTouchDrag = 32; | 97 const int kScreenEdgeInsetForTouchDrag = 32; |
| 110 | 98 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 return; | 369 return; |
| 382 } | 370 } |
| 383 const bool in_original_root = !root || root == GetTarget()->GetRootWindow(); | 371 const bool in_original_root = !root || root == GetTarget()->GetRootWindow(); |
| 384 // Hide a phantom window for snapping if the cursor is in another root window. | 372 // Hide a phantom window for snapping if the cursor is in another root window. |
| 385 if (in_original_root) { | 373 if (in_original_root) { |
| 386 UpdateSnapPhantomWindow(location_in_parent, bounds); | 374 UpdateSnapPhantomWindow(location_in_parent, bounds); |
| 387 } else { | 375 } else { |
| 388 snap_type_ = SNAP_NONE; | 376 snap_type_ = SNAP_NONE; |
| 389 snap_phantom_window_controller_.reset(); | 377 snap_phantom_window_controller_.reset(); |
| 390 edge_cycler_.reset(); | 378 edge_cycler_.reset(); |
| 391 SetDraggedWindowDocked(false); | |
| 392 } | 379 } |
| 393 } | 380 } |
| 394 | 381 |
| 395 void WorkspaceWindowResizer::CompleteDrag() { | 382 void WorkspaceWindowResizer::CompleteDrag() { |
| 396 if (!did_move_or_resize_) | 383 if (!did_move_or_resize_) |
| 397 return; | 384 return; |
| 398 | 385 |
| 399 window_state()->set_bounds_changed_by_user(true); | 386 window_state()->set_bounds_changed_by_user(true); |
| 400 snap_phantom_window_controller_.reset(); | 387 snap_phantom_window_controller_.reset(); |
| 401 | 388 |
| 402 // If the window's state type changed over the course of the drag do not snap | 389 // If the window's state type changed over the course of the drag do not snap |
| 403 // the window. This happens when the user minimizes or maximizes the window | 390 // the window. This happens when the user minimizes or maximizes the window |
| 404 // using a keyboard shortcut while dragging it. | 391 // using a keyboard shortcut while dragging it. |
| 405 if (window_state()->GetStateType() != details().initial_state_type) | 392 if (window_state()->GetStateType() != details().initial_state_type) |
| 406 return; | 393 return; |
| 407 | 394 |
| 408 bool snapped = false; | 395 bool snapped = false; |
| 409 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { | 396 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { |
| 410 if (!window_state()->HasRestoreBounds()) { | 397 if (!window_state()->HasRestoreBounds()) { |
| 411 gfx::Rect initial_bounds = GetTarget()->GetParent()->ConvertRectToScreen( | 398 gfx::Rect initial_bounds = GetTarget()->GetParent()->ConvertRectToScreen( |
| 412 details().initial_bounds_in_parent); | 399 details().initial_bounds_in_parent); |
| 413 window_state()->SetRestoreBoundsInScreen( | 400 window_state()->SetRestoreBoundsInScreen( |
| 414 details().restore_bounds.IsEmpty() ? initial_bounds | 401 details().restore_bounds.IsEmpty() ? initial_bounds |
| 415 : details().restore_bounds); | 402 : details().restore_bounds); |
| 416 } | 403 } |
| 417 if (!dock_layout_->is_dragged_window_docked()) { | 404 // TODO(oshima): Add event source type to WMEvent and move |
| 418 // TODO(oshima): Add event source type to WMEvent and move | 405 // metrics recording inside WindowState::OnWMEvent. |
| 419 // metrics recording inside WindowState::OnWMEvent. | 406 const wm::WMEvent event(snap_type_ == SNAP_LEFT ? wm::WM_EVENT_SNAP_LEFT |
| 420 const wm::WMEvent event(snap_type_ == SNAP_LEFT | 407 : wm::WM_EVENT_SNAP_RIGHT); |
| 421 ? wm::WM_EVENT_SNAP_LEFT | 408 window_state()->OnWMEvent(&event); |
| 422 : wm::WM_EVENT_SNAP_RIGHT); | 409 shell_->RecordUserMetricsAction(snap_type_ == SNAP_LEFT |
| 423 window_state()->OnWMEvent(&event); | 410 ? UMA_DRAG_MAXIMIZE_LEFT |
| 424 shell_->RecordUserMetricsAction(snap_type_ == SNAP_LEFT | 411 : UMA_DRAG_MAXIMIZE_RIGHT); |
| 425 ? UMA_DRAG_MAXIMIZE_LEFT | 412 snapped = true; |
| 426 : UMA_DRAG_MAXIMIZE_RIGHT); | |
| 427 snapped = true; | |
| 428 } | |
| 429 } | 413 } |
| 430 | 414 |
| 431 if (!snapped) { | 415 if (!snapped) { |
| 432 if (window_state()->IsSnapped()) { | 416 if (window_state()->IsSnapped()) { |
| 433 // Keep the window snapped if the user resizes the window such that the | 417 // Keep the window snapped if the user resizes the window such that the |
| 434 // window has valid bounds for a snapped window. Always unsnap the window | 418 // window has valid bounds for a snapped window. Always unsnap the window |
| 435 // if the user dragged the window via the caption area because doing this | 419 // if the user dragged the window via the caption area because doing this |
| 436 // is slightly less confusing. | 420 // is slightly less confusing. |
| 437 if (details().window_component == HTCAPTION || | 421 if (details().window_component == HTCAPTION || |
| 438 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), | 422 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), |
| 439 GetTarget()->GetBounds())) { | 423 GetTarget()->GetBounds())) { |
| 440 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the | 424 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the |
| 441 // window at the bounds that the user has moved/resized the | 425 // window at the bounds that the user has moved/resized the |
| 442 // window to. | 426 // window to. |
| 443 window_state()->SaveCurrentBoundsForRestore(); | 427 window_state()->SaveCurrentBoundsForRestore(); |
| 444 window_state()->Restore(); | 428 window_state()->Restore(); |
| 445 } | 429 } |
| 446 } else if (!dock_layout_->is_dragged_window_docked()) { | 430 } else { |
| 447 // The window was not snapped and is not snapped. This is a user | 431 // The window was not snapped and is not snapped. This is a user |
| 448 // resize/drag and so the current bounds should be maintained, clearing | 432 // resize/drag and so the current bounds should be maintained, clearing |
| 449 // any prior restore bounds. When the window is docked the restore bound | 433 // any prior restore bounds. |
| 450 // must be kept so the docked state can be reverted properly. | |
| 451 window_state()->ClearRestoreBounds(); | 434 window_state()->ClearRestoreBounds(); |
| 452 } | 435 } |
| 453 } | 436 } |
| 454 } | 437 } |
| 455 | 438 |
| 456 void WorkspaceWindowResizer::RevertDrag() { | 439 void WorkspaceWindowResizer::RevertDrag() { |
| 457 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); | 440 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); |
| 458 snap_phantom_window_controller_.reset(); | 441 snap_phantom_window_controller_.reset(); |
| 459 | 442 |
| 460 if (!did_move_or_resize_) | 443 if (!did_move_or_resize_) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 weak_ptr_factory_(this) { | 485 weak_ptr_factory_(this) { |
| 503 DCHECK(details().is_resizable); | 486 DCHECK(details().is_resizable); |
| 504 | 487 |
| 505 // A mousemove should still show the cursor even if the window is | 488 // A mousemove should still show the cursor even if the window is |
| 506 // being moved or resized with touch, so do not lock the cursor. | 489 // being moved or resized with touch, so do not lock the cursor. |
| 507 if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) { | 490 if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) { |
| 508 shell_->LockCursor(); | 491 shell_->LockCursor(); |
| 509 did_lock_cursor_ = true; | 492 did_lock_cursor_ = true; |
| 510 } | 493 } |
| 511 | 494 |
| 512 dock_layout_ = DockedWindowLayoutManager::Get(GetTarget()); | |
| 513 | |
| 514 // Only support attaching to the right/bottom. | 495 // Only support attaching to the right/bottom. |
| 515 DCHECK(attached_windows_.empty() || (details().window_component == HTRIGHT || | 496 DCHECK(attached_windows_.empty() || (details().window_component == HTRIGHT || |
| 516 details().window_component == HTBOTTOM)); | 497 details().window_component == HTBOTTOM)); |
| 517 | 498 |
| 518 // TODO: figure out how to deal with window going off the edge. | 499 // TODO: figure out how to deal with window going off the edge. |
| 519 | 500 |
| 520 // Calculate sizes so that we can maintain the ratios if we need to resize. | 501 // Calculate sizes so that we can maintain the ratios if we need to resize. |
| 521 int total_available = 0; | 502 int total_available = 0; |
| 522 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 503 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
| 523 gfx::Size min(attached_windows_[i]->GetMinimumSize()); | 504 gfx::Size min(attached_windows_[i]->GetMinimumSize()); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, | 848 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, |
| 868 const gfx::Rect& bounds) { | 849 const gfx::Rect& bounds) { |
| 869 if (!did_move_or_resize_ || details().window_component != HTCAPTION) | 850 if (!did_move_or_resize_ || details().window_component != HTCAPTION) |
| 870 return; | 851 return; |
| 871 | 852 |
| 872 SnapType last_type = snap_type_; | 853 SnapType last_type = snap_type_; |
| 873 snap_type_ = GetSnapType(location); | 854 snap_type_ = GetSnapType(location); |
| 874 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { | 855 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { |
| 875 snap_phantom_window_controller_.reset(); | 856 snap_phantom_window_controller_.reset(); |
| 876 edge_cycler_.reset(); | 857 edge_cycler_.reset(); |
| 877 if (snap_type_ == SNAP_NONE) { | 858 if (snap_type_ == SNAP_NONE) |
| 878 SetDraggedWindowDocked(false); | |
| 879 return; | 859 return; |
| 880 } | |
| 881 } | 860 } |
| 882 | 861 |
| 883 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT); | 862 DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT); |
| 884 DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) | |
| 885 ? DOCKED_ALIGNMENT_LEFT | |
| 886 : DOCKED_ALIGNMENT_RIGHT; | |
| 887 const bool can_dock = | |
| 888 ash::switches::DockedWindowsEnabled() && | |
| 889 dock_layout_->CanDockWindow(GetTarget(), desired_alignment) && | |
| 890 dock_layout_->GetAlignmentOfWindow(GetTarget()) != DOCKED_ALIGNMENT_NONE; | |
| 891 if (!can_dock) { | |
| 892 // If the window cannot be docked, undock the window. This may change the | |
| 893 // workspace bounds and hence |snap_type_|. | |
| 894 SetDraggedWindowDocked(false); | |
| 895 snap_type_ = GetSnapType(location); | |
| 896 } | |
| 897 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); | 863 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); |
| 898 if (!can_snap && !can_dock) { | 864 if (!can_snap) { |
| 899 snap_type_ = SNAP_NONE; | 865 snap_type_ = SNAP_NONE; |
| 900 snap_phantom_window_controller_.reset(); | 866 snap_phantom_window_controller_.reset(); |
| 901 edge_cycler_.reset(); | 867 edge_cycler_.reset(); |
| 902 return; | 868 return; |
| 903 } | 869 } |
| 904 if (!edge_cycler_) { | 870 if (!edge_cycler_) { |
| 905 edge_cycler_.reset(new TwoStepEdgeCycler( | 871 edge_cycler_.reset(new TwoStepEdgeCycler( |
| 906 location, snap_type_ == SNAP_LEFT | 872 location, snap_type_ == SNAP_LEFT |
| 907 ? TwoStepEdgeCycler::DIRECTION_LEFT | 873 ? TwoStepEdgeCycler::DIRECTION_LEFT |
| 908 : TwoStepEdgeCycler::DIRECTION_RIGHT)); | 874 : TwoStepEdgeCycler::DIRECTION_RIGHT)); |
| 909 } else { | 875 } else { |
| 910 edge_cycler_->OnMove(location); | 876 edge_cycler_->OnMove(location); |
| 911 } | 877 } |
| 912 | 878 |
| 913 // Update phantom window with snapped or docked guide bounds. | 879 // Update phantom window with snapped guide bounds. |
| 914 // Windows that cannot be snapped or are less wide than kMaxDockWidth can get | 880 const gfx::Rect phantom_bounds = |
| 915 // docked without going through a snapping sequence. | 881 (snap_type_ == SNAP_LEFT) |
| 916 gfx::Rect phantom_bounds; | 882 ? wm::GetDefaultLeftSnappedWindowBoundsInParent(GetTarget()) |
| 917 const bool should_dock = | 883 : wm::GetDefaultRightSnappedWindowBoundsInParent(GetTarget()); |
| 918 can_dock && (!can_snap || | |
| 919 GetTarget()->GetBounds().width() <= | |
| 920 DockedWindowLayoutManager::kMaxDockWidth || | |
| 921 edge_cycler_->use_second_mode() || | |
| 922 dock_layout_->is_dragged_window_docked()); | |
| 923 if (should_dock) { | |
| 924 SetDraggedWindowDocked(true); | |
| 925 phantom_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( | |
| 926 dock_layout_->dragged_bounds()); | |
| 927 } else { | |
| 928 phantom_bounds = | |
| 929 (snap_type_ == SNAP_LEFT) | |
| 930 ? wm::GetDefaultLeftSnappedWindowBoundsInParent(GetTarget()) | |
| 931 : wm::GetDefaultRightSnappedWindowBoundsInParent(GetTarget()); | |
| 932 } | |
| 933 | 884 |
| 934 if (!snap_phantom_window_controller_) { | 885 if (!snap_phantom_window_controller_) { |
| 935 snap_phantom_window_controller_.reset( | 886 snap_phantom_window_controller_.reset( |
| 936 new PhantomWindowController(GetTarget())); | 887 new PhantomWindowController(GetTarget())); |
| 937 } | 888 } |
| 938 snap_phantom_window_controller_->Show( | 889 snap_phantom_window_controller_->Show( |
| 939 GetTarget()->GetParent()->ConvertRectToScreen(phantom_bounds)); | 890 GetTarget()->GetParent()->ConvertRectToScreen(phantom_bounds)); |
| 940 } | 891 } |
| 941 | 892 |
| 942 void WorkspaceWindowResizer::RestackWindows() { | 893 void WorkspaceWindowResizer::RestackWindows() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 inset_right = kScreenEdgeInsetForTouchDrag; | 936 inset_right = kScreenEdgeInsetForTouchDrag; |
| 986 area.Inset(inset_left, 0, inset_right, 0); | 937 area.Inset(inset_left, 0, inset_right, 0); |
| 987 } | 938 } |
| 988 if (location.x() <= area.x()) | 939 if (location.x() <= area.x()) |
| 989 return SNAP_LEFT; | 940 return SNAP_LEFT; |
| 990 if (location.x() >= area.right() - 1) | 941 if (location.x() >= area.right() - 1) |
| 991 return SNAP_RIGHT; | 942 return SNAP_RIGHT; |
| 992 return SNAP_NONE; | 943 return SNAP_NONE; |
| 993 } | 944 } |
| 994 | 945 |
| 995 void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) { | |
| 996 if (should_dock) { | |
| 997 if (!dock_layout_->is_dragged_window_docked()) { | |
| 998 window_state()->set_bounds_changed_by_user(false); | |
| 999 dock_layout_->DockDraggedWindow(GetTarget()); | |
| 1000 } | |
| 1001 } else { | |
| 1002 if (dock_layout_->is_dragged_window_docked()) { | |
| 1003 dock_layout_->UndockDraggedWindow(); | |
| 1004 window_state()->set_bounds_changed_by_user(true); | |
| 1005 } | |
| 1006 } | |
| 1007 } | |
| 1008 | |
| 1009 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds( | 946 bool WorkspaceWindowResizer::AreBoundsValidSnappedBounds( |
| 1010 wm::WindowStateType snapped_type, | 947 wm::WindowStateType snapped_type, |
| 1011 const gfx::Rect& bounds_in_parent) const { | 948 const gfx::Rect& bounds_in_parent) const { |
| 1012 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 949 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
| 1013 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 950 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1014 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); | 951 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); |
| 1015 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 952 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1016 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 953 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1017 snapped_bounds.set_width(bounds_in_parent.width()); | 954 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1018 return bounds_in_parent == snapped_bounds; | 955 return bounds_in_parent == snapped_bounds; |
| 1019 } | 956 } |
| 1020 | 957 |
| 1021 } // namespace ash | 958 } // namespace ash |
| OLD | NEW |