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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 // mouse-drag-release-press case, where the mouse is released and | 469 // mouse-drag-release-press case, where the mouse is released and |
470 // pressed without mouse move event. | 470 // pressed without mouse move event. |
471 int component = GetWindowComponent(target, *event); | 471 int component = GetWindowComponent(target, *event); |
472 if ((event->flags() & | 472 if ((event->flags() & |
473 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && | 473 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && |
474 WindowResizer::GetBoundsChangeForWindowComponent(component)) { | 474 WindowResizer::GetBoundsChangeForWindowComponent(component)) { |
475 gfx::Point location_in_parent( | 475 gfx::Point location_in_parent( |
476 ConvertPointToParent(target, event->location())); | 476 ConvertPointToParent(target, event->location())); |
477 AttemptToStartDrag(target, location_in_parent, component, | 477 AttemptToStartDrag(target, location_in_parent, component, |
478 aura::client::WINDOW_MOVE_SOURCE_MOUSE); | 478 aura::client::WINDOW_MOVE_SOURCE_MOUSE); |
479 event->StopPropagation(); | 479 // Set as handled so that other event handlers do no act upon the event |
| 480 // but still receive it so that they receive both parts of each pressed/ |
| 481 // released pair. |
| 482 event->SetHandled(); |
480 } else { | 483 } else { |
481 CompleteDrag(DRAG_COMPLETE); | 484 CompleteDrag(DRAG_COMPLETE); |
482 } | 485 } |
483 } | 486 } |
484 | 487 |
485 void ToplevelWindowEventHandler::HandleMouseReleased( | 488 void ToplevelWindowEventHandler::HandleMouseReleased( |
486 aura::Window* target, | 489 aura::Window* target, |
487 ui::MouseEvent* event) { | 490 ui::MouseEvent* event) { |
488 if (event->phase() != ui::EP_PRETARGET) | 491 if (event->phase() != ui::EP_PRETARGET) |
489 return; | 492 return; |
490 | 493 |
491 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? | 494 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? |
492 DRAG_COMPLETE : DRAG_REVERT); | 495 DRAG_COMPLETE : DRAG_REVERT); |
493 // Completing the drag may result in hiding the window. If this happens | 496 // Completing the drag may result in hiding the window. If this happens |
494 // return true so no other handlers/observers see the event. Otherwise | 497 // mark the event as handled so no other handlers/observers act upon the |
495 // they see the event on a hidden window. | 498 // event. They should see the event on a hidden window, to determine targets |
| 499 // of destructive actions such as hiding. They should not act upon them. |
496 if (window_resizer_ && | 500 if (window_resizer_ && |
497 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && | 501 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && |
498 !target->IsVisible()) { | 502 !target->IsVisible()) { |
499 event->StopPropagation(); | 503 event->SetHandled(); |
500 } | 504 } |
501 } | 505 } |
502 | 506 |
503 void ToplevelWindowEventHandler::HandleDrag( | 507 void ToplevelWindowEventHandler::HandleDrag( |
504 aura::Window* target, | 508 aura::Window* target, |
505 ui::LocatedEvent* event) { | 509 ui::LocatedEvent* event) { |
506 // This function only be triggered to move window | 510 // This function only be triggered to move window |
507 // by mouse drag or touch move event. | 511 // by mouse drag or touch move event. |
508 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || | 512 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || |
509 event->type() == ui::ET_TOUCH_MOVED || | 513 event->type() == ui::ET_TOUCH_MOVED || |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 606 |
603 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { | 607 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { |
604 // We explicitly don't invoke RevertDrag() since that may do things to window. | 608 // We explicitly don't invoke RevertDrag() since that may do things to window. |
605 // Instead we destroy the resizer. | 609 // Instead we destroy the resizer. |
606 window_resizer_.reset(); | 610 window_resizer_.reset(); |
607 | 611 |
608 CompleteDrag(DRAG_REVERT); | 612 CompleteDrag(DRAG_REVERT); |
609 } | 613 } |
610 | 614 |
611 } // namespace ash | 615 } // namespace ash |
OLD | NEW |