OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/tabs/dragged_tab_controller.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/notification_details.h" | 27 #include "chrome/common/notification_details.h" |
28 #include "chrome/common/notification_source.h" | 28 #include "chrome/common/notification_source.h" |
29 #include "gfx/canvas_skia.h" | 29 #include "gfx/canvas_skia.h" |
30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
31 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
32 #include "ui/base/animation/animation.h" | 32 #include "ui/base/animation/animation.h" |
33 #include "ui/base/animation/animation_delegate.h" | 33 #include "ui/base/animation/animation_delegate.h" |
34 #include "ui/base/animation/slide_animation.h" | 34 #include "ui/base/animation/slide_animation.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "views/event.h" | 36 #include "views/event.h" |
| 37 #include "views/screen.h" |
37 #include "views/widget/root_view.h" | 38 #include "views/widget/root_view.h" |
38 #include "views/widget/widget.h" | 39 #include "views/widget/widget.h" |
39 #include "views/window/window.h" | 40 #include "views/window/window.h" |
40 | 41 |
41 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
42 #include "views/widget/widget_win.h" | 43 #include "views/widget/widget_win.h" |
43 #endif | 44 #endif |
44 | 45 |
45 #if defined(OS_LINUX) | 46 #if defined(OS_LINUX) |
46 #include <gdk/gdk.h> // NOLINT | 47 #include <gdk/gdk.h> // NOLINT |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 window_create_point_.Offset(mouse_offset_.x(), mouse_offset_.y()); | 531 window_create_point_.Offset(mouse_offset_.x(), mouse_offset_.y()); |
531 } | 532 } |
532 | 533 |
533 gfx::Point DraggedTabController::GetWindowCreatePoint() const { | 534 gfx::Point DraggedTabController::GetWindowCreatePoint() const { |
534 gfx::Point cursor_point = GetCursorScreenPoint(); | 535 gfx::Point cursor_point = GetCursorScreenPoint(); |
535 if (dock_info_.type() != DockInfo::NONE && dock_info_.in_enable_area()) { | 536 if (dock_info_.type() != DockInfo::NONE && dock_info_.in_enable_area()) { |
536 // If we're going to dock, we need to return the exact coordinate, | 537 // If we're going to dock, we need to return the exact coordinate, |
537 // otherwise we may attempt to maximize on the wrong monitor. | 538 // otherwise we may attempt to maximize on the wrong monitor. |
538 return cursor_point; | 539 return cursor_point; |
539 } | 540 } |
| 541 // If the cursor is outside the monitor area, move it inside. For example, |
| 542 // dropping a tab onto the task bar on Windows produces this situation. |
| 543 gfx::Rect work_area = views::Screen::GetMonitorWorkAreaNearestPoint( |
| 544 cursor_point); |
| 545 if (!work_area.IsEmpty()) { |
| 546 if (cursor_point.x() < work_area.x()) |
| 547 cursor_point.set_x(work_area.x()); |
| 548 else if (cursor_point.x() > work_area.right()) |
| 549 cursor_point.set_x(work_area.right()); |
| 550 if (cursor_point.y() < work_area.y()) |
| 551 cursor_point.set_y(work_area.y()); |
| 552 else if (cursor_point.y() > work_area.bottom()) |
| 553 cursor_point.set_y(work_area.bottom()); |
| 554 } |
540 return gfx::Point(cursor_point.x() - window_create_point_.x(), | 555 return gfx::Point(cursor_point.x() - window_create_point_.x(), |
541 cursor_point.y() - window_create_point_.y()); | 556 cursor_point.y() - window_create_point_.y()); |
542 } | 557 } |
543 | 558 |
544 void DraggedTabController::UpdateDockInfo(const gfx::Point& screen_point) { | 559 void DraggedTabController::UpdateDockInfo(const gfx::Point& screen_point) { |
545 // Update the DockInfo for the current mouse coordinates. | 560 // Update the DockInfo for the current mouse coordinates. |
546 DockInfo dock_info = GetDockInfoAtPoint(screen_point); | 561 DockInfo dock_info = GetDockInfoAtPoint(screen_point); |
547 if (source_tabstrip_->type() == BaseTabStrip::VERTICAL_TAB_STRIP && | 562 if (source_tabstrip_->type() == BaseTabStrip::VERTICAL_TAB_STRIP && |
548 ((dock_info.type() == DockInfo::LEFT_OF_WINDOW && | 563 ((dock_info.type() == DockInfo::LEFT_OF_WINDOW && |
549 !base::i18n::IsRTL()) || | 564 !base::i18n::IsRTL()) || |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 #else | 1351 #else |
1337 NOTIMPLEMENTED(); | 1352 NOTIMPLEMENTED(); |
1338 #endif | 1353 #endif |
1339 } | 1354 } |
1340 } | 1355 } |
1341 | 1356 |
1342 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { | 1357 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { |
1343 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> | 1358 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> |
1344 model(); | 1359 model(); |
1345 } | 1360 } |
OLD | NEW |