Chromium Code Reviews| 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/ash_switches.h" | 12 #include "ash/ash_switches.h" |
| 13 #include "ash/display/display_controller.h" | 13 #include "ash/display/display_controller.h" |
| 14 #include "ash/screen_ash.h" | 14 #include "ash/screen_ash.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
| 17 #include "ash/wm/coordinate_conversion.h" | 17 #include "ash/wm/coordinate_conversion.h" |
| 18 #include "ash/wm/default_window_resizer.h" | 18 #include "ash/wm/default_window_resizer.h" |
| 19 #include "ash/wm/dock/dock_layout_manager.h" | |
| 20 #include "ash/wm/dock/dock_window_resizer.h" | |
| 19 #include "ash/wm/drag_window_resizer.h" | 21 #include "ash/wm/drag_window_resizer.h" |
| 20 #include "ash/wm/panels/panel_window_resizer.h" | 22 #include "ash/wm/panels/panel_window_resizer.h" |
| 21 #include "ash/wm/property_util.h" | 23 #include "ash/wm/property_util.h" |
| 22 #include "ash/wm/window_properties.h" | 24 #include "ash/wm/window_properties.h" |
| 23 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
| 24 #include "ash/wm/workspace/phantom_window_controller.h" | 26 #include "ash/wm/workspace/phantom_window_controller.h" |
| 25 #include "ash/wm/workspace/snap_sizer.h" | 27 #include "ash/wm/workspace/snap_sizer.h" |
| 26 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 27 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 28 #include "ui/aura/client/window_types.h" | 30 #include "ui/aura/client/window_types.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 58 window_component, | 60 window_component, |
| 59 std::vector<aura::Window*>()); | 61 std::vector<aura::Window*>()); |
| 60 } else if (wm::IsWindowNormal(window)) { | 62 } else if (wm::IsWindowNormal(window)) { |
| 61 window_resizer = DefaultWindowResizer::Create( | 63 window_resizer = DefaultWindowResizer::Create( |
| 62 window, point_in_parent, window_component); | 64 window, point_in_parent, window_component); |
| 63 } | 65 } |
| 64 if (window_resizer) { | 66 if (window_resizer) { |
| 65 window_resizer = internal::DragWindowResizer::Create( | 67 window_resizer = internal::DragWindowResizer::Create( |
| 66 window_resizer, window, point_in_parent, window_component); | 68 window_resizer, window, point_in_parent, window_component); |
| 67 } | 69 } |
| 68 if (window_resizer && window->type() == aura::client::WINDOW_TYPE_PANEL) { | 70 if (window_resizer && GetDockEdge(window) != DOCK_EDGE_NONE) { |
| 71 window_resizer = DockWindowResizer::Create( | |
| 72 window_resizer, window, point_in_parent, window_component); | |
| 73 } else if (window_resizer && | |
| 74 window->type() == aura::client::WINDOW_TYPE_PANEL) { | |
|
flackr
2013/06/04 19:58:10
Should this really be an else if? Wouldn't this pr
varkha
2013/06/07 19:01:28
It would (for the panels). This is a symmetrical s
| |
| 69 window_resizer = PanelWindowResizer::Create( | 75 window_resizer = PanelWindowResizer::Create( |
| 70 window_resizer, window, point_in_parent, window_component); | 76 window_resizer, window, point_in_parent, window_component); |
| 71 } | 77 } |
| 72 return make_scoped_ptr<WindowResizer>(window_resizer); | 78 return make_scoped_ptr<WindowResizer>(window_resizer); |
| 73 } | 79 } |
| 74 | 80 |
| 75 namespace internal { | 81 namespace internal { |
| 76 | 82 |
| 77 namespace { | 83 namespace { |
| 78 | 84 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 | 302 |
| 297 private: | 303 private: |
| 298 int size_; | 304 int size_; |
| 299 int min_; | 305 int min_; |
| 300 int max_; | 306 int max_; |
| 301 }; | 307 }; |
| 302 | 308 |
| 303 WorkspaceWindowResizer::~WorkspaceWindowResizer() { | 309 WorkspaceWindowResizer::~WorkspaceWindowResizer() { |
| 304 Shell* shell = Shell::GetInstance(); | 310 Shell* shell = Shell::GetInstance(); |
| 305 shell->cursor_manager()->UnlockCursor(); | 311 shell->cursor_manager()->UnlockCursor(); |
| 312 | |
| 313 if (GetDockEdge(window()) != dock_edge_ && | |
| 314 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 315 switches::kAshEnableDockedWindows)) | |
| 316 if (window()->type() != aura::client::WINDOW_TYPE_PANEL || | |
| 317 !window()->GetProperty(internal::kPanelAttachedKey)) | |
| 318 SetDockEdge(window(), dock_edge_); | |
|
flackr
2013/06/04 19:58:10
This should probably be in CompleteDrag. Also we s
varkha
2013/06/07 19:01:28
Done (the first part). The second part may get add
| |
| 306 } | 319 } |
| 307 | 320 |
| 308 // static | 321 // static |
| 309 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( | 322 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( |
| 310 aura::Window* window, | 323 aura::Window* window, |
| 311 const gfx::Point& location_in_parent, | 324 const gfx::Point& location_in_parent, |
| 312 int window_component, | 325 int window_component, |
| 313 const std::vector<aura::Window*>& attached_windows) { | 326 const std::vector<aura::Window*>& attached_windows) { |
| 314 Details details(window, location_in_parent, window_component); | 327 Details details(window, location_in_parent, window_component); |
| 315 return details.is_resizable ? | 328 return details.is_resizable ? |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 if (bounds != window()->bounds()) | 374 if (bounds != window()->bounds()) |
| 362 window()->SetBounds(bounds); | 375 window()->SetBounds(bounds); |
| 363 } | 376 } |
| 364 | 377 |
| 365 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { | 378 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { |
| 366 wm::SetUserHasChangedWindowPositionOrSize(details_.window, true); | 379 wm::SetUserHasChangedWindowPositionOrSize(details_.window, true); |
| 367 snap_phantom_window_controller_.reset(); | 380 snap_phantom_window_controller_.reset(); |
| 368 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 381 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
| 369 return; | 382 return; |
| 370 | 383 |
| 371 // When the window is not in the normal show state, we do not snap thw window. | 384 // When the window is not in the normal show state, we do not snap the window. |
| 372 // This happens when the user minimizes or maximizes the window by keyboard | 385 // This happens when the user minimizes or maximizes the window by keyboard |
| 373 // shortcut while dragging it. If the window is the result of dragging a tab | 386 // shortcut while dragging it. If the window is the result of dragging a tab |
| 374 // out of a maximized window, it's already in the normal show state when this | 387 // out of a maximized window, it's already in the normal show state when this |
| 375 // is called, so it does not matter. | 388 // is called, so it does not matter. |
| 376 if (wm::IsWindowNormal(window()) && | 389 if (wm::IsWindowNormal(window()) && |
| 377 (window()->type() != aura::client::WINDOW_TYPE_PANEL || | 390 (window()->type() != aura::client::WINDOW_TYPE_PANEL || |
| 378 !window()->GetProperty(kPanelAttachedKey)) && | 391 !window()->GetProperty(kPanelAttachedKey)) && |
| 379 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { | 392 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { |
| 380 if (!GetRestoreBoundsInScreen(window())) { | 393 if (!GetRestoreBoundsInScreen(window())) { |
| 381 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( | 394 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 | 439 |
| 427 WorkspaceWindowResizer::WorkspaceWindowResizer( | 440 WorkspaceWindowResizer::WorkspaceWindowResizer( |
| 428 const Details& details, | 441 const Details& details, |
| 429 const std::vector<aura::Window*>& attached_windows) | 442 const std::vector<aura::Window*>& attached_windows) |
| 430 : details_(details), | 443 : details_(details), |
| 431 attached_windows_(attached_windows), | 444 attached_windows_(attached_windows), |
| 432 did_move_or_resize_(false), | 445 did_move_or_resize_(false), |
| 433 total_min_(0), | 446 total_min_(0), |
| 434 total_initial_size_(0), | 447 total_initial_size_(0), |
| 435 snap_type_(SNAP_NONE), | 448 snap_type_(SNAP_NONE), |
| 449 dock_edge_(DOCK_EDGE_NONE), | |
| 436 num_mouse_moves_since_bounds_change_(0), | 450 num_mouse_moves_since_bounds_change_(0), |
| 437 magnetism_window_(NULL) { | 451 magnetism_window_(NULL) { |
| 438 DCHECK(details_.is_resizable); | 452 DCHECK(details_.is_resizable); |
| 439 | 453 |
| 440 Shell* shell = Shell::GetInstance(); | 454 Shell* shell = Shell::GetInstance(); |
| 441 shell->cursor_manager()->LockCursor(); | 455 shell->cursor_manager()->LockCursor(); |
| 442 | 456 |
| 443 // Only support attaching to the right/bottom. | 457 // Only support attaching to the right/bottom. |
| 444 DCHECK(attached_windows_.empty() || | 458 DCHECK(attached_windows_.empty() || |
| 445 (details.window_component == HTRIGHT || | 459 (details.window_component == HTRIGHT || |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 bounds->set_y(max_y); | 690 bounds->set_y(max_y); |
| 677 } else if (bounds->y() <= work_area.y()) { | 691 } else if (bounds->y() <= work_area.y()) { |
| 678 // Don't allow dragging above the top of the display until the mouse | 692 // Don't allow dragging above the top of the display until the mouse |
| 679 // cursor reaches the work area above if any. | 693 // cursor reaches the work area above if any. |
| 680 bounds->set_y(work_area.y()); | 694 bounds->set_y(work_area.y()); |
| 681 } | 695 } |
| 682 | 696 |
| 683 if (sticky_size > 0) { | 697 if (sticky_size > 0) { |
| 684 StickToWorkAreaOnMove(work_area, sticky_size, bounds); | 698 StickToWorkAreaOnMove(work_area, sticky_size, bounds); |
| 685 MagneticallySnapToOtherWindows(bounds); | 699 MagneticallySnapToOtherWindows(bounds); |
| 700 dock_edge_ = DockLayoutManager::FindDockEdge(window()); | |
|
flackr
2013/06/04 20:58:03
As discussed, you shouldn't need to track this sin
varkha
2013/06/07 19:01:28
Done.
| |
| 686 } | 701 } |
| 687 } else if (sticky_size > 0) { | 702 } else if (sticky_size > 0) { |
| 688 MagneticallySnapResizeToOtherWindows(bounds); | 703 MagneticallySnapResizeToOtherWindows(bounds); |
| 689 if (!magnetism_window_ && sticky_size > 0) | 704 if (!magnetism_window_ && sticky_size > 0) |
| 690 StickToWorkAreaOnResize(work_area, sticky_size, bounds); | 705 StickToWorkAreaOnResize(work_area, sticky_size, bounds); |
| 691 } | 706 } |
| 692 | 707 |
| 693 if (attached_windows_.empty()) | 708 if (attached_windows_.empty()) |
| 694 return; | 709 return; |
| 695 | 710 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); | 859 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); |
| 845 if (location.x() <= area.x()) | 860 if (location.x() <= area.x()) |
| 846 return SNAP_LEFT_EDGE; | 861 return SNAP_LEFT_EDGE; |
| 847 if (location.x() >= area.right() - 1) | 862 if (location.x() >= area.right() - 1) |
| 848 return SNAP_RIGHT_EDGE; | 863 return SNAP_RIGHT_EDGE; |
| 849 return SNAP_NONE; | 864 return SNAP_NONE; |
| 850 } | 865 } |
| 851 | 866 |
| 852 } // namespace internal | 867 } // namespace internal |
| 853 } // namespace ash | 868 } // namespace ash |
| OLD | NEW |