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

Side by Side Diff: ash/common/wm/workspace/multi_window_resize_controller.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. 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 (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/common/wm/workspace/multi_window_resize_controller.h" 5 #include "ash/common/wm/workspace/multi_window_resize_controller.h"
6 6
7 #include "ash/common/wm/workspace/workspace_window_resizer.h" 7 #include "ash/common/wm/workspace/workspace_window_resizer.h"
8 #include "ash/common/wm_lookup.h" 8 #include "ash/common/wm_lookup.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (IsShowing() && windows_.Equals(windows)) 163 if (IsShowing() && windows_.Equals(windows))
164 return; 164 return;
165 165
166 Hide(); 166 Hide();
167 if (!windows.is_valid()) { 167 if (!windows.is_valid()) {
168 windows_ = ResizeWindows(); 168 windows_ = ResizeWindows();
169 return; 169 return;
170 } 170 }
171 171
172 windows_ = windows; 172 windows_ = windows;
173 windows_.window1->AddObserver(this); 173 windows_.window1->aura_window()->AddObserver(this);
174 windows_.window2->AddObserver(this); 174 windows_.window2->aura_window()->AddObserver(this);
175 show_location_in_parent_ = 175 show_location_in_parent_ =
176 window->ConvertPointToTarget(window->GetParent(), point_in_window); 176 window->ConvertPointToTarget(window->GetParent(), point_in_window);
177 show_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kShowDelayMS), 177 show_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kShowDelayMS),
178 this, 178 this,
179 &MultiWindowResizeController::ShowIfValidMouseLocation); 179 &MultiWindowResizeController::ShowIfValidMouseLocation);
180 } 180 }
181 181
182 void MultiWindowResizeController::Hide() { 182 void MultiWindowResizeController::Hide() {
183 if (window_resizer_) 183 if (window_resizer_)
184 return; // Ignore hides while actively resizing. 184 return; // Ignore hides while actively resizing.
185 185
186 if (windows_.window1) { 186 if (windows_.window1) {
187 windows_.window1->RemoveObserver(this); 187 windows_.window1->aura_window()->RemoveObserver(this);
188 windows_.window1 = NULL; 188 windows_.window1 = NULL;
189 } 189 }
190 if (windows_.window2) { 190 if (windows_.window2) {
191 windows_.window2->RemoveObserver(this); 191 windows_.window2->aura_window()->RemoveObserver(this);
192 windows_.window2 = NULL; 192 windows_.window2 = NULL;
193 } 193 }
194 194
195 show_timer_.Stop(); 195 show_timer_.Stop();
196 196
197 if (!resize_widget_) 197 if (!resize_widget_)
198 return; 198 return;
199 199
200 for (size_t i = 0; i < windows_.other_windows.size(); ++i) 200 for (size_t i = 0; i < windows_.other_windows.size(); ++i)
201 windows_.other_windows[i]->RemoveObserver(this); 201 windows_.other_windows[i]->aura_window()->RemoveObserver(this);
202 mouse_watcher_.reset(); 202 mouse_watcher_.reset();
203 resize_widget_.reset(); 203 resize_widget_.reset();
204 windows_ = ResizeWindows(); 204 windows_ = ResizeWindows();
205 } 205 }
206 206
207 void MultiWindowResizeController::MouseMovedOutOfHost() { 207 void MultiWindowResizeController::MouseMovedOutOfHost() {
208 Hide(); 208 Hide();
209 } 209 }
210 210
211 void MultiWindowResizeController::OnWindowDestroying(WmWindow* window) { 211 void MultiWindowResizeController::OnWindowDestroying(aura::Window* window) {
212 // Have to explicitly reset the WindowResizer, otherwise Hide() does nothing. 212 // Have to explicitly reset the WindowResizer, otherwise Hide() does nothing.
213 window_resizer_.reset(); 213 window_resizer_.reset();
214 Hide(); 214 Hide();
215 } 215 }
216 216
217 MultiWindowResizeController::ResizeWindows 217 MultiWindowResizeController::ResizeWindows
218 MultiWindowResizeController::DetermineWindowsFromScreenPoint( 218 MultiWindowResizeController::DetermineWindowsFromScreenPoint(
219 WmWindow* window) const { 219 WmWindow* window) const {
220 gfx::Point mouse_location( 220 gfx::Point mouse_location(
221 display::Screen::GetScreen()->GetCursorScreenPoint()); 221 display::Screen::GetScreen()->GetCursorScreenPoint());
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 DCHECK(!window_resizer_.get()); 404 DCHECK(!window_resizer_.get());
405 DCHECK(windows_.is_valid()); 405 DCHECK(windows_.is_valid());
406 gfx::Point location_in_parent = 406 gfx::Point location_in_parent =
407 windows_.window2->GetParent()->ConvertPointFromScreen(location_in_screen); 407 windows_.window2->GetParent()->ConvertPointFromScreen(location_in_screen);
408 std::vector<WmWindow*> windows; 408 std::vector<WmWindow*> windows;
409 windows.push_back(windows_.window2); 409 windows.push_back(windows_.window2);
410 DCHECK(windows_.other_windows.empty()); 410 DCHECK(windows_.other_windows.empty());
411 FindWindowsTouching(windows_.window2, windows_.direction, 411 FindWindowsTouching(windows_.window2, windows_.direction,
412 &windows_.other_windows); 412 &windows_.other_windows);
413 for (size_t i = 0; i < windows_.other_windows.size(); ++i) { 413 for (size_t i = 0; i < windows_.other_windows.size(); ++i) {
414 windows_.other_windows[i]->AddObserver(this); 414 windows_.other_windows[i]->aura_window()->AddObserver(this);
415 windows.push_back(windows_.other_windows[i]); 415 windows.push_back(windows_.other_windows[i]);
416 } 416 }
417 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM; 417 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM;
418 wm::WindowState* window_state = windows_.window1->GetWindowState(); 418 wm::WindowState* window_state = windows_.window1->GetWindowState();
419 window_state->CreateDragDetails(location_in_parent, component, 419 window_state->CreateDragDetails(location_in_parent, component,
420 aura::client::WINDOW_MOVE_SOURCE_MOUSE); 420 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
421 window_resizer_.reset(WorkspaceWindowResizer::Create(window_state, windows)); 421 window_resizer_.reset(WorkspaceWindowResizer::Create(window_state, windows));
422 422
423 // Do not hide the resize widget while a drag is active. 423 // Do not hide the resize widget while a drag is active.
424 mouse_watcher_.reset(); 424 mouse_watcher_.reset();
(...skipping 21 matching lines...) Expand all
446 446
447 // Mouse may still be over resizer, if not hide. 447 // Mouse may still be over resizer, if not hide.
448 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); 448 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint();
449 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { 449 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) {
450 Hide(); 450 Hide();
451 } else { 451 } else {
452 // If the mouse is over the resizer we need to remove observers on any of 452 // If the mouse is over the resizer we need to remove observers on any of
453 // the |other_windows|. If we start another resize we'll recalculate the 453 // the |other_windows|. If we start another resize we'll recalculate the
454 // |other_windows| and invoke AddObserver() as necessary. 454 // |other_windows| and invoke AddObserver() as necessary.
455 for (size_t i = 0; i < windows_.other_windows.size(); ++i) 455 for (size_t i = 0; i < windows_.other_windows.size(); ++i)
456 windows_.other_windows[i]->RemoveObserver(this); 456 windows_.other_windows[i]->aura_window()->RemoveObserver(this);
457 windows_.other_windows.clear(); 457 windows_.other_windows.clear();
458 458
459 CreateMouseWatcher(); 459 CreateMouseWatcher();
460 } 460 }
461 } 461 }
462 462
463 void MultiWindowResizeController::CancelResize() { 463 void MultiWindowResizeController::CancelResize() {
464 if (!window_resizer_) 464 if (!window_resizer_)
465 return; // Happens if window was destroyed and we nuked the WindowResizer. 465 return; // Happens if window was destroyed and we nuked the WindowResizer.
466 window_resizer_->RevertDrag(); 466 window_resizer_->RevertDrag();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 bool MultiWindowResizeController::IsOverComponent( 534 bool MultiWindowResizeController::IsOverComponent(
535 WmWindow* window, 535 WmWindow* window,
536 const gfx::Point& location_in_screen, 536 const gfx::Point& location_in_screen,
537 int component) const { 537 int component) const {
538 gfx::Point window_loc = window->ConvertPointFromScreen(location_in_screen); 538 gfx::Point window_loc = window->ConvertPointFromScreen(location_in_screen);
539 return window->GetNonClientComponent(window_loc) == component; 539 return window->GetNonClientComponent(window_loc) == component;
540 } 540 }
541 541
542 } // namespace ash 542 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/workspace/multi_window_resize_controller.h ('k') | ash/common/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698