| OLD | NEW |
| 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/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/wm/coordinate_conversion.h" | 11 #include "ash/wm/coordinate_conversion.h" |
| 12 #include "ash/wm/window_animations.h" | 12 #include "ash/wm/window_animations.h" |
| 13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ash/wm/window_state_delegate.h" | 14 #include "ash/wm/window_state_delegate.h" |
| 15 #include "ash/wm/window_state_util.h" |
| 15 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
| 16 #include "ash/wm/wm_event.h" | 17 #include "ash/wm/wm_event.h" |
| 17 #include "ash/wm/workspace/workspace_window_resizer.h" | 18 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 18 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
| 19 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_delegate.h" | 21 #include "ui/aura/window_delegate.h" |
| 21 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // The restore logic prevents a window from being restored to bounds | 252 // The restore logic prevents a window from being restored to bounds |
| 252 // which match the workspace bounds exactly so it is necessary to set | 253 // which match the workspace bounds exactly so it is necessary to set |
| 253 // the bounds again below. | 254 // the bounds again below. |
| 254 } | 255 } |
| 255 | 256 |
| 256 window_state->SetRestoreBoundsInParent(restore_bounds); | 257 window_state->SetRestoreBoundsInParent(restore_bounds); |
| 257 window->SetBounds(new_bounds); | 258 window->SetBounds(new_bounds); |
| 258 } | 259 } |
| 259 return true; | 260 return true; |
| 260 } | 261 } |
| 261 case WM_EVENT_TOGGLE_FULLSCREEN: { | 262 case WM_EVENT_TOGGLE_FULLSCREEN: |
| 262 // Window which cannot be maximized should not be fullscreened. | 263 ToggleFullScreen(window_state, window_state->delegate()); |
| 263 // It can, however, be restored if it was fullscreened. | |
| 264 bool is_fullscreen = window_state->IsFullscreen(); | |
| 265 if (!is_fullscreen && !window_state->CanMaximize()) | |
| 266 return true; | |
| 267 if (window_state->delegate() && | |
| 268 window_state->delegate()->ToggleFullscreen(window_state)) { | |
| 269 return true; | |
| 270 } | |
| 271 if (is_fullscreen) { | |
| 272 window_state->Restore(); | |
| 273 } else { | |
| 274 // | |
| 275 window_state->window()->SetProperty(aura::client::kShowStateKey, | |
| 276 ui::SHOW_STATE_FULLSCREEN); | |
| 277 } | |
| 278 return true; | 264 return true; |
| 279 } | |
| 280 case WM_EVENT_CENTER: | 265 case WM_EVENT_CENTER: |
| 281 CenterWindow(window_state); | 266 CenterWindow(window_state); |
| 282 return true; | 267 return true; |
| 283 case WM_EVENT_NORMAL: | 268 case WM_EVENT_NORMAL: |
| 284 case WM_EVENT_MAXIMIZE: | 269 case WM_EVENT_MAXIMIZE: |
| 285 case WM_EVENT_MINIMIZE: | 270 case WM_EVENT_MINIMIZE: |
| 286 case WM_EVENT_FULLSCREEN: | 271 case WM_EVENT_FULLSCREEN: |
| 287 case WM_EVENT_SNAP_LEFT: | 272 case WM_EVENT_SNAP_LEFT: |
| 288 case WM_EVENT_SNAP_RIGHT: | 273 case WM_EVENT_SNAP_RIGHT: |
| 289 case WM_EVENT_SET_BOUNDS: | 274 case WM_EVENT_SET_BOUNDS: |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); | 582 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); |
| 598 center_in_parent.ClampToCenteredSize(window->bounds().size()); | 583 center_in_parent.ClampToCenteredSize(window->bounds().size()); |
| 599 window_state->SetBoundsDirectAnimated(center_in_parent); | 584 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 600 } | 585 } |
| 601 // Centering window is treated as if a user moved and resized the window. | 586 // Centering window is treated as if a user moved and resized the window. |
| 602 window_state->set_bounds_changed_by_user(true); | 587 window_state->set_bounds_changed_by_user(true); |
| 603 } | 588 } |
| 604 | 589 |
| 605 } // namespace wm | 590 } // namespace wm |
| 606 } // namespace ash | 591 } // namespace ash |
| OLD | NEW |