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/toplevel_window_event_handler.h" | 5 #include "ash/wm/toplevel_window_event_handler.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/property_util.h" | 8 #include "ash/wm/property_util.h" |
9 #include "ash/wm/resize_shadow_controller.h" | 9 #include "ash/wm/resize_shadow_controller.h" |
10 #include "ash/wm/window_properties.h" | 10 #include "ash/wm/window_properties.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 class ToplevelWindowEventHandler::ScopedWindowResizer | 56 class ToplevelWindowEventHandler::ScopedWindowResizer |
57 : public aura::WindowObserver { | 57 : public aura::WindowObserver { |
58 public: | 58 public: |
59 ScopedWindowResizer(ToplevelWindowEventHandler* handler, | 59 ScopedWindowResizer(ToplevelWindowEventHandler* handler, |
60 WindowResizer* resizer); | 60 WindowResizer* resizer); |
61 virtual ~ScopedWindowResizer(); | 61 virtual ~ScopedWindowResizer(); |
62 | 62 |
63 WindowResizer* resizer() { return resizer_.get(); } | 63 WindowResizer* resizer() { return resizer_.get(); } |
64 | 64 |
65 // WindowObserver overrides: | 65 // WindowObserver overrides: |
66 virtual void OnWindowHierarchyChanging( | 66 virtual void OnWindowHierarchyChanged( |
varkha
2013/06/20 04:09:22
PTAL. I think this is a cleaner solution. This avo
flackr
2013/06/20 13:08:45
I had assumed this wouldn't work. When the window
| |
67 const HierarchyChangeParams& params) OVERRIDE; | 67 const HierarchyChangeParams& params) OVERRIDE; |
68 virtual void OnWindowPropertyChanged(aura::Window* window, | 68 virtual void OnWindowPropertyChanged(aura::Window* window, |
69 const void* key, | 69 const void* key, |
70 intptr_t old) OVERRIDE; | 70 intptr_t old) OVERRIDE; |
71 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 71 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
72 | 72 |
73 private: | 73 private: |
74 void AddHandlers(aura::Window* container); | 74 void AddHandlers(aura::Window* container); |
75 void RemoveHandlers(); | 75 void RemoveHandlers(); |
76 | 76 |
(...skipping 16 matching lines...) Expand all Loading... | |
93 if (resizer_) | 93 if (resizer_) |
94 resizer_->GetTarget()->AddObserver(this); | 94 resizer_->GetTarget()->AddObserver(this); |
95 } | 95 } |
96 | 96 |
97 ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() { | 97 ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() { |
98 RemoveHandlers(); | 98 RemoveHandlers(); |
99 if (resizer_) | 99 if (resizer_) |
100 resizer_->GetTarget()->RemoveObserver(this); | 100 resizer_->GetTarget()->RemoveObserver(this); |
101 } | 101 } |
102 | 102 |
103 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanging( | 103 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanged( |
104 const HierarchyChangeParams& params) { | 104 const HierarchyChangeParams& params) { |
105 if (params.receiver != resizer_->GetTarget()) | 105 if (params.receiver != resizer_->GetTarget()) |
106 return; | 106 return; |
107 | 107 |
108 if (params.receiver->GetProperty(internal::kContinueDragAfterReparent)) { | 108 if (params.receiver->GetProperty(internal::kContinueDragAfterReparent)) { |
109 params.receiver->SetProperty(internal::kContinueDragAfterReparent, false); | 109 params.receiver->SetProperty(internal::kContinueDragAfterReparent, false); |
110 AddHandlers(params.new_parent); | 110 AddHandlers(params.new_parent); |
111 } else { | 111 } else { |
112 handler_->CompleteDrag(DRAG_COMPLETE, 0); | 112 handler_->CompleteDrag(DRAG_COMPLETE, 0); |
113 } | 113 } |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { | 504 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { |
505 // We explicitly don't invoke RevertDrag() since that may do things to window. | 505 // We explicitly don't invoke RevertDrag() since that may do things to window. |
506 // Instead we destroy the resizer. | 506 // Instead we destroy the resizer. |
507 window_resizer_.reset(); | 507 window_resizer_.reset(); |
508 | 508 |
509 // End the move loop. This does nothing if we're not in a move loop. | 509 // End the move loop. This does nothing if we're not in a move loop. |
510 EndMoveLoop(); | 510 EndMoveLoop(); |
511 } | 511 } |
512 | 512 |
513 } // namespace ash | 513 } // namespace ash |
OLD | NEW |