| 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/display/display_controller.h" | 12 #include "ash/display/display_controller.h" |
| 13 #include "ash/metrics/user_metrics_recorder.h" | 13 #include "ash/metrics/user_metrics_recorder.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "ash/wm/coordinate_conversion.h" |
| 18 #include "ash/wm/default_window_resizer.h" | 19 #include "ash/wm/default_window_resizer.h" |
| 19 #include "ash/wm/dock/docked_window_layout_manager.h" | 20 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 20 #include "ash/wm/dock/docked_window_resizer.h" | 21 #include "ash/wm/dock/docked_window_resizer.h" |
| 21 #include "ash/wm/drag_window_resizer.h" | 22 #include "ash/wm/drag_window_resizer.h" |
| 22 #include "ash/wm/panels/panel_window_resizer.h" | 23 #include "ash/wm/panels/panel_window_resizer.h" |
| 23 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
| 24 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
| 25 #include "ash/wm/wm_event.h" | 26 #include "ash/wm/wm_event.h" |
| 26 #include "ash/wm/workspace/phantom_window_controller.h" | 27 #include "ash/wm/workspace/phantom_window_controller.h" |
| 27 #include "ash/wm/workspace/two_step_edge_cycler.h" | 28 #include "ash/wm/workspace/two_step_edge_cycler.h" |
| 28 #include "base/command_line.h" | 29 #include "base/command_line.h" |
| 29 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
| 30 #include "ui/aura/client/aura_constants.h" | 31 #include "ui/aura/client/aura_constants.h" |
| 31 #include "ui/aura/client/screen_position_client.h" | 32 #include "ui/aura/client/screen_position_client.h" |
| 32 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 33 #include "ui/aura/window_delegate.h" | 34 #include "ui/aura/window_delegate.h" |
| 34 #include "ui/aura/window_event_dispatcher.h" | 35 #include "ui/aura/window_event_dispatcher.h" |
| 35 #include "ui/base/hit_test.h" | 36 #include "ui/base/hit_test.h" |
| 36 #include "ui/compositor/layer.h" | 37 #include "ui/compositor/layer.h" |
| 37 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
| 38 #include "ui/gfx/transform.h" | 39 #include "ui/gfx/transform.h" |
| 39 #include "ui/wm/core/coordinate_conversion.h" | |
| 40 #include "ui/wm/core/window_util.h" | 40 #include "ui/wm/core/window_util.h" |
| 41 #include "ui/wm/public/window_types.h" | 41 #include "ui/wm/public/window_types.h" |
| 42 | 42 |
| 43 namespace ash { | 43 namespace ash { |
| 44 | 44 |
| 45 scoped_ptr<WindowResizer> CreateWindowResizer( | 45 scoped_ptr<WindowResizer> CreateWindowResizer( |
| 46 aura::Window* window, | 46 aura::Window* window, |
| 47 const gfx::Point& point_in_parent, | 47 const gfx::Point& point_in_parent, |
| 48 int window_component, | 48 int window_component, |
| 49 aura::client::WindowMoveSource source) { | 49 aura::client::WindowMoveSource source) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (bounds != GetTarget()->bounds()) { | 364 if (bounds != GetTarget()->bounds()) { |
| 365 if (!did_move_or_resize_) { | 365 if (!did_move_or_resize_) { |
| 366 if (!details().restore_bounds.IsEmpty()) | 366 if (!details().restore_bounds.IsEmpty()) |
| 367 window_state()->ClearRestoreBounds(); | 367 window_state()->ClearRestoreBounds(); |
| 368 RestackWindows(); | 368 RestackWindows(); |
| 369 } | 369 } |
| 370 did_move_or_resize_ = true; | 370 did_move_or_resize_ = true; |
| 371 } | 371 } |
| 372 | 372 |
| 373 gfx::Point location_in_screen = location_in_parent; | 373 gfx::Point location_in_screen = location_in_parent; |
| 374 ::wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); | 374 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); |
| 375 | 375 |
| 376 aura::Window* root = NULL; | 376 aura::Window* root = NULL; |
| 377 gfx::Display display = | 377 gfx::Display display = |
| 378 ScreenUtil::FindDisplayContainingPoint(location_in_screen); | 378 ScreenUtil::FindDisplayContainingPoint(location_in_screen); |
| 379 // Track the last screen that the pointer was on to keep the snap phantom | 379 // Track the last screen that the pointer was on to keep the snap phantom |
| 380 // window there. | 380 // window there. |
| 381 if (display.is_valid()) { | 381 if (display.is_valid()) { |
| 382 root = Shell::GetInstance()->display_controller()-> | 382 root = Shell::GetInstance()->display_controller()-> |
| 383 GetRootWindowForDisplayId(display.id()); | 383 GetRootWindowForDisplayId(display.id()); |
| 384 } | 384 } |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 } | 766 } |
| 767 return false; | 767 return false; |
| 768 } | 768 } |
| 769 | 769 |
| 770 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( | 770 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( |
| 771 int sticky_size, | 771 int sticky_size, |
| 772 gfx::Rect* bounds) { | 772 gfx::Rect* bounds) { |
| 773 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 773 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| 774 ::wm::ConvertPointToScreen(GetTarget()->parent(), | 774 wm::ConvertPointToScreen(GetTarget()->parent(), |
| 775 &last_mouse_location_in_screen); | 775 &last_mouse_location_in_screen); |
| 776 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint( | 776 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint( |
| 777 last_mouse_location_in_screen); | 777 last_mouse_location_in_screen); |
| 778 gfx::Rect work_area = | 778 gfx::Rect work_area = |
| 779 ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), | 779 ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), |
| 780 display.work_area()); | 780 display.work_area()); |
| 781 if (details().window_component == HTCAPTION) { | 781 if (details().window_component == HTCAPTION) { |
| 782 // Adjust the bounds to the work area where the mouse cursor is located. | 782 // Adjust the bounds to the work area where the mouse cursor is located. |
| 783 // Always keep kMinOnscreenHeight or the window height (whichever is less) | 783 // Always keep kMinOnscreenHeight or the window height (whichever is less) |
| 784 // on the bottom. | 784 // on the bottom. |
| 785 int max_y = work_area.bottom() - std::min(kMinOnscreenHeight, | 785 int max_y = work_area.bottom() - std::min(kMinOnscreenHeight, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1038 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1039 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1039 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 1040 GetTarget()); | 1040 GetTarget()); |
| 1041 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1041 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1042 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1042 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1043 snapped_bounds.set_width(bounds_in_parent.width()); | 1043 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1044 return bounds_in_parent == snapped_bounds; | 1044 return bounds_in_parent == snapped_bounds; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 } // namespace ash | 1047 } // namespace ash |
| OLD | NEW |