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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.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 other os's 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/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 window()->SetBounds(snap_sizer_->target_bounds()); 187 window()->SetBounds(snap_sizer_->target_bounds());
188 return; 188 return;
189 } 189 }
190 190
191 gfx::Rect bounds(GetFinalBounds(window()->bounds())); 191 gfx::Rect bounds(GetFinalBounds(window()->bounds()));
192 192
193 // Check if the destination is another display. 193 // Check if the destination is another display.
194 gfx::Point last_mouse_location_in_screen = last_mouse_location_; 194 gfx::Point last_mouse_location_in_screen = last_mouse_location_;
195 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); 195 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen);
196 const gfx::Display dst_display = 196 const gfx::Display dst_display =
197 gfx::Screen::GetDisplayNearestPoint(last_mouse_location_in_screen); 197 gfx::Screen::GetDisplayNearestPoint(
198 ash::Shell::GetRootNativeView(), last_mouse_location_in_screen);
198 199
199 if (dst_display.id() != 200 if (dst_display.id() !=
200 gfx::Screen::GetDisplayNearestWindow(window()->GetRootWindow()).id()) { 201 gfx::Screen::GetDisplayNearestWindow(window()->GetRootWindow()).id()) {
201 // Don't animate when moving to another display. 202 // Don't animate when moving to another display.
202 const gfx::Rect dst_bounds = 203 const gfx::Rect dst_bounds =
203 ScreenAsh::ConvertRectToScreen(window()->parent(), bounds); 204 ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
204 window()->SetBoundsInScreen(dst_bounds, dst_display); 205 window()->SetBoundsInScreen(dst_bounds, dst_display);
205 } 206 }
206 } 207 }
207 208
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 421 }
421 } 422 }
422 423
423 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( 424 void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
424 gfx::Rect* bounds, 425 gfx::Rect* bounds,
425 int grid_size) { 426 int grid_size) {
426 427
427 gfx::Point last_mouse_location_in_screen = last_mouse_location_; 428 gfx::Point last_mouse_location_in_screen = last_mouse_location_;
428 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); 429 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen);
429 gfx::Display display = 430 gfx::Display display =
430 gfx::Screen::GetDisplayNearestPoint(last_mouse_location_in_screen); 431 gfx::Screen::GetDisplayNearestPoint(
432 ash::Shell::GetRootNativeView(), last_mouse_location_in_screen);
431 gfx::Rect work_area = 433 gfx::Rect work_area =
432 ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area()); 434 ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area());
433 if (details_.window_component == HTCAPTION) { 435 if (details_.window_component == HTCAPTION) {
434 // Adjust the bounds to the work area where the mouse cursor is located. 436 // Adjust the bounds to the work area where the mouse cursor is located.
435 // Always keep kMinOnscreenHeight on the bottom. 437 // Always keep kMinOnscreenHeight on the bottom.
436 int max_y = work_area.bottom() - kMinOnscreenHeight; 438 int max_y = work_area.bottom() - kMinOnscreenHeight;
437 if (bounds->y() > max_y) { 439 if (bounds->y() > max_y) {
438 bounds->set_y(max_y); 440 bounds->set_y(max_y);
439 } else if (bounds->y() <= work_area.y()) { 441 } else if (bounds->y() <= work_area.y()) {
440 // Don't allow dragging above the top of the display until the mouse 442 // Don't allow dragging above the top of the display until the mouse
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); 539 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window));
538 540
539 if (fraction_in_another_window > 0) { 541 if (fraction_in_another_window > 0) {
540 if (!drag_phantom_window_controller_.get()) { 542 if (!drag_phantom_window_controller_.get()) {
541 drag_phantom_window_controller_.reset( 543 drag_phantom_window_controller_.reset(
542 new PhantomWindowController(window())); 544 new PhantomWindowController(window()));
543 drag_phantom_window_controller_->set_style( 545 drag_phantom_window_controller_->set_style(
544 PhantomWindowController::STYLE_DRAGGING); 546 PhantomWindowController::STYLE_DRAGGING);
545 // Always show the drag phantom on the |another_root| window. 547 // Always show the drag phantom on the |another_root| window.
546 drag_phantom_window_controller_->SetDestinationDisplay( 548 drag_phantom_window_controller_->SetDestinationDisplay(
547 gfx::Screen::GetDisplayMatching(another_root->GetBoundsInScreen())); 549 gfx::Screen::GetDisplayMatching(
550 ash::Shell::GetRootNativeView(),
551 another_root->GetBoundsInScreen()));
548 if (!layer_) 552 if (!layer_)
549 RecreateWindowLayers(); 553 RecreateWindowLayers();
550 drag_phantom_window_controller_->Show(bounds_in_screen, layer_); 554 drag_phantom_window_controller_->Show(bounds_in_screen, layer_);
551 } else { 555 } else {
552 // No animation. 556 // No animation.
553 drag_phantom_window_controller_->SetBounds(bounds_in_screen); 557 drag_phantom_window_controller_->SetBounds(bounds_in_screen);
554 } 558 }
555 drag_phantom_window_controller_->SetOpacity(phantom_opacity); 559 drag_phantom_window_controller_->SetOpacity(phantom_opacity);
556 window()->layer()->SetOpacity(window_opacity); 560 window()->layer()->SetOpacity(window_opacity);
557 } else { 561 } else {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 gfx::Rect layer_bounds = layer_->bounds(); 649 gfx::Rect layer_bounds = layer_->bounds();
646 layer_bounds.set_origin(gfx::Point(0, 0)); 650 layer_bounds.set_origin(gfx::Point(0, 0));
647 layer_->SetBounds(layer_bounds); 651 layer_->SetBounds(layer_bounds);
648 layer_->SetVisible(false); 652 layer_->SetVisible(false);
649 // Detach it from the current container. 653 // Detach it from the current container.
650 layer_->parent()->Remove(layer_); 654 layer_->parent()->Remove(layer_);
651 } 655 }
652 656
653 } // namespace internal 657 } // namespace internal
654 } // namespace ash 658 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698