| 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/drag_window_controller.h" | 5 #include "ash/wm/drag_window_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/display/window_tree_host_manager.h" | 9 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/screen_util.h" | |
| 12 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 13 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 14 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
| 17 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 21 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 22 #include "ui/compositor/layer_tree_owner.h" | 21 #include "ui/compositor/layer_tree_owner.h" |
| 23 #include "ui/compositor/paint_context.h" | 22 #include "ui/compositor/paint_context.h" |
| 24 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 25 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| 26 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 26 #include "ui/wm/core/coordinate_conversion.h" |
| 27 #include "ui/wm/core/shadow_types.h" | 27 #include "ui/wm/core/shadow_types.h" |
| 28 #include "ui/wm/core/window_util.h" | 28 #include "ui/wm/core/window_util.h" |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 | 31 |
| 32 // This keeps track of the drag window's state. It creates/destroys/updates | 32 // This keeps track of the drag window's state. It creates/destroys/updates |
| 33 // bounds and opacity based on the current bounds. | 33 // bounds and opacity based on the current bounds. |
| 34 class DragWindowController::DragWindowDetails : public aura::WindowDelegate { | 34 class DragWindowController::DragWindowDetails : public aura::WindowDelegate { |
| 35 public: | 35 public: |
| 36 DragWindowDetails(const display::Display& display, | 36 DragWindowDetails(const display::Display& display, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 delete drag_window_; | 52 delete drag_window_; |
| 53 // Make sure drag_window_ is reset so that new drag window will be created | 53 // Make sure drag_window_ is reset so that new drag window will be created |
| 54 // when it becomes necessary again. | 54 // when it becomes necessary again. |
| 55 DCHECK(!drag_window_); | 55 DCHECK(!drag_window_); |
| 56 layer_owner_.reset(); | 56 layer_owner_.reset(); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 if (!drag_window_) | 59 if (!drag_window_) |
| 60 CreateDragWindow(original_window, bounds_in_screen); | 60 CreateDragWindow(original_window, bounds_in_screen); |
| 61 | 61 |
| 62 gfx::Rect bounds_in_root = ScreenUtil::ConvertRectFromScreen( | 62 gfx::Rect bounds_in_root = bounds_in_screen; |
| 63 drag_window_->parent(), bounds_in_screen); | 63 ::wm::ConvertRectFromScreen(drag_window_->parent(), &bounds_in_root); |
| 64 drag_window_->SetBounds(bounds_in_root); | 64 drag_window_->SetBounds(bounds_in_root); |
| 65 if (root_bounds_in_screen.Contains(drag_location_in_screen)) { | 65 if (root_bounds_in_screen.Contains(drag_location_in_screen)) { |
| 66 SetOpacity(original_window, 1.f); | 66 SetOpacity(original_window, 1.f); |
| 67 } else { | 67 } else { |
| 68 drag_window_->SetBounds(bounds_in_root); | 68 drag_window_->SetBounds(bounds_in_root); |
| 69 gfx::Rect visible_bounds = root_bounds_in_screen; | 69 gfx::Rect visible_bounds = root_bounds_in_screen; |
| 70 visible_bounds.Intersect(bounds_in_screen); | 70 visible_bounds.Intersect(bounds_in_screen); |
| 71 SetOpacity(original_window, | 71 SetOpacity(original_window, |
| 72 GetDragWindowOpacity(bounds_in_screen, visible_bounds)); | 72 GetDragWindowOpacity(bounds_in_screen, visible_bounds)); |
| 73 } | 73 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 layers.pop_back(); | 243 layers.pop_back(); |
| 244 if (layer->delegate()) | 244 if (layer->delegate()) |
| 245 layer->delegate()->OnPaintLayer(context); | 245 layer->delegate()->OnPaintLayer(context); |
| 246 for (auto* child : layer->children()) | 246 for (auto* child : layer->children()) |
| 247 layers.push_back(child); | 247 layers.push_back(child); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace ash | 252 } // namespace ash |
| OLD | NEW |