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

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

Issue 121153003: Prevents panels attached to shelf from docking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevents panels attached to shelf from docking (nits) Created 6 years, 11 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
« no previous file with comments | « ash/wm/window_state.cc ('k') | ash/wm/workspace/workspace_window_resizer.h » ('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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 std::vector<aura::Window*> windows; 426 std::vector<aura::Window*> windows;
427 windows.push_back(windows_.window2); 427 windows.push_back(windows_.window2);
428 DCHECK(windows_.other_windows.empty()); 428 DCHECK(windows_.other_windows.empty());
429 FindWindowsTouching(windows_.window2, windows_.direction, 429 FindWindowsTouching(windows_.window2, windows_.direction,
430 &windows_.other_windows); 430 &windows_.other_windows);
431 for (size_t i = 0; i < windows_.other_windows.size(); ++i) { 431 for (size_t i = 0; i < windows_.other_windows.size(); ++i) {
432 windows_.other_windows[i]->AddObserver(this); 432 windows_.other_windows[i]->AddObserver(this);
433 windows.push_back(windows_.other_windows[i]); 433 windows.push_back(windows_.other_windows[i]);
434 } 434 }
435 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM; 435 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM;
436 window_resizer_.reset(WorkspaceWindowResizer::Create( 436 wm::WindowState* window_state = wm::GetWindowState(windows_.window1);
437 windows_.window1, 437 window_state->CreateDragDetails(windows_.window1,
438 location_in_parent, 438 location_in_parent,
439 component, 439 component,
440 aura::client::WINDOW_MOVE_SOURCE_MOUSE, 440 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
441 windows)); 441 window_resizer_.reset(WorkspaceWindowResizer::Create(window_state, windows));
442 } 442 }
443 443
444 void MultiWindowResizeController::Resize(const gfx::Point& location_in_screen, 444 void MultiWindowResizeController::Resize(const gfx::Point& location_in_screen,
445 int event_flags) { 445 int event_flags) {
446 gfx::Point location_in_parent(location_in_screen); 446 gfx::Point location_in_parent(location_in_screen);
447 aura::client::GetScreenPositionClient(windows_.window1->GetRootWindow())-> 447 aura::client::GetScreenPositionClient(windows_.window1->GetRootWindow())->
448 ConvertPointFromScreen(windows_.window1->parent(), &location_in_parent); 448 ConvertPointFromScreen(windows_.window1->parent(), &location_in_parent);
449 window_resizer_->Drag(location_in_parent, event_flags); 449 window_resizer_->Drag(location_in_parent, event_flags);
450 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( 450 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(
451 windows_.window1->parent(), 451 windows_.window1->parent(),
452 CalculateResizeWidgetBounds(location_in_parent)); 452 CalculateResizeWidgetBounds(location_in_parent));
453 453
454 if (windows_.direction == LEFT_RIGHT) 454 if (windows_.direction == LEFT_RIGHT)
455 bounds.set_y(show_bounds_in_screen_.y()); 455 bounds.set_y(show_bounds_in_screen_.y());
456 else 456 else
457 bounds.set_x(show_bounds_in_screen_.x()); 457 bounds.set_x(show_bounds_in_screen_.x());
458 resize_widget_->SetBounds(bounds); 458 resize_widget_->SetBounds(bounds);
459 } 459 }
460 460
461 void MultiWindowResizeController::CompleteResize() { 461 void MultiWindowResizeController::CompleteResize() {
462 window_resizer_->CompleteDrag(); 462 window_resizer_->CompleteDrag();
463 wm::GetWindowState(window_resizer_->GetTarget())->DeleteDragDetails();
463 window_resizer_.reset(); 464 window_resizer_.reset();
464 465
465 // Mouse may still be over resizer, if not hide. 466 // Mouse may still be over resizer, if not hide.
466 gfx::Point screen_loc = Shell::GetScreen()->GetCursorScreenPoint(); 467 gfx::Point screen_loc = Shell::GetScreen()->GetCursorScreenPoint();
467 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { 468 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) {
468 Hide(); 469 Hide();
469 } else { 470 } else {
470 // If the mouse is over the resizer we need to remove observers on any of 471 // If the mouse is over the resizer we need to remove observers on any of
471 // the |other_windows|. If we start another resize we'll recalculate the 472 // the |other_windows|. If we start another resize we'll recalculate the
472 // |other_windows| and invoke AddObserver() as necessary. 473 // |other_windows| and invoke AddObserver() as necessary.
473 for (size_t i = 0; i < windows_.other_windows.size(); ++i) 474 for (size_t i = 0; i < windows_.other_windows.size(); ++i)
474 windows_.other_windows[i]->RemoveObserver(this); 475 windows_.other_windows[i]->RemoveObserver(this);
475 windows_.other_windows.clear(); 476 windows_.other_windows.clear();
476 } 477 }
477 } 478 }
478 479
479 void MultiWindowResizeController::CancelResize() { 480 void MultiWindowResizeController::CancelResize() {
480 if (!window_resizer_) 481 if (!window_resizer_)
481 return; // Happens if window was destroyed and we nuked the WindowResizer. 482 return; // Happens if window was destroyed and we nuked the WindowResizer.
482 window_resizer_->RevertDrag(); 483 window_resizer_->RevertDrag();
484 wm::GetWindowState(window_resizer_->GetTarget())->DeleteDragDetails();
483 window_resizer_.reset(); 485 window_resizer_.reset();
484 Hide(); 486 Hide();
485 } 487 }
486 488
487 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds( 489 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds(
488 const gfx::Point& location_in_parent) const { 490 const gfx::Point& location_in_parent) const {
489 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize(); 491 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize();
490 int x = 0, y = 0; 492 int x = 0, y = 0;
491 if (windows_.direction == LEFT_RIGHT) { 493 if (windows_.direction == LEFT_RIGHT) {
492 x = windows_.window1->bounds().right() - pref.width() / 2; 494 x = windows_.window1->bounds().right() - pref.width() / 2;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 538
537 gfx::Point window_loc(location_in_screen); 539 gfx::Point window_loc(location_in_screen);
538 aura::Window::ConvertPointToTarget( 540 aura::Window::ConvertPointToTarget(
539 window->GetRootWindow(), window, &window_loc); 541 window->GetRootWindow(), window, &window_loc);
540 return window->HitTest(window_loc) && 542 return window->HitTest(window_loc) &&
541 window->delegate()->GetNonClientComponent(window_loc) == component; 543 window->delegate()->GetNonClientComponent(window_loc) == component;
542 } 544 }
543 545
544 } // namespace internal 546 } // namespace internal
545 } // namespace ash 547 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_state.cc ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698