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

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 new addition 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
« no previous file with comments | « ash/wm/window_util.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = 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
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
OLDNEW
« no previous file with comments | « ash/wm/window_util.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698