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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_window_state.cc

Issue 247363005: Fullscreen/immersive mode is allowed in touch view mode, the shelf gets hidden and an edge swipe br… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_state.h ('k') | no next file » | 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/maximize_mode/maximize_mode_window_state.h" 5 #include "ash/wm/maximize_mode/maximize_mode_window_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"
(...skipping 27 matching lines...) Expand all
38 return workspace_size; 38 return workspace_size;
39 39
40 gfx::Size size = delegate->GetMaximumSize(); 40 gfx::Size size = delegate->GetMaximumSize();
41 if (size.IsEmpty()) 41 if (size.IsEmpty())
42 return workspace_size; 42 return workspace_size;
43 43
44 size.SetToMin(workspace_size); 44 size.SetToMin(workspace_size);
45 return size; 45 return size;
46 } 46 }
47 47
48 // Returns the maximized and centered bounds of a window. 48 // Returns the maximized/full screen and/or centered bounds of a window.
49 gfx::Rect GetMaximizedAndCenteredBounds(wm::WindowState* state_object) { 49 gfx::Rect GetMaximizedAndCenteredBounds(wm::WindowState* state_object) {
50 if (state_object->IsFullscreen())
51 return ScreenUtil::GetDisplayBoundsInParent(state_object->window());
52
50 gfx::Rect bounds_in_parent; 53 gfx::Rect bounds_in_parent;
51 // Make the window as big as possible. 54 // Make the window as big as possible.
52 if (state_object->CanMaximize() || state_object->CanResize()) { 55 if (state_object->CanMaximize() || state_object->CanResize()) {
53 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object)); 56 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object));
54 } else { 57 } else {
55 // We prefer the user given window dimensions over the current windows 58 // We prefer the user given window dimensions over the current windows
56 // dimensions since they are likely to be the result from some other state 59 // dimensions since they are likely to be the result from some other state
57 // object logic. 60 // object logic.
58 if (state_object->HasRestoreBounds()) 61 if (state_object->HasRestoreBounds())
59 bounds_in_parent = state_object->GetRestoreBoundsInParent(); 62 bounds_in_parent = state_object->GetRestoreBoundsInParent();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 112
110 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) { 113 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) {
111 // Note: When we return we will destroy ourselves with the |our_reference|. 114 // Note: When we return we will destroy ourselves with the |our_reference|.
112 scoped_ptr<wm::WindowState::State> our_reference = 115 scoped_ptr<wm::WindowState::State> our_reference =
113 window_state->SetStateObject(old_state_.Pass()); 116 window_state->SetStateObject(old_state_.Pass());
114 } 117 }
115 118
116 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state, 119 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
117 const wm::WMEvent* event) { 120 const wm::WMEvent* event) {
118 switch (event->type()) { 121 switch (event->type()) {
122 case wm::WM_EVENT_TOGGLE_FULLSCREEN:
123 ShowWindow(window_state,
124 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN ?
125 FULL_SCREEN : MAXIMIZED_OR_CENTERED,
126 true);
oshima 2014/04/23 15:57:38 can you refactor the code in default_state and use
Mr4D (OOO till 08-26) 2014/04/23 19:20:31 Not quite sure what you want. Either way - that sh
Mr4D (OOO till 08-26) 2014/04/25 17:36:29 Your comment was a bit confusing. It sounded like
oshima 2014/04/25 18:46:55 Yes, that's what I meant. The same code should wor
127 break;
128 case wm::WM_EVENT_FULLSCREEN:
129 ShowWindow(window_state, FULL_SCREEN, true);
130 break;
119 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: 131 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
120 case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: 132 case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE:
121 case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: 133 case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE:
122 case wm::WM_EVENT_TOGGLE_FULLSCREEN:
123 case wm::WM_EVENT_TOGGLE_MAXIMIZE: 134 case wm::WM_EVENT_TOGGLE_MAXIMIZE:
124 case wm::WM_EVENT_CENTER: 135 case wm::WM_EVENT_CENTER:
125 case wm::WM_EVENT_FULLSCREEN:
126 case wm::WM_EVENT_SNAP_LEFT: 136 case wm::WM_EVENT_SNAP_LEFT:
127 case wm::WM_EVENT_SNAP_RIGHT: 137 case wm::WM_EVENT_SNAP_RIGHT:
128 case wm::WM_EVENT_NORMAL: 138 case wm::WM_EVENT_NORMAL:
129 case wm::WM_EVENT_MAXIMIZE: 139 case wm::WM_EVENT_MAXIMIZE:
130 MaximizeOrCenterWindow(window_state, true); 140 ShowWindow(window_state, MAXIMIZED_OR_CENTERED, true);
131 return; 141 return;
132 case wm::WM_EVENT_MINIMIZE: 142 case wm::WM_EVENT_MINIMIZE:
133 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) { 143 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) {
134 current_state_type_ = wm::WINDOW_STATE_TYPE_MINIMIZED; 144 current_state_type_ = wm::WINDOW_STATE_TYPE_MINIMIZED;
135 Minimize(window_state); 145 Minimize(window_state);
136 } 146 }
137 return; 147 return;
138 case wm::WM_EVENT_SHOW_INACTIVE: 148 case wm::WM_EVENT_SHOW_INACTIVE:
139 return; 149 return;
140 case wm::WM_EVENT_SET_BOUNDS: 150 case wm::WM_EVENT_SET_BOUNDS:
oshima 2014/04/23 15:57:38 a window in fullscreen state or maximzied state ca
Mr4D (OOO till 08-26) 2014/04/23 19:20:31 Not entirely correct. A window could have (changin
oshima 2014/04/24 00:35:15 I don't think that's supposed to be possible becau
Mr4D (OOO till 08-26) 2014/04/24 21:52:13 Checked with scheib@ and this should be correct fo
141 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MAXIMIZED || 151 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MAXIMIZED ||
142 window_state->CanResize()) { 152 window_state->CanResize()) {
143 // In case the window is resizable and / or maximized we ignore the 153 // In case the window is resizable and / or maximized we ignore the
144 // requested bounds change and resize to the biggest possible size. 154 // requested bounds change and resize to the biggest possible size.
145 MaximizeOrCenterWindow(window_state, true); 155 ShowWindow(window_state,
156 current_state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN ?
157 FULL_SCREEN : MAXIMIZED_OR_CENTERED,
158 true);
146 } else if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) { 159 } else if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) {
147 // In all other cases (except for minimized windows) we respect the 160 // In all other cases (except for minimized windows) we respect the
148 // requested bounds and center it to a fully visible area on the screen. 161 // requested bounds and center it to a fully visible area on the screen.
149 gfx::Rect bounds_in_parent = 162 gfx::Rect bounds_in_parent =
150 (static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds(); 163 (static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds();
151 bounds_in_parent.ClampToCenteredSize( 164 bounds_in_parent.ClampToCenteredSize(
152 ScreenUtil::GetDisplayWorkAreaBoundsInParent( 165 ScreenUtil::GetDisplayWorkAreaBoundsInParent(
153 window_state->window()).size()); 166 window_state->window()).size());
154 if (bounds_in_parent != window_state->window()->bounds()) 167 if (bounds_in_parent != window_state->window()->bounds())
155 window_state->SetBoundsDirectAnimated(bounds_in_parent); 168 window_state->SetBoundsDirectAnimated(bounds_in_parent);
156 } 169 }
157 break; 170 break;
158 case wm::WM_EVENT_ADDED_TO_WORKSPACE: 171 case wm::WM_EVENT_ADDED_TO_WORKSPACE:
159 MaximizeOrCenterWindow(window_state, true); 172 ShowWindow(window_state,
173 current_state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN ?
174 FULL_SCREEN : MAXIMIZED_OR_CENTERED,
175 true);
160 break; 176 break;
161 case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED: 177 case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED:
162 case wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED: 178 case wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED:
163 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) 179 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED)
164 MaximizeOrCenterWindow(window_state, false); 180 ShowWindow(window_state,
181 current_state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN ?
182 FULL_SCREEN : MAXIMIZED_OR_CENTERED,
183 false);
165 break; 184 break;
166 } 185 }
167 } 186 }
168 187
169 wm::WindowStateType MaximizeModeWindowState::GetType() const { 188 wm::WindowStateType MaximizeModeWindowState::GetType() const {
170 return current_state_type_; 189 return current_state_type_;
171 } 190 }
172 191
173 void MaximizeModeWindowState::AttachState( 192 void MaximizeModeWindowState::AttachState(
174 wm::WindowState* window_state, 193 wm::WindowState* window_state,
175 wm::WindowState::State* previous_state) { 194 wm::WindowState::State* previous_state) {
176 current_state_type_ = previous_state->GetType(); 195 current_state_type_ = previous_state->GetType();
177 196
178 // Initialize the state to a good preset. 197 // Initialize the state to a good preset.
179 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && 198 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
180 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) { 199 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
181 MaximizeOrCenterWindow(window_state, true); 200 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) {
201 ShowWindow(window_state, MAXIMIZED_OR_CENTERED, true);
182 } 202 }
183 203
184 window_state->set_can_be_dragged(false); 204 window_state->set_can_be_dragged(false);
185 } 205 }
186 206
187 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) { 207 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) {
188 window_state->set_can_be_dragged(true); 208 window_state->set_can_be_dragged(true);
189 } 209 }
190 210
191 void MaximizeModeWindowState::MaximizeOrCenterWindow( 211 void MaximizeModeWindowState::ShowWindow(
192 wm::WindowState* window_state, 212 wm::WindowState* window_state,
213 MaximizeModeWindowState::ShowState show_state,
193 bool animated) { 214 bool animated) {
194 const wm::WindowStateType target_state = 215 const wm::WindowStateType target_state =
195 window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : 216 show_state == FULL_SCREEN ? wm::WINDOW_STATE_TYPE_FULLSCREEN :
196 wm::WINDOW_STATE_TYPE_NORMAL; 217 (window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED :
218 wm::WINDOW_STATE_TYPE_NORMAL);
197 const wm::WindowStateType old_state_type = current_state_type_; 219 const wm::WindowStateType old_state_type = current_state_type_;
198 gfx::Rect bounds_in_parent = GetMaximizedAndCenteredBounds(window_state); 220 gfx::Rect bounds_in_parent = GetMaximizedAndCenteredBounds(window_state);
199 221
200 if (current_state_type_ != target_state) { 222 if (current_state_type_ != target_state) {
201 current_state_type_ = target_state; 223 current_state_type_ = target_state;
202 window_state->UpdateWindowShowStateFromStateType(); 224 window_state->UpdateWindowShowStateFromStateType();
203 window_state->NotifyPreStateTypeChange(old_state_type); 225 window_state->NotifyPreStateTypeChange(old_state_type);
204 // If we have a target bounds rectangle, we center it and set it 226 // If we have a target bounds rectangle, we center it and set it
205 // accordingly. 227 // accordingly.
206 if (!bounds_in_parent.IsEmpty()) { 228 if (!bounds_in_parent.IsEmpty()) {
(...skipping 27 matching lines...) Expand all
234 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 256 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
235 257
236 // Hide the window. 258 // Hide the window.
237 window_state->window()->Hide(); 259 window_state->window()->Hide();
238 // Activate another window. 260 // Activate another window.
239 if (window_state->IsActive()) 261 if (window_state->IsActive())
240 window_state->Deactivate(); 262 window_state->Deactivate();
241 } 263 }
242 264
243 } // namespace ash 265 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698