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

Side by Side Diff: ash/frame/caption_buttons/frame_maximize_button.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame/caption_buttons/frame_maximize_button.h" 5 #include "ash/frame/caption_buttons/frame_maximize_button.h"
6 6
7 #include "ash/frame/caption_buttons/frame_maximize_button_observer.h" 7 #include "ash/frame/caption_buttons/frame_maximize_button_observer.h"
8 #include "ash/frame/caption_buttons/maximize_bubble_controller.h" 8 #include "ash/frame/caption_buttons/maximize_bubble_controller.h"
9 #include "ash/metrics/user_metrics_recorder.h" 9 #include "ash/metrics/user_metrics_recorder.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 if (event->type() == ui::ET_GESTURE_TAP || 273 if (event->type() == ui::ET_GESTURE_TAP ||
274 (event->type() == ui::ET_GESTURE_SCROLL_END && is_snap_enabled_) || 274 (event->type() == ui::ET_GESTURE_SCROLL_END && is_snap_enabled_) ||
275 event->type() == ui::ET_SCROLL_FLING_START) { 275 event->type() == ui::ET_SCROLL_FLING_START) {
276 // The position of the event may have changed from the previous event (both 276 // The position of the event may have changed from the previous event (both
277 // for TAP and SCROLL_END). So it is necessary to update the snap-state for 277 // for TAP and SCROLL_END). So it is necessary to update the snap-state for
278 // the current event. 278 // the current event.
279 ProcessUpdateEvent(*event); 279 ProcessUpdateEvent(*event);
280 if (event->type() == ui::ET_GESTURE_TAP) { 280 if (event->type() == ui::ET_GESTURE_TAP) {
281 snap_type_ = SnapTypeForLocation(event->location()); 281 snap_type_ = SnapTypeForLocation(gfx::ToFlooredPoint(event->location()));
282 TouchUMA::GetInstance()->RecordGestureAction( 282 TouchUMA::GetInstance()->RecordGestureAction(
283 TouchUMA::GESTURE_FRAMEMAXIMIZE_TAP); 283 TouchUMA::GESTURE_FRAMEMAXIMIZE_TAP);
284 } 284 }
285 ProcessEndEvent(*event); 285 ProcessEndEvent(*event);
286 event->SetHandled(); 286 event->SetHandled();
287 return; 287 return;
288 } 288 }
289 289
290 if (is_snap_enabled_) { 290 if (is_snap_enabled_) {
291 if (event->type() == ui::ET_GESTURE_END && 291 if (event->type() == ui::ET_GESTURE_END &&
292 event->details().touch_points() == 1) { 292 event->details().touch_points() == 1) {
293 // The position of the event may have changed from the previous event. So 293 // The position of the event may have changed from the previous event. So
294 // it is necessary to update the snap-state for the current event. 294 // it is necessary to update the snap-state for the current event.
295 ProcessUpdateEvent(*event); 295 ProcessUpdateEvent(*event);
296 snap_type_ = SnapTypeForLocation(event->location()); 296 snap_type_ = SnapTypeForLocation(gfx::ToFlooredPoint(event->location()));
297 ProcessEndEvent(*event); 297 ProcessEndEvent(*event);
298 event->SetHandled(); 298 event->SetHandled();
299 return; 299 return;
300 } 300 }
301 301
302 if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || 302 if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
303 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { 303 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
304 ProcessUpdateEvent(*event); 304 ProcessUpdateEvent(*event);
305 event->SetHandled(); 305 event->SetHandled();
306 return; 306 return;
(...skipping 14 matching lines...) Expand all
321 maximizer_.reset(new MaximizeBubbleController( 321 maximizer_.reset(new MaximizeBubbleController(
322 this, 322 this,
323 GetMaximizeBubbleFrameState(), 323 GetMaximizeBubbleFrameState(),
324 bubble_appearance_delay_ms_)); 324 bubble_appearance_delay_ms_));
325 } else { 325 } else {
326 // If the menu did not show up yet, we delay it even a bit more. 326 // If the menu did not show up yet, we delay it even a bit more.
327 maximizer_->DelayCreation(); 327 maximizer_->DelayCreation();
328 } 328 }
329 InstallEventFilter(); 329 InstallEventFilter();
330 snap_type_ = SNAP_NONE; 330 snap_type_ = SNAP_NONE;
331 press_location_ = event.location(); 331 press_location_ = gfx::ToFlooredPoint(event.location());
332 exceeded_drag_threshold_ = false; 332 exceeded_drag_threshold_ = false;
333 update_timer_.Start( 333 update_timer_.Start(
334 FROM_HERE, 334 FROM_HERE,
335 base::TimeDelta::FromMilliseconds(kUpdateDelayMS), 335 base::TimeDelta::FromMilliseconds(kUpdateDelayMS),
336 this, 336 this,
337 &FrameMaximizeButton::UpdateSnapFromEventLocation); 337 &FrameMaximizeButton::UpdateSnapFromEventLocation);
338 } 338 }
339 339
340 void FrameMaximizeButton::ProcessUpdateEvent(const ui::LocatedEvent& event) { 340 void FrameMaximizeButton::ProcessUpdateEvent(const ui::LocatedEvent& event) {
341 DCHECK(is_snap_enabled_); 341 DCHECK(is_snap_enabled_);
342 if (!exceeded_drag_threshold_) { 342 if (!exceeded_drag_threshold_) {
343 exceeded_drag_threshold_ = views::View::ExceededDragThreshold( 343 exceeded_drag_threshold_ = views::View::ExceededDragThreshold(
344 event.location() - press_location_); 344 gfx::ToFlooredPoint(event.location()) - press_location_);
345 } 345 }
346 if (exceeded_drag_threshold_) 346 if (exceeded_drag_threshold_)
347 UpdateSnap(event.location()); 347 UpdateSnap(gfx::ToFlooredPoint(event.location()));
348 } 348 }
349 349
350 bool FrameMaximizeButton::ProcessEndEvent(const ui::LocatedEvent& event) { 350 bool FrameMaximizeButton::ProcessEndEvent(const ui::LocatedEvent& event) {
351 update_timer_.Stop(); 351 update_timer_.Stop();
352 UninstallEventFilter(); 352 UninstallEventFilter();
353 bool should_snap = is_snap_enabled_; 353 bool should_snap = is_snap_enabled_;
354 is_snap_enabled_ = false; 354 is_snap_enabled_ = false;
355 355
356 // Remove our help bubble. 356 // Remove our help bubble.
357 maximizer_.reset(); 357 maximizer_.reset();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return FRAME_STATE_SNAP_LEFT; 538 return FRAME_STATE_SNAP_LEFT;
539 if (bounds.right() == screen.right()) 539 if (bounds.right() == screen.right())
540 return FRAME_STATE_SNAP_RIGHT; 540 return FRAME_STATE_SNAP_RIGHT;
541 // If we come here, it is likely caused by the fact that the 541 // If we come here, it is likely caused by the fact that the
542 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case 542 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case
543 // we allow all maximize operations (and keep the restore rectangle). 543 // we allow all maximize operations (and keep the restore rectangle).
544 return FRAME_STATE_NONE; 544 return FRAME_STATE_NONE;
545 } 545 }
546 546
547 } // namespace ash 547 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698