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

Side by Side Diff: ash/wm/workspace/snap_sizer.cc

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/workspace/snap_sizer.h" 5 #include "ash/wm/workspace/snap_sizer.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
11 #include "ash/wm/property_util.h"
12 #include "ash/wm/window_resizer.h" 11 #include "ash/wm/window_resizer.h"
12 #include "ash/wm/window_state.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_delegate.h" 15 #include "ui/aura/window_delegate.h"
16 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
17 17
18 namespace ash { 18 namespace ash {
19 namespace internal { 19 namespace internal {
20 20
21 namespace { 21 namespace {
22 22
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 input_type_(input_type), 142 input_type_(input_type),
143 usable_width_(BuildIdealWidthList(window)) { 143 usable_width_(BuildIdealWidthList(window)) {
144 DCHECK(!usable_width_.empty()); 144 DCHECK(!usable_width_.empty());
145 target_bounds_ = GetTargetBounds(); 145 target_bounds_ = GetTargetBounds();
146 } 146 }
147 147
148 SnapSizer::~SnapSizer() { 148 SnapSizer::~SnapSizer() {
149 } 149 }
150 150
151 void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) { 151 void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) {
152 if (!wm::CanSnapWindow(window)) 152 wm::WindowState* window_state = wm::GetWindowState(window);
153 if (!window_state->CanSnap())
153 return; 154 return;
154 internal::SnapSizer sizer(window, gfx::Point(), edge, 155 internal::SnapSizer sizer(window, gfx::Point(), edge,
155 internal::SnapSizer::OTHER_INPUT); 156 internal::SnapSizer::OTHER_INPUT);
156 if (wm::IsWindowFullscreen(window) || wm::IsWindowMaximized(window)) { 157 if (window_state->IsMaximizedOrFullscreen()) {
157 // Before we can set the bounds we need to restore the window. 158 // Before we can set the bounds we need to restore the window.
158 // Restoring the window will set the window to its restored bounds. 159 // Restoring the window will set the window to its restored bounds.
159 // To avoid an unnecessary bounds changes (which may have side effects) 160 // To avoid an unnecessary bounds changes (which may have side effects)
160 // we set the restore bounds to the bounds we want, restore the window, 161 // we set the restore bounds to the bounds we want, restore the window,
161 // then reset the restore bounds. This way no unnecessary bounds 162 // then reset the restore bounds. This way no unnecessary bounds
162 // changes occurs and the original restore bounds is remembered. 163 // changes occurs and the original restore bounds is remembered.
163 gfx::Rect restore = *GetRestoreBoundsInScreen(window); 164 const gfx::Rect& restore = window_state->GetRestoreBoundsInScreen();
164 SetRestoreBoundsInParent(window, sizer.GetSnapBounds(window->bounds())); 165 window_state->SetRestoreBoundsInParent(
165 wm::RestoreWindow(window); 166 sizer.GetSnapBounds(window->bounds()));
166 SetRestoreBoundsInScreen(window, restore); 167 window_state->Restore();
168 window_state->SetRestoreBoundsInScreen(restore);
167 } else { 169 } else {
168 window->SetBounds(sizer.GetSnapBounds(window->bounds())); 170 window->SetBounds(sizer.GetSnapBounds(window->bounds()));
169 } 171 }
170 } 172 }
171 173
172 void SnapSizer::Update(const gfx::Point& location) { 174 void SnapSizer::Update(const gfx::Point& location) {
173 // See description above for details on this behavior. 175 // See description above for details on this behavior.
174 num_moves_since_adjust_++; 176 num_moves_since_adjust_++;
175 if ((base::TimeTicks::Now() - time_last_update_).InMilliseconds() > 177 if ((base::TimeTicks::Now() - time_last_update_).InMilliseconds() >
176 kDelayBeforeIncreaseMS) { 178 kDelayBeforeIncreaseMS) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return GetTargetBoundsForSize(size_index_); 280 return GetTargetBoundsForSize(size_index_);
279 } 281 }
280 282
281 bool SnapSizer::AlongEdge(int x) const { 283 bool SnapSizer::AlongEdge(int x) const {
282 gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_)); 284 gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_));
283 return (x <= area.x()) || (x >= area.right() - 1); 285 return (x <= area.x()) || (x >= area.right() - 1);
284 } 286 }
285 287
286 } // namespace internal 288 } // namespace internal
287 } // namespace ash 289 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698