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

Side by Side Diff: ash/wm/workspace/frame_maximize_button.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some new gfx::Screen additions Created 8 years, 2 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 (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
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 =
240 Shell::GetAshScreen()->GetCursorScreenPoint();
240 if (!maximizer_->GetBubbleWindow()->GetBoundsInScreen().Contains( 241 if (!maximizer_->GetBubbleWindow()->GetBoundsInScreen().Contains(
241 screen_location)) { 242 screen_location)) {
242 maximizer_.reset(); 243 maximizer_.reset();
243 // Make sure that all remaining snap hover states get removed. 244 // Make sure that all remaining snap hover states get removed.
244 SnapButtonHovered(SNAP_NONE); 245 SnapButtonHovered(SNAP_NONE);
245 } 246 }
246 } else { 247 } else {
247 // The maximize dialog does not show up immediately after creating the 248 // The maximize dialog does not show up immediately after creating the
248 // |mazimizer_|. Destroy the dialog therefore before it shows up. 249 // |mazimizer_|. Destroy the dialog therefore before it shows up.
249 maximizer_.reset(); 250 maximizer_.reset();
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 FrameMaximizeButton::GetMaximizeBubbleFrameState() const { 555 FrameMaximizeButton::GetMaximizeBubbleFrameState() const {
555 // When there are no restore bounds, we are in normal mode. 556 // When there are no restore bounds, we are in normal mode.
556 if (!ash::GetRestoreBoundsInScreen( 557 if (!ash::GetRestoreBoundsInScreen(
557 frame_->GetWidget()->GetNativeWindow())) 558 frame_->GetWidget()->GetNativeWindow()))
558 return FRAME_STATE_NONE; 559 return FRAME_STATE_NONE;
559 // The normal maximized test can be used. 560 // The normal maximized test can be used.
560 if (frame_->GetWidget()->IsMaximized()) 561 if (frame_->GetWidget()->IsMaximized())
561 return FRAME_STATE_FULL; 562 return FRAME_STATE_FULL;
562 // For Left/right maximize we need to check the dimensions. 563 // For Left/right maximize we need to check the dimensions.
563 gfx::Rect bounds = frame_->GetWidget()->GetWindowBoundsInScreen(); 564 gfx::Rect bounds = frame_->GetWidget()->GetWindowBoundsInScreen();
564 gfx::Rect screen = gfx::Screen::GetDisplayMatching(bounds).work_area(); 565 gfx::Rect screen =
566 Shell::GetAshScreen()->GetDisplayMatching(bounds).work_area();
565 if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100) 567 if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100)
566 return FRAME_STATE_NONE; 568 return FRAME_STATE_NONE;
567 // We might still have a horizontally filled window at this point which we 569 // We might still have a horizontally filled window at this point which we
568 // treat as no special state. 570 // treat as no special state.
569 if (bounds.y() != screen.y() || bounds.height() != screen.height()) 571 if (bounds.y() != screen.y() || bounds.height() != screen.height())
570 return FRAME_STATE_NONE; 572 return FRAME_STATE_NONE;
571 573
572 // We have to be in a maximize mode at this point. 574 // We have to be in a maximize mode at this point.
573 if (bounds.x() == screen.x()) 575 if (bounds.x() == screen.x())
574 return FRAME_STATE_SNAP_LEFT; 576 return FRAME_STATE_SNAP_LEFT;
575 if (bounds.right() == screen.right()) 577 if (bounds.right() == screen.right())
576 return FRAME_STATE_SNAP_RIGHT; 578 return FRAME_STATE_SNAP_RIGHT;
577 // If we come here, it is likely caused by the fact that the 579 // If we come here, it is likely caused by the fact that the
578 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case 580 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case
579 // we allow all maximize operations (and keep the restore rectangle). 581 // we allow all maximize operations (and keep the restore rectangle).
580 return FRAME_STATE_NONE; 582 return FRAME_STATE_NONE;
581 } 583 }
582 584
583 } // namespace ash 585 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698