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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 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
« no previous file with comments | « ash/wm/coordinate_conversion.cc ('k') | ash/wm/dock/docked_window_layout_manager.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/default_state.h" 5 #include "ash/wm/default_state.h"
6 6
7 #include "ash/display/window_tree_host_manager.h" 7 #include "ash/display/window_tree_host_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (!window_state->HasRestoreBounds()) 47 if (!window_state->HasRestoreBounds())
48 return; 48 return;
49 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); 49 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen();
50 50
51 // Move only if the restore bounds is outside of 51 // Move only if the restore bounds is outside of
52 // the display. There is no information about in which 52 // the display. There is no information about in which
53 // display it should be restored, so this is best guess. 53 // display it should be restored, so this is best guess.
54 // TODO(oshima): Restore information should contain the 54 // TODO(oshima): Restore information should contain the
55 // work area information like WindowResizer does for the 55 // work area information like WindowResizer does for the
56 // last window location. 56 // last window location.
57 gfx::Rect display_area = Shell::GetScreen()->GetDisplayNearestWindow( 57 gfx::Rect display_area = gfx::Screen::GetScreen()
58 window_state->window()).bounds(); 58 ->GetDisplayNearestWindow(window_state->window())
59 .bounds();
59 60
60 if (!display_area.Intersects(restore_bounds)) { 61 if (!display_area.Intersects(restore_bounds)) {
61 const gfx::Display& display = 62 const gfx::Display& display =
62 Shell::GetScreen()->GetDisplayMatching(restore_bounds); 63 gfx::Screen::GetScreen()->GetDisplayMatching(restore_bounds);
63 WindowTreeHostManager* window_tree_host_manager = 64 WindowTreeHostManager* window_tree_host_manager =
64 Shell::GetInstance()->window_tree_host_manager(); 65 Shell::GetInstance()->window_tree_host_manager();
65 aura::Window* new_root = 66 aura::Window* new_root =
66 window_tree_host_manager->GetRootWindowForDisplayId(display.id()); 67 window_tree_host_manager->GetRootWindowForDisplayId(display.id());
67 if (new_root != window_state->window()->GetRootWindow()) { 68 if (new_root != window_state->window()->GetRootWindow()) {
68 aura::Window* new_container = 69 aura::Window* new_container =
69 Shell::GetContainer(new_root, window_state->window()->parent()->id()); 70 Shell::GetContainer(new_root, window_state->window()->parent()->id());
70 new_container->AddChild(window_state->window()); 71 new_container->AddChild(window_state->window());
71 } 72 }
72 } 73 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 254
254 void DefaultState::AttachState( 255 void DefaultState::AttachState(
255 WindowState* window_state, 256 WindowState* window_state,
256 WindowState::State* state_in_previous_mode) { 257 WindowState::State* state_in_previous_mode) {
257 DCHECK_EQ(stored_window_state_, window_state); 258 DCHECK_EQ(stored_window_state_, window_state);
258 259
259 ReenterToCurrentState(window_state, state_in_previous_mode); 260 ReenterToCurrentState(window_state, state_in_previous_mode);
260 261
261 // If the display has changed while in the another mode, 262 // If the display has changed while in the another mode,
262 // we need to let windows know the change. 263 // we need to let windows know the change.
263 gfx::Display current_display = Shell::GetScreen()-> 264 gfx::Display current_display =
264 GetDisplayNearestWindow(window_state->window()); 265 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_state->window());
265 if (stored_display_state_.bounds() != current_display.bounds()) { 266 if (stored_display_state_.bounds() != current_display.bounds()) {
266 const WMEvent event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); 267 const WMEvent event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED);
267 window_state->OnWMEvent(&event); 268 window_state->OnWMEvent(&event);
268 } else if (stored_display_state_.work_area() != current_display.work_area()) { 269 } else if (stored_display_state_.work_area() != current_display.work_area()) {
269 const WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 270 const WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
270 window_state->OnWMEvent(&event); 271 window_state->OnWMEvent(&event);
271 } 272 }
272 } 273 }
273 274
274 void DefaultState::DetachState(WindowState* window_state) { 275 void DefaultState::DetachState(WindowState* window_state) {
275 stored_window_state_ = window_state; 276 stored_window_state_ = window_state;
276 aura::Window* window = window_state->window(); 277 aura::Window* window = window_state->window();
277 stored_bounds_ = window->bounds(); 278 stored_bounds_ = window->bounds();
278 stored_restore_bounds_ = window_state->HasRestoreBounds() ? 279 stored_restore_bounds_ = window_state->HasRestoreBounds() ?
279 window_state->GetRestoreBoundsInParent() : gfx::Rect(); 280 window_state->GetRestoreBoundsInParent() : gfx::Rect();
280 // Remember the display state so that in case of the display change 281 // Remember the display state so that in case of the display change
281 // while in the other mode, we can perform necessary action to 282 // while in the other mode, we can perform necessary action to
282 // restore the window state to the proper state for the current 283 // restore the window state to the proper state for the current
283 // display. 284 // display.
284 stored_display_state_ = Shell::GetScreen()-> 285 stored_display_state_ =
285 GetDisplayNearestWindow(window_state->window()); 286 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_state->window());
286 } 287 }
287 288
288 // static 289 // static
289 bool DefaultState::ProcessCompoundEvents(WindowState* window_state, 290 bool DefaultState::ProcessCompoundEvents(WindowState* window_state,
290 const WMEvent* event) { 291 const WMEvent* event) {
291 aura::Window* window = window_state->window(); 292 aura::Window* window = window_state->window();
292 293
293 switch (event->type()) { 294 switch (event->type()) {
294 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: 295 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
295 if (window_state->IsFullscreen()) { 296 if (window_state->IsFullscreen()) {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 733 }
733 } 734 }
734 735
735 // static 736 // static
736 void DefaultState::CenterWindow(WindowState* window_state) { 737 void DefaultState::CenterWindow(WindowState* window_state) {
737 if (!window_state->IsNormalOrSnapped()) 738 if (!window_state->IsNormalOrSnapped())
738 return; 739 return;
739 aura::Window* window = window_state->window(); 740 aura::Window* window = window_state->window();
740 if (window_state->IsSnapped()) { 741 if (window_state->IsSnapped()) {
741 gfx::Rect center_in_screen = 742 gfx::Rect center_in_screen =
742 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); 743 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
743 gfx::Size size = window_state->HasRestoreBounds() ? 744 gfx::Size size = window_state->HasRestoreBounds() ?
744 window_state->GetRestoreBoundsInScreen().size() : 745 window_state->GetRestoreBoundsInScreen().size() :
745 window->bounds().size(); 746 window->bounds().size();
746 center_in_screen.ClampToCenteredSize(size); 747 center_in_screen.ClampToCenteredSize(size);
747 window_state->SetRestoreBoundsInScreen(center_in_screen); 748 window_state->SetRestoreBoundsInScreen(center_in_screen);
748 window_state->Restore(); 749 window_state->Restore();
749 } else { 750 } else {
750 gfx::Rect center_in_parent = 751 gfx::Rect center_in_parent =
751 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 752 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
752 center_in_parent.ClampToCenteredSize(window->bounds().size()); 753 center_in_parent.ClampToCenteredSize(window->bounds().size());
753 window_state->SetBoundsDirectAnimated(center_in_parent); 754 window_state->SetBoundsDirectAnimated(center_in_parent);
754 } 755 }
755 // Centering window is treated as if a user moved and resized the window. 756 // Centering window is treated as if a user moved and resized the window.
756 window_state->set_bounds_changed_by_user(true); 757 window_state->set_bounds_changed_by_user(true);
757 } 758 }
758 759
759 } // namespace wm 760 } // namespace wm
760 } // namespace ash 761 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/coordinate_conversion.cc ('k') | ash/wm/dock/docked_window_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698