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

Side by Side Diff: ash/wm/window_state.cc

Issue 2860163005: chromeos: gets rid of wm_screen_util (Closed)
Patch Set: include Created 3 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/public/cpp/window_properties.h" 9 #include "ash/public/cpp/window_properties.h"
10 #include "ash/public/interfaces/window_pin_type.mojom.h" 10 #include "ash/public/interfaces/window_pin_type.mojom.h"
11 #include "ash/screen_util.h"
11 #include "ash/wm/default_state.h" 12 #include "ash/wm/default_state.h"
12 #include "ash/wm/window_positioning_utils.h" 13 #include "ash/wm/window_positioning_utils.h"
13 #include "ash/wm/window_state_delegate.h" 14 #include "ash/wm/window_state_delegate.h"
14 #include "ash/wm/window_state_observer.h" 15 #include "ash/wm/window_state_observer.h"
15 #include "ash/wm/wm_event.h" 16 #include "ash/wm/wm_event.h"
16 #include "ash/wm/wm_screen_util.h"
17 #include "ash/wm_window.h" 17 #include "ash/wm_window.h"
18 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 20
21 namespace ash { 21 namespace ash {
22 namespace wm { 22 namespace wm {
23 23
24 namespace { 24 namespace {
25 25
26 WMEventType WMEventTypeFromShowState(ui::WindowShowState requested_show_state) { 26 WMEventType WMEventTypeFromShowState(ui::WindowShowState requested_show_state) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 void WindowState::SetBoundsInScreen(const gfx::Rect& bounds_in_screen) { 340 void WindowState::SetBoundsInScreen(const gfx::Rect& bounds_in_screen) {
341 gfx::Rect bounds_in_parent = 341 gfx::Rect bounds_in_parent =
342 window_->GetParent()->ConvertRectFromScreen(bounds_in_screen); 342 window_->GetParent()->ConvertRectFromScreen(bounds_in_screen);
343 window_->SetBounds(bounds_in_parent); 343 window_->SetBounds(bounds_in_parent);
344 } 344 }
345 345
346 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) { 346 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) {
347 if (is_dragged() || !IsSnapped()) 347 if (is_dragged() || !IsSnapped())
348 return; 348 return;
349 gfx::Rect maximized_bounds = GetMaximizedWindowBoundsInParent(window_); 349 gfx::Rect maximized_bounds =
350 ScreenUtil::GetMaximizedWindowBoundsInParent(window_->aura_window());
350 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED) 351 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED)
351 bounds->set_x(maximized_bounds.x()); 352 bounds->set_x(maximized_bounds.x());
352 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED) 353 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED)
353 bounds->set_x(maximized_bounds.right() - bounds->width()); 354 bounds->set_x(maximized_bounds.right() - bounds->width());
354 bounds->set_y(maximized_bounds.y()); 355 bounds->set_y(maximized_bounds.y());
355 bounds->set_height(maximized_bounds.height()); 356 bounds->set_height(maximized_bounds.height());
356 } 357 }
357 358
358 void WindowState::UpdateWindowPropertiesFromStateType() { 359 void WindowState::UpdateWindowPropertiesFromStateType() {
359 ui::WindowShowState new_window_state = 360 ui::WindowShowState new_window_state =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 399
399 actual_new_bounds.set_width( 400 actual_new_bounds.set_width(
400 std::max(min_size.width(), actual_new_bounds.width())); 401 std::max(min_size.width(), actual_new_bounds.width()));
401 actual_new_bounds.set_height( 402 actual_new_bounds.set_height(
402 std::max(min_size.height(), actual_new_bounds.height())); 403 std::max(min_size.height(), actual_new_bounds.height()));
403 } 404 }
404 window_->SetBoundsDirect(actual_new_bounds); 405 window_->SetBoundsDirect(actual_new_bounds);
405 } 406 }
406 407
407 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) { 408 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) {
408 gfx::Rect work_area_in_parent = GetDisplayWorkAreaBoundsInParent(window_); 409 gfx::Rect work_area_in_parent =
410 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_->aura_window());
409 gfx::Rect child_bounds(bounds); 411 gfx::Rect child_bounds(bounds);
410 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); 412 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds);
411 SetBoundsDirect(child_bounds); 413 SetBoundsDirect(child_bounds);
412 } 414 }
413 415
414 void WindowState::SetBoundsDirectAnimated(const gfx::Rect& bounds) { 416 void WindowState::SetBoundsDirectAnimated(const gfx::Rect& bounds) {
415 window_->SetBoundsDirectAnimated(bounds); 417 window_->SetBoundsDirectAnimated(bounds);
416 } 418 }
417 419
418 void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds) { 420 void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds) {
419 // Some test results in invoking CrossFadeToBounds when window is not visible. 421 // Some test results in invoking CrossFadeToBounds when window is not visible.
420 // No animation is necessary in that case, thus just change the bounds and 422 // No animation is necessary in that case, thus just change the bounds and
421 // quit. 423 // quit.
422 if (!window_->GetTargetVisibility()) { 424 if (!window_->GetTargetVisibility()) {
423 SetBoundsConstrained(new_bounds); 425 SetBoundsConstrained(new_bounds);
424 return; 426 return;
425 } 427 }
426 428
427 window_->SetBoundsDirectCrossFade(new_bounds); 429 window_->SetBoundsDirectCrossFade(new_bounds);
428 } 430 }
429 431
430 } // namespace wm 432 } // namespace wm
431 } // namespace ash 433 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698