| 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/gtk/tabs/dragged_tab_controller_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Need to delete the dragged tab here manually _before_ we reset the dragged | 78 // Need to delete the dragged tab here manually _before_ we reset the dragged |
| 79 // contents to NULL, otherwise if the view is animating to its destination | 79 // contents to NULL, otherwise if the view is animating to its destination |
| 80 // bounds, it won't be able to clean up properly since its cleanup routine | 80 // bounds, it won't be able to clean up properly since its cleanup routine |
| 81 // uses GetIndexForDraggedContents, which will be invalid. | 81 // uses GetIndexForDraggedContents, which will be invalid. |
| 82 CleanUpDraggedTabs(); | 82 CleanUpDraggedTabs(); |
| 83 dragged_view_.reset(); | 83 dragged_view_.reset(); |
| 84 drag_data_.reset(); | 84 drag_data_.reset(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void DraggedTabControllerGtk::CaptureDragInfo(const gfx::Point& mouse_offset) { | 87 void DraggedTabControllerGtk::CaptureDragInfo(const gfx::Point& mouse_offset) { |
| 88 start_screen_point_ = gfx::Screen::GetCursorScreenPoint(); | 88 start_screen_point_ = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); |
| 89 mouse_offset_ = mouse_offset; | 89 mouse_offset_ = mouse_offset; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DraggedTabControllerGtk::Drag() { | 92 void DraggedTabControllerGtk::Drag() { |
| 93 if (!drag_data_->GetSourceTabData()->tab_ || | 93 if (!drag_data_->GetSourceTabData()->tab_ || |
| 94 !drag_data_->GetSourceTabContents() || | 94 !drag_data_->GetSourceTabContents() || |
| 95 !drag_data_->GetSourceWebContents()) { | 95 !drag_data_->GetSourceWebContents()) { |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 drag_data_->get(i)->original_delegate_ = NULL; | 241 drag_data_->get(i)->original_delegate_ = NULL; |
| 242 EndDragImpl(TAB_DESTROYED); | 242 EndDragImpl(TAB_DESTROYED); |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 // If we get here it means we got notification for a tab we don't know about. | 246 // If we get here it means we got notification for a tab we don't know about. |
| 247 NOTREACHED(); | 247 NOTREACHED(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 gfx::Point DraggedTabControllerGtk::GetWindowCreatePoint() const { | 250 gfx::Point DraggedTabControllerGtk::GetWindowCreatePoint() const { |
| 251 gfx::Point creation_point = gfx::Screen::GetCursorScreenPoint(); | 251 gfx::Point creation_point = |
| 252 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); |
| 252 gfx::Point distance_from_origin = | 253 gfx::Point distance_from_origin = |
| 253 dragged_view_->GetDistanceFromTabStripOriginToMousePointer(); | 254 dragged_view_->GetDistanceFromTabStripOriginToMousePointer(); |
| 254 // TODO(dpapad): offset also because of tabstrip origin being different than | 255 // TODO(dpapad): offset also because of tabstrip origin being different than |
| 255 // window origin. | 256 // window origin. |
| 256 creation_point.Offset(-distance_from_origin.x(), -distance_from_origin.y()); | 257 creation_point.Offset(-distance_from_origin.x(), -distance_from_origin.y()); |
| 257 return creation_point; | 258 return creation_point; |
| 258 } | 259 } |
| 259 | 260 |
| 260 void DraggedTabControllerGtk::ContinueDragging() { | 261 void DraggedTabControllerGtk::ContinueDragging() { |
| 261 // TODO(jhawkins): We don't handle the situation where the last tab is dragged | 262 // TODO(jhawkins): We don't handle the situation where the last tab is dragged |
| 262 // out of a window, so we'll just go with the way Windows handles dragging for | 263 // out of a window, so we'll just go with the way Windows handles dragging for |
| 263 // now. | 264 // now. |
| 264 gfx::Point screen_point = gfx::Screen::GetCursorScreenPoint(); | 265 gfx::Point screen_point = |
| 266 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); |
| 265 | 267 |
| 266 // Determine whether or not we have dragged over a compatible TabStrip in | 268 // Determine whether or not we have dragged over a compatible TabStrip in |
| 267 // another browser window. If we have, we should attach to it and start | 269 // another browser window. If we have, we should attach to it and start |
| 268 // dragging within it. | 270 // dragging within it. |
| 269 TabStripGtk* target_tabstrip = GetTabStripForPoint(screen_point); | 271 TabStripGtk* target_tabstrip = GetTabStripForPoint(screen_point); |
| 270 if (target_tabstrip != attached_tabstrip_) { | 272 if (target_tabstrip != attached_tabstrip_) { |
| 271 // Make sure we're fully detached from whatever TabStrip we're attached to | 273 // Make sure we're fully detached from whatever TabStrip we're attached to |
| 272 // (if any). | 274 // (if any). |
| 273 if (attached_tabstrip_) | 275 if (attached_tabstrip_) |
| 274 Detach(); | 276 Detach(); |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 source_tabstrip_->DestroyDragController(); | 871 source_tabstrip_->DestroyDragController(); |
| 870 } | 872 } |
| 871 | 873 |
| 872 void DraggedTabControllerGtk::BringWindowUnderMouseToFront() { | 874 void DraggedTabControllerGtk::BringWindowUnderMouseToFront() { |
| 873 // If we're going to dock to another window, bring it to the front. | 875 // If we're going to dock to another window, bring it to the front. |
| 874 gfx::NativeWindow window = dock_info_.window(); | 876 gfx::NativeWindow window = dock_info_.window(); |
| 875 if (!window) { | 877 if (!window) { |
| 876 gfx::NativeView dragged_tab = dragged_view_->widget(); | 878 gfx::NativeView dragged_tab = dragged_view_->widget(); |
| 877 dock_windows_.insert(dragged_tab); | 879 dock_windows_.insert(dragged_tab); |
| 878 window = DockInfo::GetLocalProcessWindowAtPoint( | 880 window = DockInfo::GetLocalProcessWindowAtPoint( |
| 879 gfx::Screen::GetCursorScreenPoint(), dock_windows_); | 881 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(), |
| 882 dock_windows_); |
| 880 dock_windows_.erase(dragged_tab); | 883 dock_windows_.erase(dragged_tab); |
| 881 } | 884 } |
| 882 | 885 |
| 883 if (window) | 886 if (window) |
| 884 gtk_window_present(GTK_WINDOW(window)); | 887 gtk_window_present(GTK_WINDOW(window)); |
| 885 } | 888 } |
| 886 | 889 |
| 887 bool DraggedTabControllerGtk::AreTabsConsecutive() { | 890 bool DraggedTabControllerGtk::AreTabsConsecutive() { |
| 888 for (size_t i = 1; i < drag_data_->size(); ++i) { | 891 for (size_t i = 1; i < drag_data_->size(); ++i) { |
| 889 if (drag_data_->get(i - 1)->source_model_index_ + 1 != | 892 if (drag_data_->get(i - 1)->source_model_index_ + 1 != |
| 890 drag_data_->get(i)->source_model_index_) { | 893 drag_data_->get(i)->source_model_index_) { |
| 891 return false; | 894 return false; |
| 892 } | 895 } |
| 893 } | 896 } |
| 894 return true; | 897 return true; |
| 895 } | 898 } |
| OLD | NEW |