| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 using ash::internal::SnapSizer; | 26 using ash::internal::SnapSizer; |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // Delay before forcing an update of the snap location. | 32 // Delay before forcing an update of the snap location. |
| 33 const int kUpdateDelayMS = 400; | 33 const int kUpdateDelayMS = 400; |
| 34 | 34 |
| 35 // The delay of the bubble appearance. |
| 36 const int kBubbleAppearanceDelayMS = 200; |
| 37 |
| 35 } | 38 } |
| 36 | 39 |
| 37 // EscapeEventFilter is installed on the RootWindow to track when the escape key | 40 // EscapeEventFilter is installed on the RootWindow to track when the escape key |
| 38 // is pressed. We use an EventFilter for this as the FrameMaximizeButton | 41 // is pressed. We use an EventFilter for this as the FrameMaximizeButton |
| 39 // normally does not get focus. | 42 // normally does not get focus. |
| 40 class FrameMaximizeButton::EscapeEventFilter : public aura::EventFilter { | 43 class FrameMaximizeButton::EscapeEventFilter : public aura::EventFilter { |
| 41 public: | 44 public: |
| 42 explicit EscapeEventFilter(FrameMaximizeButton* button); | 45 explicit EscapeEventFilter(FrameMaximizeButton* button); |
| 43 virtual ~EscapeEventFilter(); | 46 virtual ~EscapeEventFilter(); |
| 44 | 47 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 103 |
| 101 // FrameMaximizeButton --------------------------------------------------------- | 104 // FrameMaximizeButton --------------------------------------------------------- |
| 102 | 105 |
| 103 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, | 106 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, |
| 104 views::NonClientFrameView* frame) | 107 views::NonClientFrameView* frame) |
| 105 : ImageButton(listener), | 108 : ImageButton(listener), |
| 106 frame_(frame), | 109 frame_(frame), |
| 107 is_snap_enabled_(false), | 110 is_snap_enabled_(false), |
| 108 exceeded_drag_threshold_(false), | 111 exceeded_drag_threshold_(false), |
| 109 window_(NULL), | 112 window_(NULL), |
| 110 snap_type_(SNAP_NONE) { | 113 snap_type_(SNAP_NONE), |
| 114 bubble_appearance_delay_ms_(kBubbleAppearanceDelayMS) { |
| 111 // TODO(sky): nuke this. It's temporary while we don't have good images. | 115 // TODO(sky): nuke this. It's temporary while we don't have good images. |
| 112 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); | 116 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); |
| 113 } | 117 } |
| 114 | 118 |
| 115 FrameMaximizeButton::~FrameMaximizeButton() { | 119 FrameMaximizeButton::~FrameMaximizeButton() { |
| 116 // Before the window gets destroyed, the maximizer dialog needs to be shut | 120 // Before the window gets destroyed, the maximizer dialog needs to be shut |
| 117 // down since it would otherwise call into a deleted object. | 121 // down since it would otherwise call into a deleted object. |
| 118 maximizer_.reset(); | 122 maximizer_.reset(); |
| 119 if (window_) | 123 if (window_) |
| 120 OnWindowDestroying(window_); | 124 OnWindowDestroying(window_); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void FrameMaximizeButton::OnMouseEntered(const views::MouseEvent& event) { | 199 void FrameMaximizeButton::OnMouseEntered(const views::MouseEvent& event) { |
| 196 ImageButton::OnMouseEntered(event); | 200 ImageButton::OnMouseEntered(event); |
| 197 if (!maximizer_.get()) { | 201 if (!maximizer_.get()) { |
| 198 DCHECK(GetWidget()); | 202 DCHECK(GetWidget()); |
| 199 if (!window_) { | 203 if (!window_) { |
| 200 window_ = frame_->GetWidget()->GetNativeWindow(); | 204 window_ = frame_->GetWidget()->GetNativeWindow(); |
| 201 window_->AddObserver(this); | 205 window_->AddObserver(this); |
| 202 } | 206 } |
| 203 maximizer_.reset(new MaximizeBubbleController( | 207 maximizer_.reset(new MaximizeBubbleController( |
| 204 this, | 208 this, |
| 205 frame_->GetWidget()->IsMaximized())); | 209 frame_->GetWidget()->IsMaximized(), |
| 210 bubble_appearance_delay_ms_)); |
| 206 } | 211 } |
| 207 } | 212 } |
| 208 | 213 |
| 209 void FrameMaximizeButton::OnMouseExited(const views::MouseEvent& event) { | 214 void FrameMaximizeButton::OnMouseExited(const views::MouseEvent& event) { |
| 210 ImageButton::OnMouseExited(event); | 215 ImageButton::OnMouseExited(event); |
| 211 // Remove the bubble menu when the button is not pressed and the mouse is not | 216 // Remove the bubble menu when the button is not pressed and the mouse is not |
| 212 // within the bubble. | 217 // within the bubble. |
| 213 if (!is_snap_enabled_ && maximizer_.get()) { | 218 if (!is_snap_enabled_ && maximizer_.get()) { |
| 214 if (maximizer_->GetBubbleWindow()) { | 219 if (maximizer_->GetBubbleWindow()) { |
| 215 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint(); | 220 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 283 |
| 279 return ImageButton::OnGestureEvent(event); | 284 return ImageButton::OnGestureEvent(event); |
| 280 } | 285 } |
| 281 | 286 |
| 282 void FrameMaximizeButton::ProcessStartEvent(const views::LocatedEvent& event) { | 287 void FrameMaximizeButton::ProcessStartEvent(const views::LocatedEvent& event) { |
| 283 DCHECK(is_snap_enabled_); | 288 DCHECK(is_snap_enabled_); |
| 284 // Prepare the help menu. | 289 // Prepare the help menu. |
| 285 if (!maximizer_.get()) { | 290 if (!maximizer_.get()) { |
| 286 maximizer_.reset(new MaximizeBubbleController( | 291 maximizer_.reset(new MaximizeBubbleController( |
| 287 this, | 292 this, |
| 288 frame_->GetWidget()->IsMaximized())); | 293 frame_->GetWidget()->IsMaximized(), |
| 294 bubble_appearance_delay_ms_)); |
| 289 } else { | 295 } else { |
| 290 // If the menu did not show up yet, we delay it even a bit more. | 296 // If the menu did not show up yet, we delay it even a bit more. |
| 291 maximizer_->DelayCreation(); | 297 maximizer_->DelayCreation(); |
| 292 } | 298 } |
| 293 snap_sizer_.reset(NULL); | 299 snap_sizer_.reset(NULL); |
| 294 InstallEventFilter(); | 300 InstallEventFilter(); |
| 295 snap_type_ = SNAP_NONE; | 301 snap_type_ = SNAP_NONE; |
| 296 press_location_ = event.location(); | 302 press_location_ = event.location(); |
| 297 exceeded_drag_threshold_ = false; | 303 exceeded_drag_threshold_ = false; |
| 298 update_timer_.Start( | 304 update_timer_.Start( |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 break; | 496 break; |
| 491 case SNAP_RESTORE: | 497 case SNAP_RESTORE: |
| 492 frame_->GetWidget()->Restore(); | 498 frame_->GetWidget()->Restore(); |
| 493 break; | 499 break; |
| 494 case SNAP_NONE: | 500 case SNAP_NONE: |
| 495 NOTREACHED(); | 501 NOTREACHED(); |
| 496 } | 502 } |
| 497 } | 503 } |
| 498 | 504 |
| 499 } // namespace ash | 505 } // namespace ash |
| OLD | NEW |