| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 virtual ~EscapeEventFilter(); | 48 virtual ~EscapeEventFilter(); |
| 49 | 49 |
| 50 // EventFilter overrides: | 50 // EventFilter overrides: |
| 51 virtual bool PreHandleKeyEvent(aura::Window* target, | 51 virtual bool PreHandleKeyEvent(aura::Window* target, |
| 52 ui::KeyEvent* event) OVERRIDE; | 52 ui::KeyEvent* event) OVERRIDE; |
| 53 virtual bool PreHandleMouseEvent(aura::Window* target, | 53 virtual bool PreHandleMouseEvent(aura::Window* target, |
| 54 ui::MouseEvent* event) OVERRIDE; | 54 ui::MouseEvent* event) OVERRIDE; |
| 55 virtual ui::TouchStatus PreHandleTouchEvent( | 55 virtual ui::TouchStatus PreHandleTouchEvent( |
| 56 aura::Window* target, | 56 aura::Window* target, |
| 57 ui::TouchEvent* event) OVERRIDE; | 57 ui::TouchEvent* event) OVERRIDE; |
| 58 virtual ui::GestureStatus PreHandleGestureEvent( | 58 virtual ui::EventResult PreHandleGestureEvent( |
| 59 aura::Window* target, | 59 aura::Window* target, |
| 60 ui::GestureEvent* event) OVERRIDE; | 60 ui::GestureEvent* event) OVERRIDE; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 FrameMaximizeButton* button_; | 63 FrameMaximizeButton* button_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter); | 65 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter( | 68 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 90 ui::MouseEvent* event) { | 90 ui::MouseEvent* event) { |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| 94 ui::TouchStatus FrameMaximizeButton::EscapeEventFilter::PreHandleTouchEvent( | 94 ui::TouchStatus FrameMaximizeButton::EscapeEventFilter::PreHandleTouchEvent( |
| 95 aura::Window* target, | 95 aura::Window* target, |
| 96 ui::TouchEvent* event) { | 96 ui::TouchEvent* event) { |
| 97 return ui::TOUCH_STATUS_UNKNOWN; | 97 return ui::TOUCH_STATUS_UNKNOWN; |
| 98 } | 98 } |
| 99 | 99 |
| 100 ui::GestureStatus FrameMaximizeButton::EscapeEventFilter::PreHandleGestureEvent( | 100 ui::EventResult FrameMaximizeButton::EscapeEventFilter::PreHandleGestureEvent( |
| 101 aura::Window* target, | 101 aura::Window* target, |
| 102 ui::GestureEvent* event) { | 102 ui::GestureEvent* event) { |
| 103 return ui::GESTURE_STATUS_UNKNOWN; | 103 return ui::ER_UNHANDLED; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // FrameMaximizeButton --------------------------------------------------------- | 106 // FrameMaximizeButton --------------------------------------------------------- |
| 107 | 107 |
| 108 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, | 108 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, |
| 109 views::NonClientFrameView* frame) | 109 views::NonClientFrameView* frame) |
| 110 : ImageButton(listener), | 110 : ImageButton(listener), |
| 111 frame_(frame), | 111 frame_(frame), |
| 112 is_snap_enabled_(false), | 112 is_snap_enabled_(false), |
| 113 exceeded_drag_threshold_(false), | 113 exceeded_drag_threshold_(false), |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (!ProcessEndEvent(event) && snap_was_enabled) | 252 if (!ProcessEndEvent(event) && snap_was_enabled) |
| 253 ImageButton::OnMouseReleased(event); | 253 ImageButton::OnMouseReleased(event); |
| 254 // At this point |this| might be already destroyed. | 254 // At this point |this| might be already destroyed. |
| 255 } | 255 } |
| 256 | 256 |
| 257 void FrameMaximizeButton::OnMouseCaptureLost() { | 257 void FrameMaximizeButton::OnMouseCaptureLost() { |
| 258 Cancel(false); | 258 Cancel(false); |
| 259 ImageButton::OnMouseCaptureLost(); | 259 ImageButton::OnMouseCaptureLost(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 ui::GestureStatus FrameMaximizeButton::OnGestureEvent( | 262 ui::EventResult FrameMaximizeButton::OnGestureEvent( |
| 263 const ui::GestureEvent& event) { | 263 const ui::GestureEvent& event) { |
| 264 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { | 264 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { |
| 265 is_snap_enabled_ = true; | 265 is_snap_enabled_ = true; |
| 266 ProcessStartEvent(event); | 266 ProcessStartEvent(event); |
| 267 return ui::GESTURE_STATUS_CONSUMED; | 267 return ui::ER_CONSUMED; |
| 268 } | 268 } |
| 269 | 269 |
| 270 if (event.type() == ui::ET_GESTURE_TAP || | 270 if (event.type() == ui::ET_GESTURE_TAP || |
| 271 event.type() == ui::ET_GESTURE_SCROLL_END) { | 271 event.type() == ui::ET_GESTURE_SCROLL_END) { |
| 272 // The position of the event may have changed from the previous event (both | 272 // The position of the event may have changed from the previous event (both |
| 273 // for TAP and SCROLL_END). So it is necessary to update the snap-state for | 273 // for TAP and SCROLL_END). So it is necessary to update the snap-state for |
| 274 // the current event. | 274 // the current event. |
| 275 ProcessUpdateEvent(event); | 275 ProcessUpdateEvent(event); |
| 276 if (event.type() == ui::ET_GESTURE_TAP) | 276 if (event.type() == ui::ET_GESTURE_TAP) |
| 277 snap_type_ = SnapTypeForLocation(event.location()); | 277 snap_type_ = SnapTypeForLocation(event.location()); |
| 278 ProcessEndEvent(event); | 278 ProcessEndEvent(event); |
| 279 return ui::GESTURE_STATUS_CONSUMED; | 279 return ui::ER_CONSUMED; |
| 280 } | 280 } |
| 281 | 281 |
| 282 if (is_snap_enabled_) { | 282 if (is_snap_enabled_) { |
| 283 if (event.type() == ui::ET_GESTURE_END && | 283 if (event.type() == ui::ET_GESTURE_END && |
| 284 event.details().touch_points() == 1) { | 284 event.details().touch_points() == 1) { |
| 285 // The position of the event may have changed from the previous event. So | 285 // The position of the event may have changed from the previous event. So |
| 286 // it is necessary to update the snap-state for the current event. | 286 // it is necessary to update the snap-state for the current event. |
| 287 ProcessUpdateEvent(event); | 287 ProcessUpdateEvent(event); |
| 288 snap_type_ = SnapTypeForLocation(event.location()); | 288 snap_type_ = SnapTypeForLocation(event.location()); |
| 289 ProcessEndEvent(event); | 289 ProcessEndEvent(event); |
| 290 return ui::GESTURE_STATUS_CONSUMED; | 290 return ui::ER_CONSUMED; |
| 291 } | 291 } |
| 292 | 292 |
| 293 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || | 293 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 294 event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 294 event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 295 ProcessUpdateEvent(event); | 295 ProcessUpdateEvent(event); |
| 296 return ui::GESTURE_STATUS_CONSUMED; | 296 return ui::ER_CONSUMED; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 return ImageButton::OnGestureEvent(event); | 300 return ImageButton::OnGestureEvent(event); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) { | 303 void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) { |
| 304 DCHECK(is_snap_enabled_); | 304 DCHECK(is_snap_enabled_); |
| 305 // Prepare the help menu. | 305 // Prepare the help menu. |
| 306 if (!maximizer_.get()) { | 306 if (!maximizer_.get()) { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 return FRAME_STATE_SNAP_LEFT; | 558 return FRAME_STATE_SNAP_LEFT; |
| 559 if (bounds.right() == screen.right()) | 559 if (bounds.right() == screen.right()) |
| 560 return FRAME_STATE_SNAP_RIGHT; | 560 return FRAME_STATE_SNAP_RIGHT; |
| 561 // If we come here, it is likely caused by the fact that the | 561 // If we come here, it is likely caused by the fact that the |
| 562 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 562 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
| 563 // we allow all maximize operations (and keep the restore rectangle). | 563 // we allow all maximize operations (and keep the restore rectangle). |
| 564 return FRAME_STATE_NONE; | 564 return FRAME_STATE_NONE; |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace ash | 567 } // namespace ash |
| OLD | NEW |