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/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/resize_shadow_controller.h" | 8 #include "ash/wm/resize_shadow_controller.h" |
| 9 #include "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 if (window_resizer_.get() && !in_gesture_drag_) | 177 if (window_resizer_.get() && !in_gesture_drag_) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 if (window_resizer_.get() && | 180 if (window_resizer_.get() && |
| 181 window_resizer_->resizer()->GetTarget() != target) { | 181 window_resizer_->resizer()->GetTarget() != target) { |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 | 184 |
| 185 switch (event->type()) { | 185 switch (event->type()) { |
| 186 case ui::ET_GESTURE_TAP_DOWN: { | 186 case ui::ET_GESTURE_TAP_DOWN: { |
| 187 if (event->handled()) | |
| 188 return; | |
| 187 int component = | 189 int component = |
| 188 target->delegate()->GetNonClientComponent(event->location()); | 190 target->delegate()->GetNonClientComponent(event->location()); |
| 189 if (!(WindowResizer::GetBoundsChangeForWindowComponent(component) & | 191 if (!(WindowResizer::GetBoundsChangeForWindowComponent(component) & |
| 190 WindowResizer::kBoundsChange_Resizes)) | 192 WindowResizer::kBoundsChange_Resizes)) |
| 191 return; | 193 return; |
| 192 internal::ResizeShadowController* controller = | 194 internal::ResizeShadowController* controller = |
| 193 Shell::GetInstance()->resize_shadow_controller(); | 195 Shell::GetInstance()->resize_shadow_controller(); |
| 194 if (controller) | 196 if (controller) |
| 195 controller->ShowShadow(target, component); | 197 controller->ShowShadow(target, component); |
| 196 return; | 198 return; |
| 197 } | 199 } |
| 198 case ui::ET_GESTURE_END: { | 200 case ui::ET_GESTURE_END: { |
| 199 internal::ResizeShadowController* controller = | 201 internal::ResizeShadowController* controller = |
| 200 Shell::GetInstance()->resize_shadow_controller(); | 202 Shell::GetInstance()->resize_shadow_controller(); |
| 201 if (controller) | 203 if (controller) |
| 202 controller->HideShadow(target); | 204 controller->HideShadow(target); |
| 203 return; | 205 return; |
| 204 } | 206 } |
| 205 case ui::ET_GESTURE_SCROLL_BEGIN: { | 207 case ui::ET_GESTURE_SCROLL_BEGIN: { |
| 206 if (in_gesture_drag_) | 208 if (in_gesture_drag_ || event->handled()) |
| 207 return; | 209 return; |
| 208 int component = | 210 int component = |
| 209 target->delegate()->GetNonClientComponent(event->location()); | 211 target->delegate()->GetNonClientComponent(event->location()); |
| 210 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) | 212 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) |
| 211 return; | 213 return; |
| 212 gfx::Point location_in_parent( | 214 gfx::Point location_in_parent( |
| 213 ConvertPointToParent(target, event->location())); | 215 ConvertPointToParent(target, event->location())); |
| 214 AttemptToStartDrag(target, location_in_parent, component, | 216 AttemptToStartDrag(target, location_in_parent, component, |
| 215 aura::client::WINDOW_MOVE_SOURCE_TOUCH); | 217 aura::client::WINDOW_MOVE_SOURCE_TOUCH); |
| 216 event->StopPropagation(); | 218 event->StopPropagation(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 drag_reverted_ = (status == DRAG_REVERT); | 347 drag_reverted_ = (status == DRAG_REVERT); |
| 346 | 348 |
| 347 in_gesture_drag_ = false; | 349 in_gesture_drag_ = false; |
| 348 if (in_move_loop_) | 350 if (in_move_loop_) |
| 349 quit_closure_.Run(); | 351 quit_closure_.Run(); |
| 350 } | 352 } |
| 351 | 353 |
| 352 void ToplevelWindowEventHandler::HandleMousePressed( | 354 void ToplevelWindowEventHandler::HandleMousePressed( |
| 353 aura::Window* target, | 355 aura::Window* target, |
| 354 ui::MouseEvent* event) { | 356 ui::MouseEvent* event) { |
| 355 if (event->phase() != ui::EP_PRETARGET) | 357 if (event->phase() != ui::EP_PRETARGET || event->handled()) |
| 356 return; | 358 return; |
| 357 | 359 |
| 358 // We also update the current window component here because for the | 360 // We also update the current window component here because for the |
| 359 // mouse-drag-release-press case, where the mouse is released and | 361 // mouse-drag-release-press case, where the mouse is released and |
| 360 // pressed without mouse move event. | 362 // pressed without mouse move event. |
| 361 int component = | 363 int component = |
| 362 target->delegate()->GetNonClientComponent(event->location()); | 364 target->delegate()->GetNonClientComponent(event->location()); |
| 363 if ((event->flags() & | 365 if ((event->flags() & |
| 364 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && | 366 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && |
| 365 WindowResizer::GetBoundsChangeForWindowComponent(component)) { | 367 WindowResizer::GetBoundsChangeForWindowComponent(component)) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 379 if (event->phase() != ui::EP_PRETARGET) | 381 if (event->phase() != ui::EP_PRETARGET) |
| 380 return; | 382 return; |
| 381 | 383 |
| 382 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? | 384 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? |
| 383 DRAG_COMPLETE : DRAG_REVERT); | 385 DRAG_COMPLETE : DRAG_REVERT); |
| 384 // Completing the drag may result in hiding the window. If this happens | 386 // Completing the drag may result in hiding the window. If this happens |
| 385 // return true so no other handlers/observers see the event. Otherwise | 387 // return true so no other handlers/observers see the event. Otherwise |
| 386 // they see the event on a hidden window. | 388 // they see the event on a hidden window. |
| 387 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && | 389 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && |
| 388 !target->IsVisible()) { | 390 !target->IsVisible()) { |
| 389 event->StopPropagation(); | 391 event->StopPropagation(); |
|
pkotwicz
2014/01/21 22:22:39
Can you do me a favor and only call StopPropagatio
flackr
2014/01/29 15:27:32
Done.
| |
| 390 } | 392 } |
| 391 } | 393 } |
| 392 | 394 |
| 393 void ToplevelWindowEventHandler::HandleDrag( | 395 void ToplevelWindowEventHandler::HandleDrag( |
| 394 aura::Window* target, | 396 aura::Window* target, |
| 395 ui::LocatedEvent* event) { | 397 ui::LocatedEvent* event) { |
| 396 // This function only be triggered to move window | 398 // This function only be triggered to move window |
| 397 // by mouse drag or touch move event. | 399 // by mouse drag or touch move event. |
| 398 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || | 400 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || |
| 399 event->type() == ui::ET_TOUCH_MOVED || | 401 event->type() == ui::ET_TOUCH_MOVED || |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 | 491 |
| 490 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { | 492 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { |
| 491 // We explicitly don't invoke RevertDrag() since that may do things to window. | 493 // We explicitly don't invoke RevertDrag() since that may do things to window. |
| 492 // Instead we destroy the resizer. | 494 // Instead we destroy the resizer. |
| 493 window_resizer_.reset(); | 495 window_resizer_.reset(); |
| 494 | 496 |
| 495 CompleteDrag(DRAG_REVERT); | 497 CompleteDrag(DRAG_REVERT); |
| 496 } | 498 } |
| 497 | 499 |
| 498 } // namespace ash | 500 } // namespace ash |
| OLD | NEW |