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

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

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase Created 3 years, 10 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 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/default_state.h" 5 #include "ash/common/wm/default_state.h"
6 6
7 #include "ash/common/ash_switches.h"
8 #include "ash/common/wm/dock/docked_window_layout_manager.h"
9 #include "ash/common/wm/window_animation_types.h" 7 #include "ash/common/wm/window_animation_types.h"
10 #include "ash/common/wm/window_parenting_utils.h" 8 #include "ash/common/wm/window_parenting_utils.h"
11 #include "ash/common/wm/window_positioning_utils.h" 9 #include "ash/common/wm/window_positioning_utils.h"
12 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm/window_state_delegate.h" 11 #include "ash/common/wm/window_state_delegate.h"
14 #include "ash/common/wm/window_state_util.h" 12 #include "ash/common/wm/window_state_util.h"
15 #include "ash/common/wm/wm_event.h" 13 #include "ash/common/wm/wm_event.h"
16 #include "ash/common/wm/wm_screen_util.h" 14 #include "ash/common/wm/wm_screen_util.h"
17 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
19 #include "ash/public/cpp/shell_window_ids.h" 17 #include "ash/public/cpp/shell_window_ids.h"
20 #include "ash/root_window_controller.h" 18 #include "ash/root_window_controller.h"
21 #include "ui/display/display.h" 19 #include "ui/display/display.h"
22 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
23 21
24 namespace ash { 22 namespace ash {
25 namespace wm { 23 namespace wm {
26 namespace { 24 namespace {
27 25
28 // This specifies how much percent (30%) of a window rect 26 // This specifies how much percent (30%) of a window rect
29 // must be visible when the window is added to the workspace. 27 // must be visible when the window is added to the workspace.
30 const float kMinimumPercentOnScreenArea = 0.3f; 28 const float kMinimumPercentOnScreenArea = 0.3f;
31 29
32 // When a window that has restore bounds at least as large as a work area is 30 // When a window that has restore bounds at least as large as a work area is
33 // unmaximized, inset the bounds slightly so that they are not exactly the same. 31 // unmaximized, inset the bounds slightly so that they are not exactly the same.
34 // This makes it easier to resize the window. 32 // This makes it easier to resize the window.
35 const int kMaximizedWindowInset = 10; // DIPs. 33 const int kMaximizedWindowInset = 10; // DIPs.
36 34
37 bool IsMinimizedWindowState(const WindowStateType state_type) { 35 bool IsMinimizedWindowState(const WindowStateType state_type) {
38 return state_type == WINDOW_STATE_TYPE_MINIMIZED || 36 return state_type == WINDOW_STATE_TYPE_MINIMIZED;
39 state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED;
40 } 37 }
41 38
42 void MoveToDisplayForRestore(WindowState* window_state) { 39 void MoveToDisplayForRestore(WindowState* window_state) {
43 if (!window_state->HasRestoreBounds()) 40 if (!window_state->HasRestoreBounds())
44 return; 41 return;
45 const gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); 42 const gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
46 43
47 // Move only if the restore bounds is outside of 44 // Move only if the restore bounds is outside of
48 // the display. There is no information about in which 45 // the display. There is no information about in which
49 // display it should be restored, so this is best guess. 46 // display it should be restored, so this is best guess.
50 // TODO(oshima): Restore information should contain the 47 // TODO(oshima): Restore information should contain the
51 // work area information like WindowResizer does for the 48 // work area information like WindowResizer does for the
52 // last window location. 49 // last window location.
53 gfx::Rect display_area = 50 gfx::Rect display_area =
54 window_state->window()->GetDisplayNearestWindow().bounds(); 51 window_state->window()->GetDisplayNearestWindow().bounds();
55 52
56 if (!display_area.Intersects(restore_bounds)) { 53 if (!display_area.Intersects(restore_bounds)) {
57 const display::Display& display = 54 const display::Display& display =
58 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); 55 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds);
59 WmShell* shell = window_state->window()->GetShell(); 56 WmShell* shell = window_state->window()->GetShell();
60 WmWindow* new_root = shell->GetRootWindowForDisplayId(display.id()); 57 WmWindow* new_root = shell->GetRootWindowForDisplayId(display.id());
61 if (new_root != window_state->window()->GetRootWindow()) { 58 if (new_root != window_state->window()->GetRootWindow()) {
62 WmWindow* new_container = new_root->GetChildByShellWindowId( 59 WmWindow* new_container = new_root->GetChildByShellWindowId(
63 window_state->window()->GetParent()->GetShellWindowId()); 60 window_state->window()->GetParent()->GetShellWindowId());
64 new_container->AddChild(window_state->window()); 61 new_container->AddChild(window_state->window());
65 } 62 }
66 } 63 }
67 } 64 }
68 65
69 DockedWindowLayoutManager* GetDockedWindowLayoutManager(WmShell* shell) {
70 return DockedWindowLayoutManager::Get(shell->GetActiveWindow());
71 }
72
73 class ScopedPreferredAlignmentResetter {
74 public:
75 ScopedPreferredAlignmentResetter(DockedAlignment dock_alignment,
76 DockedWindowLayoutManager* dock_layout)
77 : docked_window_layout_manager_(dock_layout) {
78 docked_window_layout_manager_->set_preferred_alignment(dock_alignment);
79 }
80 ~ScopedPreferredAlignmentResetter() {
81 docked_window_layout_manager_->set_preferred_alignment(
82 DOCKED_ALIGNMENT_NONE);
83 }
84
85 private:
86 DockedWindowLayoutManager* docked_window_layout_manager_;
87
88 DISALLOW_COPY_AND_ASSIGN(ScopedPreferredAlignmentResetter);
89 };
90
91 class ScopedDockedLayoutEventSourceResetter {
92 public:
93 ScopedDockedLayoutEventSourceResetter(DockedWindowLayoutManager* dock_layout)
94 : docked_window_layout_manager_(dock_layout) {
95 docked_window_layout_manager_->set_event_source(
96 DOCKED_ACTION_SOURCE_KEYBOARD);
97 }
98 ~ScopedDockedLayoutEventSourceResetter() {
99 docked_window_layout_manager_->set_event_source(
100 DOCKED_ACTION_SOURCE_UNKNOWN);
101 }
102
103 private:
104 DockedWindowLayoutManager* docked_window_layout_manager_;
105
106 DISALLOW_COPY_AND_ASSIGN(ScopedDockedLayoutEventSourceResetter);
107 };
108
109 void CycleSnap(WindowState* window_state, WMEventType event) { 66 void CycleSnap(WindowState* window_state, WMEventType event) {
110 DCHECK(!ash::switches::DockedWindowsEnabled());
111
112 wm::WindowStateType desired_snap_state = 67 wm::WindowStateType desired_snap_state =
113 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT 68 event == WM_EVENT_CYCLE_SNAP_LEFT ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
114 ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED 69 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED;
115 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED;
116 70
117 if (window_state->CanSnap() && 71 if (window_state->CanSnap() &&
118 window_state->GetStateType() != desired_snap_state && 72 window_state->GetStateType() != desired_snap_state &&
119 window_state->window()->GetType() != ui::wm::WINDOW_TYPE_PANEL) { 73 window_state->window()->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
120 const wm::WMEvent event(desired_snap_state == 74 const wm::WMEvent event(desired_snap_state ==
121 wm::WINDOW_STATE_TYPE_LEFT_SNAPPED 75 wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
122 ? wm::WM_EVENT_SNAP_LEFT 76 ? wm::WM_EVENT_SNAP_LEFT
123 : wm::WM_EVENT_SNAP_RIGHT); 77 : wm::WM_EVENT_SNAP_RIGHT);
124 window_state->OnWMEvent(&event); 78 window_state->OnWMEvent(&event);
125 return; 79 return;
126 } 80 }
127 81
128 if (window_state->IsSnapped()) { 82 if (window_state->IsSnapped()) {
129 window_state->Restore(); 83 window_state->Restore();
130 return; 84 return;
131 } 85 }
132 window_state->window()->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); 86 window_state->window()->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE);
133 } 87 }
134 88
135 void CycleSnapDock(WindowState* window_state, WMEventType event) {
136 DCHECK(ash::switches::DockedWindowsEnabled());
137
138 DockedWindowLayoutManager* dock_layout =
139 GetDockedWindowLayoutManager(window_state->window()->GetShell());
140 wm::WindowStateType desired_snap_state =
141 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT
142 ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
143 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED;
144 DockedAlignment desired_dock_alignment =
145 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT ? DOCKED_ALIGNMENT_LEFT
146 : DOCKED_ALIGNMENT_RIGHT;
147 DockedAlignment current_dock_alignment =
148 dock_layout ? dock_layout->CalculateAlignment() : DOCKED_ALIGNMENT_NONE;
149
150 if (!window_state->IsDocked() ||
151 (current_dock_alignment != DOCKED_ALIGNMENT_NONE &&
152 current_dock_alignment != desired_dock_alignment)) {
153 if (window_state->CanSnap() &&
154 window_state->GetStateType() != desired_snap_state &&
155 window_state->window()->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
156 const wm::WMEvent event(desired_snap_state ==
157 wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
158 ? wm::WM_EVENT_SNAP_LEFT
159 : wm::WM_EVENT_SNAP_RIGHT);
160 window_state->OnWMEvent(&event);
161 return;
162 }
163
164 if (dock_layout &&
165 dock_layout->CanDockWindow(window_state->window(),
166 desired_dock_alignment)) {
167 if (window_state->IsDocked()) {
168 dock_layout->MaybeSetDesiredDockedAlignment(desired_dock_alignment);
169 return;
170 }
171
172 ScopedDockedLayoutEventSourceResetter event_source_resetter(dock_layout);
173 ScopedPreferredAlignmentResetter alignmentResetter(desired_dock_alignment,
174 dock_layout);
175 const wm::WMEvent event(wm::WM_EVENT_DOCK);
176 window_state->OnWMEvent(&event);
177 return;
178 }
179 }
180
181 if (window_state->IsDocked() || window_state->IsSnapped()) {
182 ScopedDockedLayoutEventSourceResetter event_source_resetter(dock_layout);
183 window_state->Restore();
184 return;
185 }
186 window_state->window()->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE);
187 }
188
189 } // namespace 89 } // namespace
190 90
191 DefaultState::DefaultState(WindowStateType initial_state_type) 91 DefaultState::DefaultState(WindowStateType initial_state_type)
192 : state_type_(initial_state_type), stored_window_state_(nullptr) {} 92 : state_type_(initial_state_type), stored_window_state_(nullptr) {}
193 DefaultState::~DefaultState() {} 93 DefaultState::~DefaultState() {}
194 94
195 void DefaultState::OnWMEvent(WindowState* window_state, const WMEvent* event) { 95 void DefaultState::OnWMEvent(WindowState* window_state, const WMEvent* event) {
196 if (ProcessWorkspaceEvents(window_state, event)) 96 if (ProcessWorkspaceEvents(window_state, event))
197 return; 97 return;
198 98
199 // Do not change the PINNED window state if this is not unpin event. 99 // Do not change the PINNED window state if this is not unpin event.
200 if (window_state->IsTrustedPinned() && event->type() != WM_EVENT_NORMAL) 100 if (window_state->IsTrustedPinned() && event->type() != WM_EVENT_NORMAL)
201 return; 101 return;
202 102
203 if (ProcessCompoundEvents(window_state, event)) 103 if (ProcessCompoundEvents(window_state, event))
204 return; 104 return;
205 105
206 WindowStateType current_state_type = window_state->GetStateType(); 106 WindowStateType current_state_type = window_state->GetStateType();
207 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL; 107 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL;
208 switch (event->type()) { 108 switch (event->type()) {
209 case WM_EVENT_NORMAL: 109 case WM_EVENT_NORMAL:
210 next_state_type = current_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED 110 next_state_type = WINDOW_STATE_TYPE_NORMAL;
211 ? WINDOW_STATE_TYPE_DOCKED
212 : WINDOW_STATE_TYPE_NORMAL;
213 break; 111 break;
214 case WM_EVENT_MAXIMIZE: 112 case WM_EVENT_MAXIMIZE:
215 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED; 113 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED;
216 break; 114 break;
217 case WM_EVENT_MINIMIZE: 115 case WM_EVENT_MINIMIZE:
218 next_state_type = current_state_type == WINDOW_STATE_TYPE_DOCKED 116 next_state_type = WINDOW_STATE_TYPE_MINIMIZED;
219 ? WINDOW_STATE_TYPE_DOCKED_MINIMIZED
220 : WINDOW_STATE_TYPE_MINIMIZED;
221 break; 117 break;
222 case WM_EVENT_FULLSCREEN: 118 case WM_EVENT_FULLSCREEN:
223 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN; 119 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN;
224 break; 120 break;
225 case WM_EVENT_SNAP_LEFT: 121 case WM_EVENT_SNAP_LEFT:
226 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED; 122 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED;
227 break; 123 break;
228 case WM_EVENT_SNAP_RIGHT: 124 case WM_EVENT_SNAP_RIGHT:
229 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED; 125 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED;
230 break; 126 break;
231 case WM_EVENT_DOCK:
232 next_state_type = WINDOW_STATE_TYPE_DOCKED;
233 break;
234 case WM_EVENT_SET_BOUNDS: 127 case WM_EVENT_SET_BOUNDS:
235 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); 128 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event));
236 return; 129 return;
237 case WM_EVENT_SHOW_INACTIVE: 130 case WM_EVENT_SHOW_INACTIVE:
238 next_state_type = WINDOW_STATE_TYPE_INACTIVE; 131 next_state_type = WINDOW_STATE_TYPE_INACTIVE;
239 break; 132 break;
240 case WM_EVENT_PIN: 133 case WM_EVENT_PIN:
241 case WM_EVENT_TRUSTED_PIN: 134 case WM_EVENT_TRUSTED_PIN:
242 // If there already is a pinned window, it is not allowed to set it 135 // If there already is a pinned window, it is not allowed to set it
243 // to this window. 136 // to this window.
244 // TODO(hidehiko): If a system modal window is openening, the pinning 137 // TODO(hidehiko): If a system modal window is openening, the pinning
245 // probably should fail. 138 // probably should fail.
246 if (WmShell::Get()->IsPinned()) { 139 if (WmShell::Get()->IsPinned()) {
247 LOG(ERROR) << "An PIN event will be failed since another window is " 140 LOG(ERROR) << "An PIN event will be failed since another window is "
248 << "already in pinned mode."; 141 << "already in pinned mode.";
249 next_state_type = current_state_type; 142 next_state_type = current_state_type;
250 } else { 143 } else {
251 next_state_type = event->type() == WM_EVENT_PIN 144 next_state_type = event->type() == WM_EVENT_PIN
252 ? WINDOW_STATE_TYPE_PINNED 145 ? WINDOW_STATE_TYPE_PINNED
253 : WINDOW_STATE_TYPE_TRUSTED_PINNED; 146 : WINDOW_STATE_TYPE_TRUSTED_PINNED;
254 } 147 }
255 break; 148 break;
256 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: 149 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
257 case WM_EVENT_TOGGLE_MAXIMIZE: 150 case WM_EVENT_TOGGLE_MAXIMIZE:
258 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: 151 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE:
259 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: 152 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE:
260 case WM_EVENT_TOGGLE_FULLSCREEN: 153 case WM_EVENT_TOGGLE_FULLSCREEN:
261 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: 154 case WM_EVENT_CYCLE_SNAP_LEFT:
262 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: 155 case WM_EVENT_CYCLE_SNAP_RIGHT:
263 case WM_EVENT_CENTER: 156 case WM_EVENT_CENTER:
264 NOTREACHED() << "Compound event should not reach here:" << event; 157 NOTREACHED() << "Compound event should not reach here:" << event;
265 return; 158 return;
266 case WM_EVENT_ADDED_TO_WORKSPACE: 159 case WM_EVENT_ADDED_TO_WORKSPACE:
267 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: 160 case WM_EVENT_WORKAREA_BOUNDS_CHANGED:
268 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: 161 case WM_EVENT_DISPLAY_BOUNDS_CHANGED:
269 NOTREACHED() << "Workspace event should not reach here:" << event; 162 NOTREACHED() << "Workspace event should not reach here:" << event;
270 return; 163 return;
271 } 164 }
272 165
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 297 }
405 298
406 window_state->SetRestoreBoundsInParent(restore_bounds); 299 window_state->SetRestoreBoundsInParent(restore_bounds);
407 window->SetBounds(new_bounds); 300 window->SetBounds(new_bounds);
408 } 301 }
409 return true; 302 return true;
410 } 303 }
411 case WM_EVENT_TOGGLE_FULLSCREEN: 304 case WM_EVENT_TOGGLE_FULLSCREEN:
412 ToggleFullScreen(window_state, window_state->delegate()); 305 ToggleFullScreen(window_state, window_state->delegate());
413 return true; 306 return true;
414 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: 307 case WM_EVENT_CYCLE_SNAP_LEFT:
415 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: 308 case WM_EVENT_CYCLE_SNAP_RIGHT:
416 if (ash::switches::DockedWindowsEnabled()) 309 CycleSnap(window_state, event->type());
417 CycleSnapDock(window_state, event->type());
418 else
419 CycleSnap(window_state, event->type());
420 return true; 310 return true;
421 case WM_EVENT_CENTER: 311 case WM_EVENT_CENTER:
422 CenterWindow(window_state); 312 CenterWindow(window_state);
423 return true; 313 return true;
424 case WM_EVENT_NORMAL: 314 case WM_EVENT_NORMAL:
425 case WM_EVENT_MAXIMIZE: 315 case WM_EVENT_MAXIMIZE:
426 case WM_EVENT_MINIMIZE: 316 case WM_EVENT_MINIMIZE:
427 case WM_EVENT_FULLSCREEN: 317 case WM_EVENT_FULLSCREEN:
428 case WM_EVENT_PIN: 318 case WM_EVENT_PIN:
429 case WM_EVENT_TRUSTED_PIN: 319 case WM_EVENT_TRUSTED_PIN:
430 case WM_EVENT_SNAP_LEFT: 320 case WM_EVENT_SNAP_LEFT:
431 case WM_EVENT_SNAP_RIGHT: 321 case WM_EVENT_SNAP_RIGHT:
432 case WM_EVENT_SET_BOUNDS: 322 case WM_EVENT_SET_BOUNDS:
433 case WM_EVENT_SHOW_INACTIVE: 323 case WM_EVENT_SHOW_INACTIVE:
434 case WM_EVENT_DOCK:
435 break; 324 break;
436 case WM_EVENT_ADDED_TO_WORKSPACE: 325 case WM_EVENT_ADDED_TO_WORKSPACE:
437 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: 326 case WM_EVENT_WORKAREA_BOUNDS_CHANGED:
438 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: 327 case WM_EVENT_DISPLAY_BOUNDS_CHANGED:
439 NOTREACHED() << "Workspace event should not reach here:" << event; 328 NOTREACHED() << "Workspace event should not reach here:" << event;
440 break; 329 break;
441 } 330 }
442 return false; 331 return false;
443 } 332 }
444 333
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 window_state->AdjustSnappedBounds(&bounds); 414 window_state->AdjustSnappedBounds(&bounds);
526 if (window_state->window()->GetTargetBounds() != bounds) 415 if (window_state->window()->GetTargetBounds() != bounds)
527 window_state->SetBoundsDirectAnimated(bounds); 416 window_state->SetBoundsDirectAnimated(bounds);
528 return true; 417 return true;
529 } 418 }
530 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: 419 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
531 case WM_EVENT_TOGGLE_MAXIMIZE: 420 case WM_EVENT_TOGGLE_MAXIMIZE:
532 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: 421 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE:
533 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: 422 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE:
534 case WM_EVENT_TOGGLE_FULLSCREEN: 423 case WM_EVENT_TOGGLE_FULLSCREEN:
535 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: 424 case WM_EVENT_CYCLE_SNAP_LEFT:
536 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: 425 case WM_EVENT_CYCLE_SNAP_RIGHT:
537 case WM_EVENT_CENTER: 426 case WM_EVENT_CENTER:
538 case WM_EVENT_NORMAL: 427 case WM_EVENT_NORMAL:
539 case WM_EVENT_MAXIMIZE: 428 case WM_EVENT_MAXIMIZE:
540 case WM_EVENT_MINIMIZE: 429 case WM_EVENT_MINIMIZE:
541 case WM_EVENT_FULLSCREEN: 430 case WM_EVENT_FULLSCREEN:
542 case WM_EVENT_PIN: 431 case WM_EVENT_PIN:
543 case WM_EVENT_TRUSTED_PIN: 432 case WM_EVENT_TRUSTED_PIN:
544 case WM_EVENT_SNAP_LEFT: 433 case WM_EVENT_SNAP_LEFT:
545 case WM_EVENT_SNAP_RIGHT: 434 case WM_EVENT_SNAP_RIGHT:
546 case WM_EVENT_SET_BOUNDS: 435 case WM_EVENT_SET_BOUNDS:
547 case WM_EVENT_SHOW_INACTIVE: 436 case WM_EVENT_SHOW_INACTIVE:
548 case WM_EVENT_DOCK:
549 break; 437 break;
550 } 438 }
551 return false; 439 return false;
552 } 440 }
553 441
554 // static 442 // static
555 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { 443 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) {
556 DCHECK(!window_state->is_dragged()); 444 DCHECK(!window_state->is_dragged());
557 if (window_state->IsMaximized()) { 445 if (window_state->IsMaximized()) {
558 window_state->SetBoundsDirect( 446 window_state->SetBoundsDirect(
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 WmWindow* window = window_state->window(); 574 WmWindow* window = window_state->window();
687 gfx::Rect bounds_in_parent; 575 gfx::Rect bounds_in_parent;
688 switch (state_type_) { 576 switch (state_type_) {
689 case WINDOW_STATE_TYPE_LEFT_SNAPPED: 577 case WINDOW_STATE_TYPE_LEFT_SNAPPED:
690 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: 578 case WINDOW_STATE_TYPE_RIGHT_SNAPPED:
691 bounds_in_parent = 579 bounds_in_parent =
692 state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED 580 state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED
693 ? GetDefaultLeftSnappedWindowBoundsInParent(window) 581 ? GetDefaultLeftSnappedWindowBoundsInParent(window)
694 : GetDefaultRightSnappedWindowBoundsInParent(window); 582 : GetDefaultRightSnappedWindowBoundsInParent(window);
695 break; 583 break;
696 case WINDOW_STATE_TYPE_DOCKED: {
697 // TODO(afakhry): Remove in M58.
698 DCHECK(ash::switches::DockedWindowsEnabled());
699 if (window->GetParent()->GetShellWindowId() !=
700 kShellWindowId_DockedContainer) {
701 WmWindow* docked_container =
702 window->GetRootWindow()->GetChildByShellWindowId(
703 kShellWindowId_DockedContainer);
704 ReparentChildWithTransientChildren(window, window->GetParent(),
705 docked_container);
706 }
707 // Return early because we don't want to update the bounds of the
708 // window below; as the bounds are managed by the dock layout.
709 return;
710 }
711 case WINDOW_STATE_TYPE_DEFAULT: 584 case WINDOW_STATE_TYPE_DEFAULT:
712 case WINDOW_STATE_TYPE_NORMAL: { 585 case WINDOW_STATE_TYPE_NORMAL: {
713 gfx::Rect work_area_in_parent = GetDisplayWorkAreaBoundsInParent(window); 586 gfx::Rect work_area_in_parent = GetDisplayWorkAreaBoundsInParent(window);
714 if (window_state->HasRestoreBounds()) { 587 if (window_state->HasRestoreBounds()) {
715 bounds_in_parent = window_state->GetRestoreBoundsInParent(); 588 bounds_in_parent = window_state->GetRestoreBoundsInParent();
716 // Check if the |window|'s restored size is bigger than the working area 589 // Check if the |window|'s restored size is bigger than the working area
717 // This may happen if a window was resized to maximized bounds or if the 590 // This may happen if a window was resized to maximized bounds or if the
718 // display resolution changed while the window was maximized. 591 // display resolution changed while the window was maximized.
719 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && 592 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED &&
720 bounds_in_parent.width() >= work_area_in_parent.width() && 593 bounds_in_parent.width() >= work_area_in_parent.width() &&
(...skipping 18 matching lines...) Expand all
739 case WINDOW_STATE_TYPE_MAXIMIZED: 612 case WINDOW_STATE_TYPE_MAXIMIZED:
740 bounds_in_parent = GetMaximizedWindowBoundsInParent(window); 613 bounds_in_parent = GetMaximizedWindowBoundsInParent(window);
741 break; 614 break;
742 615
743 case WINDOW_STATE_TYPE_FULLSCREEN: 616 case WINDOW_STATE_TYPE_FULLSCREEN:
744 case WINDOW_STATE_TYPE_PINNED: 617 case WINDOW_STATE_TYPE_PINNED:
745 case WINDOW_STATE_TYPE_TRUSTED_PINNED: 618 case WINDOW_STATE_TYPE_TRUSTED_PINNED:
746 bounds_in_parent = GetDisplayBoundsInParent(window); 619 bounds_in_parent = GetDisplayBoundsInParent(window);
747 break; 620 break;
748 621
749 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED:
750 case WINDOW_STATE_TYPE_MINIMIZED: 622 case WINDOW_STATE_TYPE_MINIMIZED:
751 break; 623 break;
752 case WINDOW_STATE_TYPE_INACTIVE: 624 case WINDOW_STATE_TYPE_INACTIVE:
753 case WINDOW_STATE_TYPE_END: 625 case WINDOW_STATE_TYPE_END:
754 case WINDOW_STATE_TYPE_AUTO_POSITIONED: 626 case WINDOW_STATE_TYPE_AUTO_POSITIONED:
755 return; 627 return;
756 } 628 }
757 629
758 if (!window_state->IsMinimized()) { 630 if (!window_state->IsMinimized()) {
759 if (IsMinimizedWindowState(previous_state_type) || 631 if (IsMinimizedWindowState(previous_state_type) ||
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); 686 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window);
815 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); 687 center_in_parent.ClampToCenteredSize(window->GetBounds().size());
816 window_state->SetBoundsDirectAnimated(center_in_parent); 688 window_state->SetBoundsDirectAnimated(center_in_parent);
817 } 689 }
818 // Centering window is treated as if a user moved and resized the window. 690 // Centering window is treated as if a user moved and resized the window.
819 window_state->set_bounds_changed_by_user(true); 691 window_state->set_bounds_changed_by_user(true);
820 } 692 }
821 693
822 } // namespace wm 694 } // namespace wm
823 } // namespace ash 695 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698