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

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

Issue 14297013: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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/workspace/frame_maximize_button.cc ('k') | ash/wm/workspace/workspace_cycler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/multi_window_resize_controller.h" 5 #include "ash/wm/workspace/multi_window_resize_controller.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/coordinate_conversion.h" 10 #include "ash/wm/coordinate_conversion.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 Hide(); 155 Hide();
156 } 156 }
157 157
158 void MultiWindowResizeController::Show(Window* window, 158 void MultiWindowResizeController::Show(Window* window,
159 int component, 159 int component,
160 const gfx::Point& point_in_window) { 160 const gfx::Point& point_in_window) {
161 // When the resize widget is showing we ignore Show() requests. Instead we 161 // When the resize widget is showing we ignore Show() requests. Instead we
162 // only care about mouse movements from MouseWatcher. This is necessary as 162 // only care about mouse movements from MouseWatcher. This is necessary as
163 // WorkspaceEventHandler only sees mouse movements over the windows, not all 163 // WorkspaceEventHandler only sees mouse movements over the windows, not all
164 // windows or over the desktop. 164 // windows or over the desktop.
165 if (resize_widget_.get()) 165 if (resize_widget_)
166 return; 166 return;
167 167
168 ResizeWindows windows(DetermineWindows(window, component, point_in_window)); 168 ResizeWindows windows(DetermineWindows(window, component, point_in_window));
169 if (IsShowing()) { 169 if (IsShowing()) {
170 if (windows_.Equals(windows)) 170 if (windows_.Equals(windows))
171 return; // Over the same windows. 171 return; // Over the same windows.
172 DelayedHide(); 172 DelayedHide();
173 } 173 }
174 174
175 if (!windows.is_valid()) 175 if (!windows.is_valid())
176 return; 176 return;
177 Hide(); 177 Hide();
178 windows_ = windows; 178 windows_ = windows;
179 windows_.window1->AddObserver(this); 179 windows_.window1->AddObserver(this);
180 windows_.window2->AddObserver(this); 180 windows_.window2->AddObserver(this);
181 show_location_in_parent_ = point_in_window; 181 show_location_in_parent_ = point_in_window;
182 Window::ConvertPointToTarget( 182 Window::ConvertPointToTarget(
183 window, window->parent(), &show_location_in_parent_); 183 window, window->parent(), &show_location_in_parent_);
184 if (show_timer_.IsRunning()) 184 if (show_timer_.IsRunning())
185 return; 185 return;
186 show_timer_.Start( 186 show_timer_.Start(
187 FROM_HERE, base::TimeDelta::FromMilliseconds(kShowDelayMS), 187 FROM_HERE, base::TimeDelta::FromMilliseconds(kShowDelayMS),
188 this, &MultiWindowResizeController::ShowIfValidMouseLocation); 188 this, &MultiWindowResizeController::ShowIfValidMouseLocation);
189 } 189 }
190 190
191 void MultiWindowResizeController::Hide() { 191 void MultiWindowResizeController::Hide() {
192 hide_timer_.Stop(); 192 hide_timer_.Stop();
193 if (window_resizer_.get()) 193 if (window_resizer_)
194 return; // Ignore hides while actively resizing. 194 return; // Ignore hides while actively resizing.
195 195
196 if (windows_.window1) { 196 if (windows_.window1) {
197 windows_.window1->RemoveObserver(this); 197 windows_.window1->RemoveObserver(this);
198 windows_.window1 = NULL; 198 windows_.window1 = NULL;
199 } 199 }
200 if (windows_.window2) { 200 if (windows_.window2) {
201 windows_.window2->RemoveObserver(this); 201 windows_.window2->RemoveObserver(this);
202 windows_.window2 = NULL; 202 windows_.window2 = NULL;
203 } 203 }
204 204
205 show_timer_.Stop(); 205 show_timer_.Stop();
206 206
207 if (!resize_widget_.get()) 207 if (!resize_widget_)
208 return; 208 return;
209 209
210 for (size_t i = 0; i < windows_.other_windows.size(); ++i) 210 for (size_t i = 0; i < windows_.other_windows.size(); ++i)
211 windows_.other_windows[i]->RemoveObserver(this); 211 windows_.other_windows[i]->RemoveObserver(this);
212 mouse_watcher_.reset(); 212 mouse_watcher_.reset();
213 resize_widget_.reset(); 213 resize_widget_.reset();
214 windows_ = ResizeWindows(); 214 windows_ = ResizeWindows();
215 } 215 }
216 216
217 void MultiWindowResizeController::MouseMovedOutOfHost() { 217 void MultiWindowResizeController::MouseMovedOutOfHost() {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // If the mouse is over the resizer we need to remove observers on any of 466 // If the mouse is over the resizer we need to remove observers on any of
467 // the |other_windows|. If we start another resize we'll recalculate the 467 // the |other_windows|. If we start another resize we'll recalculate the
468 // |other_windows| and invoke AddObserver() as necessary. 468 // |other_windows| and invoke AddObserver() as necessary.
469 for (size_t i = 0; i < windows_.other_windows.size(); ++i) 469 for (size_t i = 0; i < windows_.other_windows.size(); ++i)
470 windows_.other_windows[i]->RemoveObserver(this); 470 windows_.other_windows[i]->RemoveObserver(this);
471 windows_.other_windows.clear(); 471 windows_.other_windows.clear();
472 } 472 }
473 } 473 }
474 474
475 void MultiWindowResizeController::CancelResize() { 475 void MultiWindowResizeController::CancelResize() {
476 if (!window_resizer_.get()) 476 if (!window_resizer_)
477 return; // Happens if window was destroyed and we nuked the WindowResizer. 477 return; // Happens if window was destroyed and we nuked the WindowResizer.
478 window_resizer_->RevertDrag(); 478 window_resizer_->RevertDrag();
479 window_resizer_.reset(); 479 window_resizer_.reset();
480 Hide(); 480 Hide();
481 } 481 }
482 482
483 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds( 483 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds(
484 const gfx::Point& location_in_parent) const { 484 const gfx::Point& location_in_parent) const {
485 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize(); 485 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize();
486 int x = 0, y = 0; 486 int x = 0, y = 0;
(...skipping 10 matching lines...) Expand all
497 x + pref.height() / 2 > windows_.window2->bounds().right()) { 497 x + pref.height() / 2 > windows_.window2->bounds().right()) {
498 x = location_in_parent.x() - kResizeWidgetPadding - pref.width(); 498 x = location_in_parent.x() - kResizeWidgetPadding - pref.width();
499 } 499 }
500 y = windows_.window1->bounds().bottom() - pref.height() / 2; 500 y = windows_.window1->bounds().bottom() - pref.height() / 2;
501 } 501 }
502 return gfx::Rect(x, y, pref.width(), pref.height()); 502 return gfx::Rect(x, y, pref.width(), pref.height());
503 } 503 }
504 504
505 bool MultiWindowResizeController::IsOverWindows( 505 bool MultiWindowResizeController::IsOverWindows(
506 const gfx::Point& location_in_screen) const { 506 const gfx::Point& location_in_screen) const {
507 if (window_resizer_.get()) 507 if (window_resizer_)
508 return true; // Ignore hides while actively resizing. 508 return true; // Ignore hides while actively resizing.
509 509
510 if (resize_widget_->GetWindowBoundsInScreen().Contains(location_in_screen)) 510 if (resize_widget_->GetWindowBoundsInScreen().Contains(location_in_screen))
511 return true; 511 return true;
512 512
513 int hit1, hit2; 513 int hit1, hit2;
514 if (windows_.direction == TOP_BOTTOM) { 514 if (windows_.direction == TOP_BOTTOM) {
515 hit1 = HTBOTTOM; 515 hit1 = HTBOTTOM;
516 hit2 = HTTOP; 516 hit2 = HTTOP;
517 } else { 517 } else {
(...skipping 14 matching lines...) Expand all
532 532
533 gfx::Point window_loc(location_in_screen); 533 gfx::Point window_loc(location_in_screen);
534 aura::Window::ConvertPointToTarget( 534 aura::Window::ConvertPointToTarget(
535 window->GetRootWindow(), window, &window_loc); 535 window->GetRootWindow(), window, &window_loc);
536 return window->HitTest(window_loc) && 536 return window->HitTest(window_loc) &&
537 window->delegate()->GetNonClientComponent(window_loc) == component; 537 window->delegate()->GetNonClientComponent(window_loc) == component;
538 } 538 }
539 539
540 } // namespace internal 540 } // namespace internal
541 } // namespace ash 541 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/frame_maximize_button.cc ('k') | ash/wm/workspace/workspace_cycler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698