Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: ash/wm/toplevel_window_event_handler.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 gfx::Point ConvertPointToParent(aura::Window* window, 70 gfx::Point ConvertPointToParent(aura::Window* window,
71 const gfx::Point& point) { 71 const gfx::Point& point) {
72 gfx::Point result(point); 72 gfx::Point result(point);
73 aura::Window::ConvertPointToTarget(window, window->parent(), &result); 73 aura::Window::ConvertPointToTarget(window, window->parent(), &result);
74 return result; 74 return result;
75 } 75 }
76 76
77 // Returns the window component containing |event|'s location. 77 // Returns the window component containing |event|'s location.
78 int GetWindowComponent(aura::Window* window, const ui::LocatedEvent& event) { 78 int GetWindowComponent(aura::Window* window, const ui::LocatedEvent& event) {
79 return window->delegate()->GetNonClientComponent(event.location()); 79 return window->delegate()->GetNonClientComponent(
80 gfx::ToFlooredPoint(event.location()));
80 } 81 }
81 82
82 } // namespace 83 } // namespace
83 84
84 // ScopedWindowResizer --------------------------------------------------------- 85 // ScopedWindowResizer ---------------------------------------------------------
85 86
86 // Wraps a WindowResizer and installs an observer on its target window. When 87 // Wraps a WindowResizer and installs an observer on its target window. When
87 // the window is destroyed ResizerWindowDestroyed() is invoked back on the 88 // the window is destroyed ResizerWindowDestroyed() is invoked back on the
88 // ToplevelWindowEventHandler to clean up. 89 // ToplevelWindowEventHandler to clean up.
89 class ToplevelWindowEventHandler::ScopedWindowResizer 90 class ToplevelWindowEventHandler::ScopedWindowResizer
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // window jumping upon initiating a two finger drag. When a one finger 284 // window jumping upon initiating a two finger drag. When a one finger
284 // drag is converted to a two finger drag, a jump occurs because the 285 // drag is converted to a two finger drag, a jump occurs because the
285 // location of the ET_GESTURE_SCROLL_UPDATE event switches from the single 286 // location of the ET_GESTURE_SCROLL_UPDATE event switches from the single
286 // finger's position to the position in the middle of the two fingers. 287 // finger's position to the position in the middle of the two fingers.
287 if (window_resizer_.get()) 288 if (window_resizer_.get())
288 return; 289 return;
289 int component = GetWindowComponent(target, *event); 290 int component = GetWindowComponent(target, *event);
290 if (!CanStartOneFingerDrag(component)) 291 if (!CanStartOneFingerDrag(component))
291 return; 292 return;
292 gfx::Point location_in_parent( 293 gfx::Point location_in_parent(
293 ConvertPointToParent(target, event->location())); 294 ConvertPointToParent(target, gfx::ToFlooredPoint(event->location())));
294 AttemptToStartDrag(target, location_in_parent, component, 295 AttemptToStartDrag(target, location_in_parent, component,
295 aura::client::WINDOW_MOVE_SOURCE_TOUCH); 296 aura::client::WINDOW_MOVE_SOURCE_TOUCH);
296 event->StopPropagation(); 297 event->StopPropagation();
297 return; 298 return;
298 } 299 }
299 default: 300 default:
300 break; 301 break;
301 } 302 }
302 303
303 if (!window_resizer_.get()) 304 if (!window_resizer_.get())
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 return; 467 return;
467 468
468 // We also update the current window component here because for the 469 // We also update the current window component here because for the
469 // mouse-drag-release-press case, where the mouse is released and 470 // mouse-drag-release-press case, where the mouse is released and
470 // pressed without mouse move event. 471 // pressed without mouse move event.
471 int component = GetWindowComponent(target, *event); 472 int component = GetWindowComponent(target, *event);
472 if ((event->flags() & 473 if ((event->flags() &
473 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 && 474 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 &&
474 WindowResizer::GetBoundsChangeForWindowComponent(component)) { 475 WindowResizer::GetBoundsChangeForWindowComponent(component)) {
475 gfx::Point location_in_parent( 476 gfx::Point location_in_parent(
476 ConvertPointToParent(target, event->location())); 477 ConvertPointToParent(target, gfx::ToFlooredPoint(event->location())));
477 AttemptToStartDrag(target, location_in_parent, component, 478 AttemptToStartDrag(target, location_in_parent, component,
478 aura::client::WINDOW_MOVE_SOURCE_MOUSE); 479 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
479 // Set as handled so that other event handlers do no act upon the event 480 // 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 // but still receive it so that they receive both parts of each pressed/
481 // released pair. 482 // released pair.
482 event->SetHandled(); 483 event->SetHandled();
483 } else { 484 } else {
484 CompleteDrag(DRAG_COMPLETE); 485 CompleteDrag(DRAG_COMPLETE);
485 } 486 }
486 } 487 }
(...skipping 27 matching lines...) Expand all
514 event->type() == ui::ET_GESTURE_SCROLL_UPDATE); 515 event->type() == ui::ET_GESTURE_SCROLL_UPDATE);
515 516
516 // Drag actions are performed pre-target handling to prevent spurious mouse 517 // Drag actions are performed pre-target handling to prevent spurious mouse
517 // moves from the move/size operation from being sent to the target. 518 // moves from the move/size operation from being sent to the target.
518 if (event->phase() != ui::EP_PRETARGET) 519 if (event->phase() != ui::EP_PRETARGET)
519 return; 520 return;
520 521
521 if (!window_resizer_) 522 if (!window_resizer_)
522 return; 523 return;
523 window_resizer_->resizer()->Drag( 524 window_resizer_->resizer()->Drag(
524 ConvertPointToParent(target, event->location()), event->flags()); 525 ConvertPointToParent(target, gfx::ToFlooredPoint(event->location())),
526 event->flags());
525 event->StopPropagation(); 527 event->StopPropagation();
526 } 528 }
527 529
528 void ToplevelWindowEventHandler::HandleMouseMoved( 530 void ToplevelWindowEventHandler::HandleMouseMoved(
529 aura::Window* target, 531 aura::Window* target,
530 ui::LocatedEvent* event) { 532 ui::LocatedEvent* event) {
531 // Shadow effects are applied after target handling. Note that we don't 533 // Shadow effects are applied after target handling. Note that we don't
532 // respect ER_HANDLED here right now since we have not had a reason to allow 534 // respect ER_HANDLED here right now since we have not had a reason to allow
533 // the target to cancel shadow rendering. 535 // the target to cancel shadow rendering.
534 if (event->phase() != ui::EP_POSTTARGET || !target->delegate()) 536 if (event->phase() != ui::EP_POSTTARGET || !target->delegate())
535 return; 537 return;
536 538
537 // TODO(jamescook): Move the resize cursor update code into here from 539 // TODO(jamescook): Move the resize cursor update code into here from
538 // CompoundEventFilter? 540 // CompoundEventFilter?
539 ResizeShadowController* controller = 541 ResizeShadowController* controller =
540 Shell::GetInstance()->resize_shadow_controller(); 542 Shell::GetInstance()->resize_shadow_controller();
541 if (controller) { 543 if (controller) {
542 if (event->flags() & ui::EF_IS_NON_CLIENT) { 544 if (event->flags() & ui::EF_IS_NON_CLIENT) {
543 int component = 545 int component = target->delegate()->GetNonClientComponent(
544 target->delegate()->GetNonClientComponent(event->location()); 546 gfx::ToFlooredPoint(event->location()));
545 controller->ShowShadow(target, component); 547 controller->ShowShadow(target, component);
546 } else { 548 } else {
547 controller->HideShadow(target); 549 controller->HideShadow(target);
548 } 550 }
549 } 551 }
550 } 552 }
551 553
552 void ToplevelWindowEventHandler::HandleMouseExited( 554 void ToplevelWindowEventHandler::HandleMouseExited(
553 aura::Window* target, 555 aura::Window* target,
554 ui::LocatedEvent* event) { 556 ui::LocatedEvent* event) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 608
607 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 609 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
608 // We explicitly don't invoke RevertDrag() since that may do things to window. 610 // We explicitly don't invoke RevertDrag() since that may do things to window.
609 // Instead we destroy the resizer. 611 // Instead we destroy the resizer.
610 window_resizer_.reset(); 612 window_resizer_.reset();
611 613
612 CompleteDrag(DRAG_REVERT); 614 CompleteDrag(DRAG_REVERT);
613 } 615 }
614 616
615 } // namespace ash 617 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698