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