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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && | 476 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && |
| 477 WindowResizer::GetBoundsChangeForWindowComponent(component)) { | 477 WindowResizer::GetBoundsChangeForWindowComponent(component)) { |
| 478 gfx::Point location_in_parent( | 478 gfx::Point location_in_parent( |
| 479 ConvertPointToParent(target, event->location())); | 479 ConvertPointToParent(target, event->location())); |
| 480 AttemptToStartDrag(target, location_in_parent, component, | 480 AttemptToStartDrag(target, location_in_parent, component, |
| 481 aura::client::WINDOW_MOVE_SOURCE_MOUSE); | 481 aura::client::WINDOW_MOVE_SOURCE_MOUSE); |
| 482 // Set as handled so that other event handlers do no act upon the event | 482 // Set as handled so that other event handlers do no act upon the event |
| 483 // but still receive it so that they receive both parts of each pressed/ | 483 // but still receive it so that they receive both parts of each pressed/ |
| 484 // released pair. | 484 // released pair. |
| 485 event->SetHandled(); | 485 event->SetHandled(); |
| 486 } else { | 486 } else { |
|
pkotwicz
2014/06/29 16:00:40
We should also avoid calling CompleteDrag() here i
oshima
2014/07/01 17:52:01
Why another CL? Don't we want to fix them all and
pkotwicz
2014/07/04 14:28:41
I wanted to keep the CL to be merged as small as p
| |
| 487 CompleteDrag(DRAG_COMPLETE); | 487 CompleteDrag(DRAG_COMPLETE); |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 void ToplevelWindowEventHandler::HandleMouseReleased( | 491 void ToplevelWindowEventHandler::HandleMouseReleased( |
| 492 aura::Window* target, | 492 aura::Window* target, |
| 493 ui::MouseEvent* event) { | 493 ui::MouseEvent* event) { |
| 494 if (event->phase() != ui::EP_PRETARGET) | 494 if (event->phase() != ui::EP_PRETARGET) |
| 495 return; | 495 return; |
| 496 | 496 |
| 497 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? | 497 if (window_resizer_) { |
|
pkotwicz
2014/06/28 18:37:36
We should also avoid calling CompleteDrag() here i
varkha
2014/07/04 23:09:01
Should this method just return early when !window_
| |
| 498 DRAG_COMPLETE : DRAG_REVERT); | 498 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? |
| 499 DRAG_COMPLETE : DRAG_REVERT); | |
| 500 } | |
| 501 | |
| 499 // Completing the drag may result in hiding the window. If this happens | 502 // Completing the drag may result in hiding the window. If this happens |
| 500 // mark the event as handled so no other handlers/observers act upon the | 503 // mark the event as handled so no other handlers/observers act upon the |
| 501 // event. They should see the event on a hidden window, to determine targets | 504 // event. They should see the event on a hidden window, to determine targets |
| 502 // of destructive actions such as hiding. They should not act upon them. | 505 // of destructive actions such as hiding. They should not act upon them. |
| 503 if (window_resizer_ && | 506 if (window_resizer_ && |
| 504 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && | 507 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && |
| 505 !target->IsVisible()) { | 508 !target->IsVisible()) { |
|
pkotwicz
2014/06/28 18:37:36
This code never gets run. (That's as a result of a
| |
| 506 event->SetHandled(); | 509 event->SetHandled(); |
| 507 } | 510 } |
| 508 } | 511 } |
| 509 | 512 |
| 510 void ToplevelWindowEventHandler::HandleDrag( | 513 void ToplevelWindowEventHandler::HandleDrag( |
| 511 aura::Window* target, | 514 aura::Window* target, |
| 512 ui::LocatedEvent* event) { | 515 ui::LocatedEvent* event) { |
| 513 // This function only be triggered to move window | 516 // This function only be triggered to move window |
| 514 // by mouse drag or touch move event. | 517 // by mouse drag or touch move event. |
| 515 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || | 518 DCHECK(event->type() == ui::ET_MOUSE_DRAGGED || |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 | 612 |
| 610 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { | 613 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { |
| 611 // We explicitly don't invoke RevertDrag() since that may do things to window. | 614 // We explicitly don't invoke RevertDrag() since that may do things to window. |
| 612 // Instead we destroy the resizer. | 615 // Instead we destroy the resizer. |
| 613 window_resizer_.reset(); | 616 window_resizer_.reset(); |
| 614 | 617 |
| 615 CompleteDrag(DRAG_REVERT); | 618 CompleteDrag(DRAG_REVERT); |
| 616 } | 619 } |
| 617 | 620 |
| 618 } // namespace ash | 621 } // namespace ash |
| OLD | NEW |