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

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

Issue 1929023002: Refactors WindowResizers to use ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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>
11 11
12 #include "ash/metrics/user_metrics_recorder.h"
13 #include "ash/wm/common/default_window_resizer.h" 12 #include "ash/wm/common/default_window_resizer.h"
14 #include "ash/wm/common/dock/docked_window_layout_manager.h" 13 #include "ash/wm/common/dock/docked_window_layout_manager.h"
15 #include "ash/wm/common/window_positioning_utils.h" 14 #include "ash/wm/common/window_positioning_utils.h"
16 #include "ash/wm/common/window_state.h" 15 #include "ash/wm/common/window_state.h"
17 #include "ash/wm/common/wm_event.h" 16 #include "ash/wm/common/wm_event.h"
18 #include "ash/wm/common/wm_globals.h" 17 #include "ash/wm/common/wm_globals.h"
19 #include "ash/wm/common/wm_root_window_controller.h" 18 #include "ash/wm/common/wm_root_window_controller.h"
20 #include "ash/wm/common/wm_screen_util.h" 19 #include "ash/wm/common/wm_screen_util.h"
21 #include "ash/wm/common/wm_shell_window_ids.h" 20 #include "ash/wm/common/wm_shell_window_ids.h"
21 #include "ash/wm/common/wm_user_metrics_action.h"
22 #include "ash/wm/common/wm_window.h" 22 #include "ash/wm/common/wm_window.h"
23 #include "ash/wm/dock/docked_window_resizer.h" 23 #include "ash/wm/dock/docked_window_resizer.h"
24 #include "ash/wm/drag_window_resizer.h"
25 #include "ash/wm/panels/panel_window_resizer.h" 24 #include "ash/wm/panels/panel_window_resizer.h"
26 #include "ash/wm/workspace/phantom_window_controller.h" 25 #include "ash/wm/workspace/phantom_window_controller.h"
27 #include "ash/wm/workspace/two_step_edge_cycler.h" 26 #include "ash/wm/workspace/two_step_edge_cycler.h"
28 #include "base/memory/ptr_util.h" 27 #include "base/memory/ptr_util.h"
29 #include "base/memory/weak_ptr.h" 28 #include "base/memory/weak_ptr.h"
30 #include "ui/base/hit_test.h" 29 #include "ui/base/hit_test.h"
31 #include "ui/compositor/layer.h" 30 #include "ui/compositor/layer.h"
32 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
33 #include "ui/gfx/transform.h" 32 #include "ui/gfx/transform.h"
34 #include "ui/wm/public/window_types.h" 33 #include "ui/wm/public/window_types.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 window->GetParent() ? window->GetParent()->GetShellWindowId() : -1; 77 window->GetParent() ? window->GetParent()->GetShellWindowId() : -1;
79 if (window->GetParent() && 78 if (window->GetParent() &&
80 (parent_shell_window_id == kShellWindowId_DefaultContainer || 79 (parent_shell_window_id == kShellWindowId_DefaultContainer ||
81 parent_shell_window_id == kShellWindowId_DockedContainer || 80 parent_shell_window_id == kShellWindowId_DockedContainer ||
82 parent_shell_window_id == kShellWindowId_PanelContainer)) { 81 parent_shell_window_id == kShellWindowId_PanelContainer)) {
83 window_resizer.reset(WorkspaceWindowResizer::Create( 82 window_resizer.reset(WorkspaceWindowResizer::Create(
84 window_state, std::vector<wm::WmWindow*>())); 83 window_state, std::vector<wm::WmWindow*>()));
85 } else { 84 } else {
86 window_resizer.reset(DefaultWindowResizer::Create(window_state)); 85 window_resizer.reset(DefaultWindowResizer::Create(window_state));
87 } 86 }
88 window_resizer.reset( 87 window_resizer = window->GetGlobals()->CreateDragWindowResizer(
89 DragWindowResizer::Create(window_resizer.release(), window_state)); 88 std::move(window_resizer), window_state);
90 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL) 89 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL)
91 window_resizer.reset( 90 window_resizer.reset(
92 PanelWindowResizer::Create(window_resizer.release(), window_state)); 91 PanelWindowResizer::Create(window_resizer.release(), window_state));
93 if (window_resizer && window->GetParent() && !window->GetTransientParent() && 92 if (window_resizer && window->GetParent() && !window->GetTransientParent() &&
94 (parent_shell_window_id == kShellWindowId_DefaultContainer || 93 (parent_shell_window_id == kShellWindowId_DefaultContainer ||
95 parent_shell_window_id == kShellWindowId_DockedContainer || 94 parent_shell_window_id == kShellWindowId_DockedContainer ||
96 parent_shell_window_id == kShellWindowId_PanelContainer)) { 95 parent_shell_window_id == kShellWindowId_PanelContainer)) {
97 window_resizer.reset( 96 window_resizer.reset(
98 DockedWindowResizer::Create(window_resizer.release(), window_state)); 97 DockedWindowResizer::Create(window_resizer.release(), window_state));
99 } 98 }
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { 421 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) {
423 if (!window_state()->HasRestoreBounds()) { 422 if (!window_state()->HasRestoreBounds()) {
424 gfx::Rect initial_bounds = GetTarget()->GetParent()->ConvertRectToScreen( 423 gfx::Rect initial_bounds = GetTarget()->GetParent()->ConvertRectToScreen(
425 details().initial_bounds_in_parent); 424 details().initial_bounds_in_parent);
426 window_state()->SetRestoreBoundsInScreen( 425 window_state()->SetRestoreBoundsInScreen(
427 details().restore_bounds.IsEmpty() ? 426 details().restore_bounds.IsEmpty() ?
428 initial_bounds : 427 initial_bounds :
429 details().restore_bounds); 428 details().restore_bounds);
430 } 429 }
431 if (!dock_layout_->is_dragged_window_docked()) { 430 if (!dock_layout_->is_dragged_window_docked()) {
432 UserMetricsRecorder* metrics = globals_->GetUserMetricsRecorder();
433 // TODO(oshima): Add event source type to WMEvent and move 431 // TODO(oshima): Add event source type to WMEvent and move
434 // metrics recording inside WindowState::OnWMEvent. 432 // metrics recording inside WindowState::OnWMEvent.
435 const wm::WMEvent event(snap_type_ == SNAP_LEFT ? 433 const wm::WMEvent event(snap_type_ == SNAP_LEFT ?
436 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT); 434 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT);
437 window_state()->OnWMEvent(&event); 435 window_state()->OnWMEvent(&event);
438 metrics->RecordUserMetricsAction( 436 globals_->RecordUserMetricsAction(
439 snap_type_ == SNAP_LEFT ? 437 snap_type_ == SNAP_LEFT
440 UMA_DRAG_MAXIMIZE_LEFT : UMA_DRAG_MAXIMIZE_RIGHT); 438 ? wm::WmUserMetricsAction::DRAG_MAXIMIZE_LEFT
439 : wm::WmUserMetricsAction::DRAG_MAXIMIZE_RIGHT);
441 snapped = true; 440 snapped = true;
442 } 441 }
443 } 442 }
444 443
445 if (!snapped) { 444 if (!snapped) {
446 if (window_state()->IsSnapped()) { 445 if (window_state()->IsSnapped()) {
447 // Keep the window snapped if the user resizes the window such that the 446 // Keep the window snapped if the user resizes the window such that the
448 // window has valid bounds for a snapped window. Always unsnap the window 447 // window has valid bounds for a snapped window. Always unsnap the window
449 // if the user dragged the window via the caption area because doing this 448 // if the user dragged the window via the caption area because doing this
450 // is slightly less confusing. 449 // is slightly less confusing.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || 1033 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ||
1035 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1034 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1036 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); 1035 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget());
1037 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1036 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1038 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1037 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1039 snapped_bounds.set_width(bounds_in_parent.width()); 1038 snapped_bounds.set_width(bounds_in_parent.width());
1040 return bounds_in_parent == snapped_bounds; 1039 return bounds_in_parent == snapped_bounds;
1041 } 1040 }
1042 1041
1043 } // namespace ash 1042 } // namespace ash
OLDNEW
« ash/wm/common/wm_globals.h ('K') | « ash/wm/workspace/phantom_window_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698