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

Side by Side Diff: ash/wm/toplevel_window_event_handler.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/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/property_util.h"
9 #include "ash/wm/resize_shadow_controller.h" 8 #include "ash/wm/resize_shadow_controller.h"
10 #include "ash/wm/window_resizer.h" 9 #include "ash/wm/window_resizer.h"
11 #include "ash/wm/window_settings.h" 10 #include "ash/wm/window_state.h"
12 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
13 #include "ash/wm/workspace/snap_sizer.h" 12 #include "ash/wm/workspace/snap_sizer.h"
14 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 14 #include "base/run_loop.h"
16 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/client/cursor_client.h" 16 #include "ui/aura/client/cursor_client.h"
18 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
19 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
20 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
21 #include "ui/aura/window_delegate.h" 20 #include "ui/aura/window_delegate.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() { 96 ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() {
98 RemoveHandlers(); 97 RemoveHandlers();
99 if (resizer_) 98 if (resizer_)
100 resizer_->GetTarget()->RemoveObserver(this); 99 resizer_->GetTarget()->RemoveObserver(this);
101 } 100 }
102 101
103 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanging( 102 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanging(
104 const HierarchyChangeParams& params) { 103 const HierarchyChangeParams& params) {
105 if (params.receiver != resizer_->GetTarget()) 104 if (params.receiver != resizer_->GetTarget())
106 return; 105 return;
107 106 wm::WindowState* state = wm::GetWindowState(params.receiver);
108 if (wm::GetWindowSettings(params.receiver)->continue_drag_after_reparent()) { 107 if (state->continue_drag_after_reparent()) {
109 wm::GetWindowSettings(params.receiver)-> 108 state->set_continue_drag_after_reparent(false);
110 set_continue_drag_after_reparent(false);
111 AddHandlers(params.new_parent); 109 AddHandlers(params.new_parent);
112 } else { 110 } else {
113 handler_->CompleteDrag(DRAG_COMPLETE, 0); 111 handler_->CompleteDrag(DRAG_COMPLETE, 0);
114 } 112 }
115 } 113 }
116 114
117 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowPropertyChanged( 115 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowPropertyChanged(
118 aura::Window* window, 116 aura::Window* window,
119 const void* key, 117 const void* key,
120 intptr_t old) { 118 intptr_t old) {
121 if (key == aura::client::kShowStateKey && !wm::IsWindowNormal(window)) 119 if (key == aura::client::kShowStateKey &&
James Cook 2013/09/18 20:44:17 Not for this CL, but I wonder WindowState should p
oshima 2013/09/19 01:52:01 Yes, I'll look into if we can change such that onl
120 !wm::GetWindowState(window)->IsNormal())
122 handler_->CompleteDrag(DRAG_COMPLETE, 0); 121 handler_->CompleteDrag(DRAG_COMPLETE, 0);
123 } 122 }
124 123
125 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowDestroying( 124 void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowDestroying(
126 aura::Window* window) { 125 aura::Window* window) {
127 DCHECK(resizer_.get()); 126 DCHECK(resizer_.get());
128 DCHECK_EQ(resizer_->GetTarget(), window); 127 DCHECK_EQ(resizer_->GetTarget(), window);
129 handler_->ResizerWindowDestroyed(); 128 handler_->ResizerWindowDestroyed();
130 } 129 }
131 130
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 279
281 if (event->type() == ui::ET_GESTURE_SCROLL_END) { 280 if (event->type() == ui::ET_GESTURE_SCROLL_END) {
282 event->StopPropagation(); 281 event->StopPropagation();
283 return; 282 return;
284 } 283 }
285 284
286 int component = 285 int component =
287 target->delegate()->GetNonClientComponent(event->location()); 286 target->delegate()->GetNonClientComponent(event->location());
288 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) 287 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0)
289 return; 288 return;
290 if (!wm::IsWindowNormal(target)) 289
290 wm::WindowState* window_state = wm::GetWindowState(target);
291 if (!window_state->IsNormal())
291 return; 292 return;
292 293
293 if (fabs(event->details().velocity_y()) > 294 if (fabs(event->details().velocity_y()) >
294 kMinVertVelocityForWindowMinimize) { 295 kMinVertVelocityForWindowMinimize) {
295 // Minimize/maximize. 296 // Minimize/maximize.
296 if (event->details().velocity_y() > 0 && 297 if (event->details().velocity_y() > 0 &&
297 wm::CanMinimizeWindow(target)) { 298 window_state->CanMinimize()) {
298 wm::MinimizeWindow(target); 299 window_state->Minimize();
299 SetWindowAlwaysRestoresToRestoreBounds(target, true); 300 window_state->set_always_restores_to_restore_bounds(true);
300 SetRestoreBoundsInParent(target, pre_drag_window_bounds_); 301 window_state->SetRestoreBoundsInParent(pre_drag_window_bounds_);
301 } else if (wm::CanMaximizeWindow(target)) { 302 } else if (window_state->CanMaximize()) {
302 SetRestoreBoundsInParent(target, pre_drag_window_bounds_); 303 window_state->SetRestoreBoundsInParent(pre_drag_window_bounds_);
303 wm::MaximizeWindow(target); 304 window_state->Maximize();
304 } 305 }
305 } else if (wm::CanSnapWindow(target) && 306 } else if (window_state->CanSnap() &&
306 fabs(event->details().velocity_x()) > 307 fabs(event->details().velocity_x()) >
307 kMinHorizVelocityForWindowSwipe) { 308 kMinHorizVelocityForWindowSwipe) {
308 // Snap left/right. 309 // Snap left/right.
309 ui::ScopedLayerAnimationSettings scoped_setter( 310 ui::ScopedLayerAnimationSettings scoped_setter(
310 target->layer()->GetAnimator()); 311 target->layer()->GetAnimator());
311 scoped_setter.SetPreemptionStrategy( 312 scoped_setter.SetPreemptionStrategy(
312 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 313 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
313 internal::SnapSizer::SnapWindow(target, 314 internal::SnapSizer::SnapWindow(target,
314 event->details().velocity_x() < 0 ? 315 event->details().velocity_x() < 0 ?
315 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE); 316 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 527 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
527 // We explicitly don't invoke RevertDrag() since that may do things to window. 528 // We explicitly don't invoke RevertDrag() since that may do things to window.
528 // Instead we destroy the resizer. 529 // Instead we destroy the resizer.
529 window_resizer_.reset(); 530 window_resizer_.reset();
530 531
531 // End the move loop. This does nothing if we're not in a move loop. 532 // End the move loop. This does nothing if we're not in a move loop.
532 EndMoveLoop(); 533 EndMoveLoop();
533 } 534 }
534 535
535 } // namespace ash 536 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698