| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/common/wm/drag_details.h" | |
| 6 | |
| 7 #include "ash/common/wm/window_resizer.h" | |
| 8 #include "ash/common/wm_window.h" | |
| 9 #include "ash/public/cpp/window_properties.h" | |
| 10 #include "ui/aura/window.h" | |
| 11 #include "ui/base/hit_test.h" | |
| 12 #include "ui/compositor/layer.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 int GetSizeChangeDirectionForWindowComponent(int window_component) { | |
| 19 int size_change_direction = WindowResizer::kBoundsChangeDirection_None; | |
| 20 switch (window_component) { | |
| 21 case HTTOPLEFT: | |
| 22 case HTTOPRIGHT: | |
| 23 case HTBOTTOMLEFT: | |
| 24 case HTBOTTOMRIGHT: | |
| 25 case HTGROWBOX: | |
| 26 case HTCAPTION: | |
| 27 size_change_direction |= | |
| 28 WindowResizer::kBoundsChangeDirection_Horizontal | | |
| 29 WindowResizer::kBoundsChangeDirection_Vertical; | |
| 30 break; | |
| 31 case HTTOP: | |
| 32 case HTBOTTOM: | |
| 33 size_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical; | |
| 34 break; | |
| 35 case HTRIGHT: | |
| 36 case HTLEFT: | |
| 37 size_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal; | |
| 38 break; | |
| 39 default: | |
| 40 break; | |
| 41 } | |
| 42 return size_change_direction; | |
| 43 } | |
| 44 | |
| 45 } // namespace | |
| 46 | |
| 47 DragDetails::DragDetails(WmWindow* window, | |
| 48 const gfx::Point& location, | |
| 49 int window_component, | |
| 50 aura::client::WindowMoveSource source) | |
| 51 : initial_state_type(window->GetWindowState()->GetStateType()), | |
| 52 initial_bounds_in_parent(window->GetBounds()), | |
| 53 initial_location_in_parent(location), | |
| 54 // When drag starts, we might be in the middle of a window opacity | |
| 55 // animation, on drag completion we must set the opacity to the target | |
| 56 // opacity rather than the current opacity (crbug.com/687003). | |
| 57 initial_opacity(window->GetLayer()->GetTargetOpacity()), | |
| 58 window_component(window_component), | |
| 59 bounds_change( | |
| 60 WindowResizer::GetBoundsChangeForWindowComponent(window_component)), | |
| 61 position_change_direction( | |
| 62 WindowResizer::GetPositionChangeDirectionForWindowComponent( | |
| 63 window_component)), | |
| 64 size_change_direction( | |
| 65 GetSizeChangeDirectionForWindowComponent(window_component)), | |
| 66 is_resizable(bounds_change != WindowResizer::kBoundsChangeDirection_None), | |
| 67 source(source), | |
| 68 should_attach_to_shelf( | |
| 69 window->GetType() == ui::wm::WINDOW_TYPE_PANEL && | |
| 70 window->aura_window()->GetProperty(kPanelAttachedKey)) { | |
| 71 wm::WindowState* window_state = window->GetWindowState(); | |
| 72 if ((window_state->IsNormalOrSnapped() || window_state->IsDocked()) && | |
| 73 window_state->HasRestoreBounds() && window_component == HTCAPTION) { | |
| 74 restore_bounds = window_state->GetRestoreBoundsInScreen(); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 DragDetails::~DragDetails() {} | |
| 79 | |
| 80 } // namespace ash | |
| OLD | NEW |