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/maximize_bubble_controller.h" | 10 #include "ash/wm/maximize_bubble_controller.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bubble_appearance_delay_ms_)); | 229 bubble_appearance_delay_ms_)); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 void FrameMaximizeButton::OnMouseExited(const ui::MouseEvent& event) { | 233 void FrameMaximizeButton::OnMouseExited(const ui::MouseEvent& event) { |
234 ImageButton::OnMouseExited(event); | 234 ImageButton::OnMouseExited(event); |
235 // Remove the bubble menu when the button is not pressed and the mouse is not | 235 // Remove the bubble menu when the button is not pressed and the mouse is not |
236 // within the bubble. | 236 // within the bubble. |
237 if (!is_snap_enabled_ && maximizer_.get()) { | 237 if (!is_snap_enabled_ && maximizer_.get()) { |
238 if (maximizer_->GetBubbleWindow()) { | 238 if (maximizer_->GetBubbleWindow()) { |
239 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint(); | 239 gfx::Point screen_location = Shell::GetScreen()->GetCursorScreenPoint(); |
240 if (!maximizer_->GetBubbleWindow()->GetBoundsInScreen().Contains( | 240 if (!maximizer_->GetBubbleWindow()->GetBoundsInScreen().Contains( |
241 screen_location)) { | 241 screen_location)) { |
242 maximizer_.reset(); | 242 maximizer_.reset(); |
243 // Make sure that all remaining snap hover states get removed. | 243 // Make sure that all remaining snap hover states get removed. |
244 SnapButtonHovered(SNAP_NONE); | 244 SnapButtonHovered(SNAP_NONE); |
245 } | 245 } |
246 } else { | 246 } else { |
247 // The maximize dialog does not show up immediately after creating the | 247 // The maximize dialog does not show up immediately after creating the |
248 // |mazimizer_|. Destroy the dialog therefore before it shows up. | 248 // |mazimizer_|. Destroy the dialog therefore before it shows up. |
249 maximizer_.reset(); | 249 maximizer_.reset(); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 FrameMaximizeButton::GetMaximizeBubbleFrameState() const { | 554 FrameMaximizeButton::GetMaximizeBubbleFrameState() const { |
555 // When there are no restore bounds, we are in normal mode. | 555 // When there are no restore bounds, we are in normal mode. |
556 if (!ash::GetRestoreBoundsInScreen( | 556 if (!ash::GetRestoreBoundsInScreen( |
557 frame_->GetWidget()->GetNativeWindow())) | 557 frame_->GetWidget()->GetNativeWindow())) |
558 return FRAME_STATE_NONE; | 558 return FRAME_STATE_NONE; |
559 // The normal maximized test can be used. | 559 // The normal maximized test can be used. |
560 if (frame_->GetWidget()->IsMaximized()) | 560 if (frame_->GetWidget()->IsMaximized()) |
561 return FRAME_STATE_FULL; | 561 return FRAME_STATE_FULL; |
562 // For Left/right maximize we need to check the dimensions. | 562 // For Left/right maximize we need to check the dimensions. |
563 gfx::Rect bounds = frame_->GetWidget()->GetWindowBoundsInScreen(); | 563 gfx::Rect bounds = frame_->GetWidget()->GetWindowBoundsInScreen(); |
564 gfx::Rect screen = gfx::Screen::GetDisplayMatching(bounds).work_area(); | 564 gfx::Rect screen = Shell::GetScreen()->GetDisplayMatching(bounds).work_area(); |
565 if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100) | 565 if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100) |
566 return FRAME_STATE_NONE; | 566 return FRAME_STATE_NONE; |
567 // We might still have a horizontally filled window at this point which we | 567 // We might still have a horizontally filled window at this point which we |
568 // treat as no special state. | 568 // treat as no special state. |
569 if (bounds.y() != screen.y() || bounds.height() != screen.height()) | 569 if (bounds.y() != screen.y() || bounds.height() != screen.height()) |
570 return FRAME_STATE_NONE; | 570 return FRAME_STATE_NONE; |
571 | 571 |
572 // We have to be in a maximize mode at this point. | 572 // We have to be in a maximize mode at this point. |
573 if (bounds.x() == screen.x()) | 573 if (bounds.x() == screen.x()) |
574 return FRAME_STATE_SNAP_LEFT; | 574 return FRAME_STATE_SNAP_LEFT; |
575 if (bounds.right() == screen.right()) | 575 if (bounds.right() == screen.right()) |
576 return FRAME_STATE_SNAP_RIGHT; | 576 return FRAME_STATE_SNAP_RIGHT; |
577 // If we come here, it is likely caused by the fact that the | 577 // If we come here, it is likely caused by the fact that the |
578 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 578 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
579 // we allow all maximize operations (and keep the restore rectangle). | 579 // we allow all maximize operations (and keep the restore rectangle). |
580 return FRAME_STATE_NONE; | 580 return FRAME_STATE_NONE; |
581 } | 581 } |
582 | 582 |
583 } // namespace ash | 583 } // namespace ash |
OLD | NEW |