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/workspace/frame_maximize_button.h" | 5 #include "ash/wm/workspace/frame_maximize_button.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || | 272 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || |
273 event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 273 event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
274 ProcessUpdateEvent(event); | 274 ProcessUpdateEvent(event); |
275 return ui::GESTURE_STATUS_CONSUMED; | 275 return ui::GESTURE_STATUS_CONSUMED; |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 return ImageButton::OnGestureEvent(event); | 279 return ImageButton::OnGestureEvent(event); |
280 } | 280 } |
281 | 281 |
282 void FrameMaximizeButton::ProcessStartEvent(const views::LocatedEvent& event) { | 282 void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) { |
283 DCHECK(is_snap_enabled_); | 283 DCHECK(is_snap_enabled_); |
284 // Prepare the help menu. | 284 // Prepare the help menu. |
285 if (!maximizer_.get()) { | 285 if (!maximizer_.get()) { |
286 maximizer_.reset(new MaximizeBubbleController( | 286 maximizer_.reset(new MaximizeBubbleController( |
287 this, | 287 this, |
288 frame_->GetWidget()->IsMaximized())); | 288 frame_->GetWidget()->IsMaximized())); |
289 } else { | 289 } else { |
290 // If the menu did not show up yet, we delay it even a bit more. | 290 // If the menu did not show up yet, we delay it even a bit more. |
291 maximizer_->DelayCreation(); | 291 maximizer_->DelayCreation(); |
292 } | 292 } |
293 snap_sizer_.reset(NULL); | 293 snap_sizer_.reset(NULL); |
294 InstallEventFilter(); | 294 InstallEventFilter(); |
295 snap_type_ = SNAP_NONE; | 295 snap_type_ = SNAP_NONE; |
296 press_location_ = event.location(); | 296 press_location_ = event.location(); |
297 exceeded_drag_threshold_ = false; | 297 exceeded_drag_threshold_ = false; |
298 update_timer_.Start( | 298 update_timer_.Start( |
299 FROM_HERE, | 299 FROM_HERE, |
300 base::TimeDelta::FromMilliseconds(kUpdateDelayMS), | 300 base::TimeDelta::FromMilliseconds(kUpdateDelayMS), |
301 this, | 301 this, |
302 &FrameMaximizeButton::UpdateSnapFromEventLocation); | 302 &FrameMaximizeButton::UpdateSnapFromEventLocation); |
303 } | 303 } |
304 | 304 |
305 void FrameMaximizeButton::ProcessUpdateEvent(const views::LocatedEvent& event) { | 305 void FrameMaximizeButton::ProcessUpdateEvent(const ui::LocatedEvent& event) { |
306 DCHECK(is_snap_enabled_); | 306 DCHECK(is_snap_enabled_); |
307 int delta_x = event.x() - press_location_.x(); | 307 int delta_x = event.x() - press_location_.x(); |
308 int delta_y = event.y() - press_location_.y(); | 308 int delta_y = event.y() - press_location_.y(); |
309 if (!exceeded_drag_threshold_) { | 309 if (!exceeded_drag_threshold_) { |
310 exceeded_drag_threshold_ = | 310 exceeded_drag_threshold_ = |
311 views::View::ExceededDragThreshold(delta_x, delta_y); | 311 views::View::ExceededDragThreshold(delta_x, delta_y); |
312 } | 312 } |
313 if (exceeded_drag_threshold_) | 313 if (exceeded_drag_threshold_) |
314 UpdateSnap(event.location()); | 314 UpdateSnap(event.location()); |
315 } | 315 } |
316 | 316 |
317 bool FrameMaximizeButton::ProcessEndEvent(const views::LocatedEvent& event) { | 317 bool FrameMaximizeButton::ProcessEndEvent(const ui::LocatedEvent& event) { |
318 update_timer_.Stop(); | 318 update_timer_.Stop(); |
319 UninstallEventFilter(); | 319 UninstallEventFilter(); |
320 bool should_snap = is_snap_enabled_; | 320 bool should_snap = is_snap_enabled_; |
321 is_snap_enabled_ = false; | 321 is_snap_enabled_ = false; |
322 | 322 |
323 // Remove our help bubble. | 323 // Remove our help bubble. |
324 maximizer_.reset(); | 324 maximizer_.reset(); |
325 | 325 |
326 if (!should_snap || snap_type_ == SNAP_NONE) | 326 if (!should_snap || snap_type_ == SNAP_NONE) |
327 return false; | 327 return false; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 break; | 490 break; |
491 case SNAP_RESTORE: | 491 case SNAP_RESTORE: |
492 frame_->GetWidget()->Restore(); | 492 frame_->GetWidget()->Restore(); |
493 break; | 493 break; |
494 case SNAP_NONE: | 494 case SNAP_NONE: |
495 NOTREACHED(); | 495 NOTREACHED(); |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 } // namespace ash | 499 } // namespace ash |
OLD | NEW |