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/common/wm/maximize_mode/maximize_mode_window_state.h" | 5 #include "ash/common/wm/maximize_mode/maximize_mode_window_state.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
10 #include "ash/common/wm/window_animation_types.h" | 10 #include "ash/common/wm/window_animation_types.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return GetCenteredBounds(bounds_in_parent, state_object); | 66 return GetCenteredBounds(bounds_in_parent, state_object); |
67 } | 67 } |
68 | 68 |
69 gfx::Rect GetRestoreBounds(wm::WindowState* window_state) { | 69 gfx::Rect GetRestoreBounds(wm::WindowState* window_state) { |
70 if (window_state->IsMinimized() || window_state->IsMaximized() || | 70 if (window_state->IsMinimized() || window_state->IsMaximized() || |
71 window_state->IsFullscreen()) { | 71 window_state->IsFullscreen()) { |
72 gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); | 72 gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); |
73 if (!restore_bounds.IsEmpty()) | 73 if (!restore_bounds.IsEmpty()) |
74 return restore_bounds; | 74 return restore_bounds; |
75 } | 75 } |
76 gfx::Rect bounds = window_state->window()->GetBoundsInScreen(); | 76 return window_state->window()->GetBoundsInScreen(); |
77 if (window_state->IsDocked()) { | |
78 gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); | |
79 // Use current window horizontal offset origin in order to preserve docked | |
80 // alignment but preserve restored size and vertical offset for the time | |
81 // when the window gets undocked. | |
82 if (!restore_bounds.IsEmpty()) { | |
83 bounds.set_size(restore_bounds.size()); | |
84 bounds.set_y(restore_bounds.y()); | |
85 } | |
86 } | |
87 return bounds; | |
88 } | 77 } |
89 | 78 |
90 } // namespace | 79 } // namespace |
91 | 80 |
92 // static | 81 // static |
93 void MaximizeModeWindowState::UpdateWindowPosition( | 82 void MaximizeModeWindowState::UpdateWindowPosition( |
94 wm::WindowState* window_state) { | 83 wm::WindowState* window_state) { |
95 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); | 84 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); |
96 if (bounds_in_parent == window_state->window()->GetBounds()) | 85 if (bounds_in_parent == window_state->window()->GetBounds()) |
97 return; | 86 return; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_PINNED, true); | 132 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_PINNED, true); |
144 break; | 133 break; |
145 case wm::WM_EVENT_TRUSTED_PIN: | 134 case wm::WM_EVENT_TRUSTED_PIN: |
146 if (!WmShell::Get()->IsPinned()) | 135 if (!WmShell::Get()->IsPinned()) |
147 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_TRUSTED_PINNED, true); | 136 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_TRUSTED_PINNED, true); |
148 break; | 137 break; |
149 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 138 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
150 case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: | 139 case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: |
151 case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: | 140 case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: |
152 case wm::WM_EVENT_TOGGLE_MAXIMIZE: | 141 case wm::WM_EVENT_TOGGLE_MAXIMIZE: |
153 case wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT: | 142 case wm::WM_EVENT_CYCLE_SNAP_LEFT: |
154 case wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: | 143 case wm::WM_EVENT_CYCLE_SNAP_RIGHT: |
155 case wm::WM_EVENT_CENTER: | 144 case wm::WM_EVENT_CENTER: |
156 case wm::WM_EVENT_SNAP_LEFT: | 145 case wm::WM_EVENT_SNAP_LEFT: |
157 case wm::WM_EVENT_SNAP_RIGHT: | 146 case wm::WM_EVENT_SNAP_RIGHT: |
158 case wm::WM_EVENT_NORMAL: | 147 case wm::WM_EVENT_NORMAL: |
159 case wm::WM_EVENT_MAXIMIZE: | 148 case wm::WM_EVENT_MAXIMIZE: |
160 case wm::WM_EVENT_DOCK: | |
161 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), | 149 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), |
162 true); | 150 true); |
163 return; | 151 return; |
164 case wm::WM_EVENT_MINIMIZE: | 152 case wm::WM_EVENT_MINIMIZE: |
165 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_MINIMIZED, true); | 153 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_MINIMIZED, true); |
166 return; | 154 return; |
167 case wm::WM_EVENT_SHOW_INACTIVE: | 155 case wm::WM_EVENT_SHOW_INACTIVE: |
168 return; | 156 return; |
169 case wm::WM_EVENT_SET_BOUNDS: | 157 case wm::WM_EVENT_SET_BOUNDS: |
170 if (window_state->allow_set_bounds_in_maximized()) { | 158 if (window_state->allow_set_bounds_in_maximized()) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // avoid flashing. | 316 // avoid flashing. |
329 if (window_state->IsMaximized()) | 317 if (window_state->IsMaximized()) |
330 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 318 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
331 else | 319 else |
332 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 320 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
333 } | 321 } |
334 } | 322 } |
335 } | 323 } |
336 | 324 |
337 } // namespace ash | 325 } // namespace ash |
OLD | NEW |