| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #if defined(USE_ASH) | 53 #if defined(USE_ASH) |
| 54 #include "ash/accelerators/accelerator_commands.h" | 54 #include "ash/accelerators/accelerator_commands.h" |
| 55 #include "ash/wm/coordinate_conversion.h" | 55 #include "ash/wm/coordinate_conversion.h" |
| 56 #include "ash/wm/window_state.h" | 56 #include "ash/wm/window_state.h" |
| 57 #include "ui/aura/env.h" | 57 #include "ui/aura/env.h" |
| 58 #include "ui/aura/root_window.h" | 58 #include "ui/aura/root_window.h" |
| 59 #include "ui/aura/window.h" | 59 #include "ui/aura/window.h" |
| 60 #include "ui/events/gestures/gesture_recognizer.h" | 60 #include "ui/events/gestures/gesture_recognizer.h" |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 #if defined(OS_WIN) && defined(USE_AURA) | 63 #if defined(OS_WIN) |
| 64 #include "ui/aura/window.h" | 64 #include "ui/aura/window.h" |
| 65 #include "ui/events/gestures/gesture_recognizer.h" | 65 #include "ui/events/gestures/gesture_recognizer.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 using base::UserMetricsAction; | 68 using base::UserMetricsAction; |
| 69 using content::OpenURLParams; | 69 using content::OpenURLParams; |
| 70 using content::WebContents; | 70 using content::WebContents; |
| 71 | 71 |
| 72 static const int kHorizontalMoveThreshold = 16; // Pixels. | 72 static const int kHorizontalMoveThreshold = 16; // Pixels. |
| 73 | 73 |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 attached_tabstrip_->ReleaseDragController(); | 951 attached_tabstrip_->ReleaseDragController(); |
| 952 target_tabstrip->OwnDragController(this); | 952 target_tabstrip->OwnDragController(this); |
| 953 // Disable animations so that we don't see a close animation on aero. | 953 // Disable animations so that we don't see a close animation on aero. |
| 954 browser_widget->SetVisibilityChangedAnimationsEnabled(false); | 954 browser_widget->SetVisibilityChangedAnimationsEnabled(false); |
| 955 // For aura we can't release capture, otherwise it'll cancel a gesture. | 955 // For aura we can't release capture, otherwise it'll cancel a gesture. |
| 956 // Instead we have to directly change capture. | 956 // Instead we have to directly change capture. |
| 957 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) | 957 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) |
| 958 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); | 958 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); |
| 959 else | 959 else |
| 960 browser_widget->ReleaseCapture(); | 960 browser_widget->ReleaseCapture(); |
| 961 #if defined(OS_WIN) && defined(USE_AURA) | 961 #if defined(OS_WIN) |
| 962 // The Gesture recognizer does not work well currently when capture changes | 962 // The Gesture recognizer does not work well currently when capture changes |
| 963 // while a touch gesture is in progress. So we need to manually transfer | 963 // while a touch gesture is in progress. So we need to manually transfer |
| 964 // gesture sequence and the GR's touch events queue to the new window. This | 964 // gesture sequence and the GR's touch events queue to the new window. This |
| 965 // should really be done somewhere in capture change code and or inside the | 965 // should really be done somewhere in capture change code and or inside the |
| 966 // GR. But we currently do not have a consistent way for doing it that would | 966 // GR. But we currently do not have a consistent way for doing it that would |
| 967 // work in all cases. Hence this hack. | 967 // work in all cases. Hence this hack. |
| 968 ui::GestureRecognizer::Get()->TransferEventsTo( | 968 ui::GestureRecognizer::Get()->TransferEventsTo( |
| 969 browser_widget->GetNativeView(), | 969 browser_widget->GetNativeView(), |
| 970 target_tabstrip->GetWidget()->GetNativeView()); | 970 target_tabstrip->GetWidget()->GetNativeView()); |
| 971 #endif | 971 #endif |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 return; | 1452 return; |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 const int last_tabstrip_width = attached_tabstrip_->tab_area_width(); | 1455 const int last_tabstrip_width = attached_tabstrip_->tab_area_width(); |
| 1456 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); | 1456 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); |
| 1457 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); | 1457 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); |
| 1458 | 1458 |
| 1459 gfx::Vector2d drag_offset; | 1459 gfx::Vector2d drag_offset; |
| 1460 Browser* browser = CreateBrowserForDrag( | 1460 Browser* browser = CreateBrowserForDrag( |
| 1461 attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds); | 1461 attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds); |
| 1462 #if defined(OS_WIN) && defined(USE_AURA) | 1462 #if defined(OS_WIN) |
| 1463 gfx::NativeView attached_native_view = | 1463 gfx::NativeView attached_native_view = |
| 1464 attached_tabstrip_->GetWidget()->GetNativeView(); | 1464 attached_tabstrip_->GetWidget()->GetNativeView(); |
| 1465 #endif | 1465 #endif |
| 1466 Detach(host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH ? | 1466 Detach(host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH ? |
| 1467 DONT_RELEASE_CAPTURE : RELEASE_CAPTURE); | 1467 DONT_RELEASE_CAPTURE : RELEASE_CAPTURE); |
| 1468 BrowserView* dragged_browser_view = | 1468 BrowserView* dragged_browser_view = |
| 1469 BrowserView::GetBrowserViewForBrowser(browser); | 1469 BrowserView::GetBrowserViewForBrowser(browser); |
| 1470 views::Widget* dragged_widget = dragged_browser_view->GetWidget(); | 1470 views::Widget* dragged_widget = dragged_browser_view->GetWidget(); |
| 1471 #if defined(OS_WIN) && defined(USE_AURA) | 1471 #if defined(OS_WIN) |
| 1472 // The Gesture recognizer does not work well currently when capture changes | 1472 // The Gesture recognizer does not work well currently when capture changes |
| 1473 // while a touch gesture is in progress. So we need to manually transfer | 1473 // while a touch gesture is in progress. So we need to manually transfer |
| 1474 // gesture sequence and the GR's touch events queue to the new window. This | 1474 // gesture sequence and the GR's touch events queue to the new window. This |
| 1475 // should really be done somewhere in capture change code and or inside the | 1475 // should really be done somewhere in capture change code and or inside the |
| 1476 // GR. But we currently do not have a consistent way for doing it that would | 1476 // GR. But we currently do not have a consistent way for doing it that would |
| 1477 // work in all cases. Hence this hack. | 1477 // work in all cases. Hence this hack. |
| 1478 ui::GestureRecognizer::Get()->TransferEventsTo( | 1478 ui::GestureRecognizer::Get()->TransferEventsTo( |
| 1479 attached_native_view, | 1479 attached_native_view, |
| 1480 dragged_widget->GetNativeView()); | 1480 dragged_widget->GetNativeView()); |
| 1481 #endif | 1481 #endif |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 gfx::Vector2d TabDragController::GetWindowOffset( | 2343 gfx::Vector2d TabDragController::GetWindowOffset( |
| 2344 const gfx::Point& point_in_screen) { | 2344 const gfx::Point& point_in_screen) { |
| 2345 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2345 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
| 2346 attached_tabstrip_ : source_tabstrip_; | 2346 attached_tabstrip_ : source_tabstrip_; |
| 2347 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2347 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
| 2348 | 2348 |
| 2349 gfx::Point point = point_in_screen; | 2349 gfx::Point point = point_in_screen; |
| 2350 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2350 views::View::ConvertPointFromScreen(toplevel_view, &point); |
| 2351 return point.OffsetFromOrigin(); | 2351 return point.OffsetFromOrigin(); |
| 2352 } | 2352 } |
| OLD | NEW |