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 "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 22 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
23 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" | 23 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" |
24 #include "chrome/browser/ui/views/tabs/tab.h" | 24 #include "chrome/browser/ui/views/tabs/tab.h" |
25 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
26 #include "chrome/browser/ui/views/tabs/window_finder.h" | 26 #include "chrome/browser/ui/views/tabs/window_finder.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
29 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
31 #include "extensions/browser/extension_function_dispatcher.h" | 31 #include "extensions/browser/extension_function_dispatcher.h" |
| 32 #include "ui/display/screen.h" |
32 #include "ui/events/event_constants.h" | 33 #include "ui/events/event_constants.h" |
33 #include "ui/events/gestures/gesture_recognizer.h" | 34 #include "ui/events/gestures/gesture_recognizer.h" |
34 #include "ui/gfx/geometry/point_conversions.h" | 35 #include "ui/gfx/geometry/point_conversions.h" |
35 #include "ui/gfx/screen.h" | |
36 #include "ui/views/event_monitor.h" | 36 #include "ui/views/event_monitor.h" |
37 #include "ui/views/focus/view_storage.h" | 37 #include "ui/views/focus/view_storage.h" |
38 #include "ui/views/widget/root_view.h" | 38 #include "ui/views/widget/root_view.h" |
39 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
40 | 40 |
41 #if defined(USE_ASH) | 41 #if defined(USE_ASH) |
42 #include "ash/accelerators/accelerator_commands.h" | 42 #include "ash/accelerators/accelerator_commands.h" |
43 #include "ash/shell.h" | 43 #include "ash/shell.h" |
44 #include "ash/wm/common/window_state.h" | 44 #include "ash/wm/common/window_state.h" |
45 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 45 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 views::View::ConvertPointToWidget(first_tab, &first_source_tab_point_); | 450 views::View::ConvertPointToWidget(first_tab, &first_source_tab_point_); |
451 window_create_point_ = first_source_tab_point_; | 451 window_create_point_ = first_source_tab_point_; |
452 window_create_point_.Offset(mouse_offset_.x(), mouse_offset_.y()); | 452 window_create_point_.Offset(mouse_offset_.x(), mouse_offset_.y()); |
453 } | 453 } |
454 | 454 |
455 gfx::Point TabDragController::GetWindowCreatePoint( | 455 gfx::Point TabDragController::GetWindowCreatePoint( |
456 const gfx::Point& origin) const { | 456 const gfx::Point& origin) const { |
457 // If the cursor is outside the monitor area, move it inside. For example, | 457 // If the cursor is outside the monitor area, move it inside. For example, |
458 // dropping a tab onto the task bar on Windows produces this situation. | 458 // dropping a tab onto the task bar on Windows produces this situation. |
459 gfx::Rect work_area = | 459 gfx::Rect work_area = |
460 gfx::Screen::GetScreen()->GetDisplayNearestPoint(origin).work_area(); | 460 display::Screen::GetScreen()->GetDisplayNearestPoint(origin).work_area(); |
461 gfx::Point create_point(origin); | 461 gfx::Point create_point(origin); |
462 if (!work_area.IsEmpty()) { | 462 if (!work_area.IsEmpty()) { |
463 if (create_point.x() < work_area.x()) | 463 if (create_point.x() < work_area.x()) |
464 create_point.set_x(work_area.x()); | 464 create_point.set_x(work_area.x()); |
465 else if (create_point.x() > work_area.right()) | 465 else if (create_point.x() > work_area.right()) |
466 create_point.set_x(work_area.right()); | 466 create_point.set_x(work_area.right()); |
467 if (create_point.y() < work_area.y()) | 467 if (create_point.y() < work_area.y()) |
468 create_point.set_y(work_area.y()); | 468 create_point.set_y(work_area.y()); |
469 else if (create_point.y() > work_area.bottom()) | 469 else if (create_point.y() > work_area.bottom()) |
470 create_point.set_y(work_area.bottom()); | 470 create_point.set_y(work_area.bottom()); |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 } | 1631 } |
1632 | 1632 |
1633 gfx::Rect TabDragController::CalculateDraggedBrowserBounds( | 1633 gfx::Rect TabDragController::CalculateDraggedBrowserBounds( |
1634 TabStrip* source, | 1634 TabStrip* source, |
1635 const gfx::Point& point_in_screen, | 1635 const gfx::Point& point_in_screen, |
1636 std::vector<gfx::Rect>* drag_bounds) { | 1636 std::vector<gfx::Rect>* drag_bounds) { |
1637 gfx::Point center(0, source->height() / 2); | 1637 gfx::Point center(0, source->height() / 2); |
1638 views::View::ConvertPointToWidget(source, ¢er); | 1638 views::View::ConvertPointToWidget(source, ¢er); |
1639 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); | 1639 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); |
1640 | 1640 |
1641 gfx::Rect work_area = gfx::Screen::GetScreen() | 1641 gfx::Rect work_area = display::Screen::GetScreen() |
1642 ->GetDisplayNearestPoint(last_point_in_screen_) | 1642 ->GetDisplayNearestPoint(last_point_in_screen_) |
1643 .work_area(); | 1643 .work_area(); |
1644 if (new_bounds.size().width() >= work_area.size().width() && | 1644 if (new_bounds.size().width() >= work_area.size().width() && |
1645 new_bounds.size().height() >= work_area.size().height()) { | 1645 new_bounds.size().height() >= work_area.size().height()) { |
1646 new_bounds = work_area; | 1646 new_bounds = work_area; |
1647 new_bounds.Inset(kMaximizedWindowInset, kMaximizedWindowInset, | 1647 new_bounds.Inset(kMaximizedWindowInset, kMaximizedWindowInset, |
1648 kMaximizedWindowInset, kMaximizedWindowInset); | 1648 kMaximizedWindowInset, kMaximizedWindowInset); |
1649 // Behave as if the |source| was maximized at the start of a drag since this | 1649 // Behave as if the |source| was maximized at the start of a drag since this |
1650 // is consistent with a browser window creation logic in case of windows | 1650 // is consistent with a browser window creation logic in case of windows |
1651 // that are as large as the |work_area|. | 1651 // that are as large as the |work_area|. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 gfx::PointF touch_point_f; | 1764 gfx::PointF touch_point_f; |
1765 bool got_touch_point = ui::GestureRecognizer::Get()-> | 1765 bool got_touch_point = ui::GestureRecognizer::Get()-> |
1766 GetLastTouchPointForTarget(widget_window, &touch_point_f); | 1766 GetLastTouchPointForTarget(widget_window, &touch_point_f); |
1767 CHECK(got_touch_point); | 1767 CHECK(got_touch_point); |
1768 gfx::Point touch_point = gfx::ToFlooredPoint(touch_point_f); | 1768 gfx::Point touch_point = gfx::ToFlooredPoint(touch_point_f); |
1769 wm::ConvertPointToScreen(widget_window->GetRootWindow(), &touch_point); | 1769 wm::ConvertPointToScreen(widget_window->GetRootWindow(), &touch_point); |
1770 return touch_point; | 1770 return touch_point; |
1771 } | 1771 } |
1772 #endif | 1772 #endif |
1773 | 1773 |
1774 return gfx::Screen::GetScreen()->GetCursorScreenPoint(); | 1774 return display::Screen::GetScreen()->GetCursorScreenPoint(); |
1775 } | 1775 } |
1776 | 1776 |
1777 gfx::Vector2d TabDragController::GetWindowOffset( | 1777 gfx::Vector2d TabDragController::GetWindowOffset( |
1778 const gfx::Point& point_in_screen) { | 1778 const gfx::Point& point_in_screen) { |
1779 TabStrip* owning_tabstrip = attached_tabstrip_ ? | 1779 TabStrip* owning_tabstrip = attached_tabstrip_ ? |
1780 attached_tabstrip_ : source_tabstrip_; | 1780 attached_tabstrip_ : source_tabstrip_; |
1781 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 1781 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
1782 | 1782 |
1783 gfx::Point point = point_in_screen; | 1783 gfx::Point point = point_in_screen; |
1784 views::View::ConvertPointFromScreen(toplevel_view, &point); | 1784 views::View::ConvertPointFromScreen(toplevel_view, &point); |
(...skipping 19 matching lines...) Expand all Loading... |
1804 // TODO(pkotwicz): Fix this properly (crbug.com/358482) | 1804 // TODO(pkotwicz): Fix this properly (crbug.com/358482) |
1805 for (auto* browser : *BrowserList::GetInstance()) { | 1805 for (auto* browser : *BrowserList::GetInstance()) { |
1806 if (browser->tab_strip_model()->empty()) | 1806 if (browser->tab_strip_model()->empty()) |
1807 exclude.insert(browser->window()->GetNativeWindow()); | 1807 exclude.insert(browser->window()->GetNativeWindow()); |
1808 } | 1808 } |
1809 #endif | 1809 #endif |
1810 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); | 1810 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); |
1811 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); | 1811 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); |
1812 return ref ? Liveness::ALIVE : Liveness::DELETED; | 1812 return ref ? Liveness::ALIVE : Liveness::DELETED; |
1813 } | 1813 } |
OLD | NEW |