| OLD | NEW |
| 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_util.h" | 7 #include "ash/screen_util.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/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // MouseWatcherHost implementation for MultiWindowResizeController. Forwards | 123 // MouseWatcherHost implementation for MultiWindowResizeController. Forwards |
| 124 // Contains() to MultiWindowResizeController. | 124 // Contains() to MultiWindowResizeController. |
| 125 class MultiWindowResizeController::ResizeMouseWatcherHost : | 125 class MultiWindowResizeController::ResizeMouseWatcherHost : |
| 126 public views::MouseWatcherHost { | 126 public views::MouseWatcherHost { |
| 127 public: | 127 public: |
| 128 ResizeMouseWatcherHost(MultiWindowResizeController* host) : host_(host) {} | 128 ResizeMouseWatcherHost(MultiWindowResizeController* host) : host_(host) {} |
| 129 | 129 |
| 130 // MouseWatcherHost overrides: | 130 // MouseWatcherHost overrides: |
| 131 bool Contains(const gfx::Point& point_in_screen, | 131 bool Contains(const gfx::Point& point_in_screen, |
| 132 MouseEventType type) override { | 132 MouseEventType type) override { |
| 133 return host_->IsOverWindows(point_in_screen); | 133 return (type == MOUSE_PRESS) |
| 134 ? host_->IsOverResizeWidget(point_in_screen) |
| 135 : host_->IsOverWindows(point_in_screen); |
| 134 } | 136 } |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 MultiWindowResizeController* host_; | 139 MultiWindowResizeController* host_; |
| 138 | 140 |
| 139 DISALLOW_COPY_AND_ASSIGN(ResizeMouseWatcherHost); | 141 DISALLOW_COPY_AND_ASSIGN(ResizeMouseWatcherHost); |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 MultiWindowResizeController::ResizeWindows::ResizeWindows() | 144 MultiWindowResizeController::ResizeWindows::ResizeWindows() |
| 143 : window1(NULL), | 145 : window1(NULL), |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 x = location_in_parent.x() + kResizeWidgetPadding; | 515 x = location_in_parent.x() + kResizeWidgetPadding; |
| 514 if (x + pref.height() / 2 > windows_.window1->bounds().right() && | 516 if (x + pref.height() / 2 > windows_.window1->bounds().right() && |
| 515 x + pref.height() / 2 > windows_.window2->bounds().right()) { | 517 x + pref.height() / 2 > windows_.window2->bounds().right()) { |
| 516 x = location_in_parent.x() - kResizeWidgetPadding - pref.width(); | 518 x = location_in_parent.x() - kResizeWidgetPadding - pref.width(); |
| 517 } | 519 } |
| 518 y = windows_.window1->bounds().bottom() - pref.height() / 2; | 520 y = windows_.window1->bounds().bottom() - pref.height() / 2; |
| 519 } | 521 } |
| 520 return gfx::Rect(x, y, pref.width(), pref.height()); | 522 return gfx::Rect(x, y, pref.width(), pref.height()); |
| 521 } | 523 } |
| 522 | 524 |
| 525 bool MultiWindowResizeController::IsOverResizeWidget( |
| 526 const gfx::Point& location_in_screen) const { |
| 527 return resize_widget_->GetWindowBoundsInScreen().Contains( |
| 528 location_in_screen); |
| 529 } |
| 530 |
| 523 bool MultiWindowResizeController::IsOverWindows( | 531 bool MultiWindowResizeController::IsOverWindows( |
| 524 const gfx::Point& location_in_screen) const { | 532 const gfx::Point& location_in_screen) const { |
| 525 if (resize_widget_->GetWindowBoundsInScreen().Contains(location_in_screen)) | 533 if (IsOverResizeWidget(location_in_screen)) |
| 526 return true; | 534 return true; |
| 527 | 535 |
| 528 if (windows_.direction == TOP_BOTTOM) { | 536 if (windows_.direction == TOP_BOTTOM) { |
| 529 if (!ContainsScreenX(windows_.window1, location_in_screen.x()) || | 537 if (!ContainsScreenX(windows_.window1, location_in_screen.x()) || |
| 530 !ContainsScreenX(windows_.window2, location_in_screen.x())) { | 538 !ContainsScreenX(windows_.window2, location_in_screen.x())) { |
| 531 return false; | 539 return false; |
| 532 } | 540 } |
| 533 } else { | 541 } else { |
| 534 if (!ContainsScreenY(windows_.window1, location_in_screen.y()) || | 542 if (!ContainsScreenY(windows_.window1, location_in_screen.y()) || |
| 535 !ContainsScreenY(windows_.window2, location_in_screen.y())) { | 543 !ContainsScreenY(windows_.window2, location_in_screen.y())) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 565 bool MultiWindowResizeController::IsOverComponent( | 573 bool MultiWindowResizeController::IsOverComponent( |
| 566 aura::Window* window, | 574 aura::Window* window, |
| 567 const gfx::Point& location_in_screen, | 575 const gfx::Point& location_in_screen, |
| 568 int component) const { | 576 int component) const { |
| 569 gfx::Point window_loc(location_in_screen); | 577 gfx::Point window_loc(location_in_screen); |
| 570 ::wm::ConvertPointFromScreen(window, &window_loc); | 578 ::wm::ConvertPointFromScreen(window, &window_loc); |
| 571 return window->delegate()->GetNonClientComponent(window_loc) == component; | 579 return window->delegate()->GetNonClientComponent(window_loc) == component; |
| 572 } | 580 } |
| 573 | 581 |
| 574 } // namespace ash | 582 } // namespace ash |
| OLD | NEW |