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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 | 1138 |
1139 attached_tabstrip_ = source_tabstrip_; | 1139 attached_tabstrip_ = source_tabstrip_; |
1140 | 1140 |
1141 ResetSelection(GetModel(attached_tabstrip_)); | 1141 ResetSelection(GetModel(attached_tabstrip_)); |
1142 | 1142 |
1143 // If we're not attached to any TabStrip, or attached to some other TabStrip, | 1143 // If we're not attached to any TabStrip, or attached to some other TabStrip, |
1144 // we need to restore the bounds of the original TabStrip's frame, in case | 1144 // we need to restore the bounds of the original TabStrip's frame, in case |
1145 // it has been hidden. | 1145 // it has been hidden. |
1146 if (restore_frame) { | 1146 if (restore_frame) { |
1147 if (!restore_bounds_.IsEmpty()) { | 1147 if (!restore_bounds_.IsEmpty()) { |
1148 #if defined(OS_WIN) | 1148 #if defined(OS_WIN) && !defined(USE_AURA) |
1149 HWND frame_hwnd = source_tabstrip_->GetWidget()->GetNativeView(); | 1149 HWND frame_hwnd = source_tabstrip_->GetWidget()->GetNativeView(); |
1150 MoveWindow(frame_hwnd, restore_bounds_.x(), restore_bounds_.y(), | 1150 MoveWindow(frame_hwnd, restore_bounds_.x(), restore_bounds_.y(), |
1151 restore_bounds_.width(), restore_bounds_.height(), TRUE); | 1151 restore_bounds_.width(), restore_bounds_.height(), TRUE); |
1152 #else | 1152 #else |
1153 NOTIMPLEMENTED(); | 1153 NOTIMPLEMENTED(); |
1154 #endif | 1154 #endif |
1155 } | 1155 } |
1156 } | 1156 } |
1157 } | 1157 } |
1158 | 1158 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1348 |
1349 gfx::Rect DraggedTabController::GetViewScreenBounds(views::View* view) const { | 1349 gfx::Rect DraggedTabController::GetViewScreenBounds(views::View* view) const { |
1350 gfx::Point view_topleft; | 1350 gfx::Point view_topleft; |
1351 views::View::ConvertPointToScreen(view, &view_topleft); | 1351 views::View::ConvertPointToScreen(view, &view_topleft); |
1352 gfx::Rect view_screen_bounds = view->GetLocalBounds(); | 1352 gfx::Rect view_screen_bounds = view->GetLocalBounds(); |
1353 view_screen_bounds.Offset(view_topleft.x(), view_topleft.y()); | 1353 view_screen_bounds.Offset(view_topleft.x(), view_topleft.y()); |
1354 return view_screen_bounds; | 1354 return view_screen_bounds; |
1355 } | 1355 } |
1356 | 1356 |
1357 void DraggedTabController::HideFrame() { | 1357 void DraggedTabController::HideFrame() { |
1358 #if defined(OS_WIN) | 1358 #if defined(OS_WIN) && !defined(USE_AURA) |
1359 // We don't actually hide the window, rather we just move it way off-screen. | 1359 // We don't actually hide the window, rather we just move it way off-screen. |
1360 // If we actually hide it, we stop receiving drag events. | 1360 // If we actually hide it, we stop receiving drag events. |
1361 HWND frame_hwnd = source_tabstrip_->GetWidget()->GetNativeView(); | 1361 HWND frame_hwnd = source_tabstrip_->GetWidget()->GetNativeView(); |
1362 RECT wr; | 1362 RECT wr; |
1363 GetWindowRect(frame_hwnd, &wr); | 1363 GetWindowRect(frame_hwnd, &wr); |
1364 MoveWindow(frame_hwnd, 0xFFFF, 0xFFFF, wr.right - wr.left, | 1364 MoveWindow(frame_hwnd, 0xFFFF, 0xFFFF, wr.right - wr.left, |
1365 wr.bottom - wr.top, TRUE); | 1365 wr.bottom - wr.top, TRUE); |
1366 | 1366 |
1367 // We also save the bounds of the window prior to it being moved, so that if | 1367 // We also save the bounds of the window prior to it being moved, so that if |
1368 // the drag session is aborted we can restore them. | 1368 // the drag session is aborted we can restore them. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 // If we're going to dock to another window, bring it to the front. | 1401 // If we're going to dock to another window, bring it to the front. |
1402 gfx::NativeWindow window = dock_info_.window(); | 1402 gfx::NativeWindow window = dock_info_.window(); |
1403 if (!window) { | 1403 if (!window) { |
1404 gfx::NativeView dragged_view = view_->GetWidget()->GetNativeView(); | 1404 gfx::NativeView dragged_view = view_->GetWidget()->GetNativeView(); |
1405 dock_windows_.insert(dragged_view); | 1405 dock_windows_.insert(dragged_view); |
1406 window = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(), | 1406 window = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(), |
1407 dock_windows_); | 1407 dock_windows_); |
1408 dock_windows_.erase(dragged_view); | 1408 dock_windows_.erase(dragged_view); |
1409 } | 1409 } |
1410 if (window) { | 1410 if (window) { |
1411 #if defined(OS_WIN) | 1411 #if defined(OS_WIN) && !defined(USE_AURA) |
1412 // Move the window to the front. | 1412 // Move the window to the front. |
1413 SetWindowPos(window, HWND_TOP, 0, 0, 0, 0, | 1413 SetWindowPos(window, HWND_TOP, 0, 0, 0, 0, |
1414 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); | 1414 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
1415 | 1415 |
1416 // The previous call made the window appear on top of the dragged window, | 1416 // The previous call made the window appear on top of the dragged window, |
1417 // move the dragged window to the front. | 1417 // move the dragged window to the front. |
1418 SetWindowPos(view_->GetWidget()->GetNativeView(), HWND_TOP, 0, 0, 0, 0, | 1418 SetWindowPos(view_->GetWidget()->GetNativeView(), HWND_TOP, 0, 0, 0, 0, |
1419 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); | 1419 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
1420 #else | 1420 #else |
1421 NOTIMPLEMENTED(); | 1421 NOTIMPLEMENTED(); |
1422 #endif | 1422 #endif |
1423 } | 1423 } |
1424 } | 1424 } |
1425 | 1425 |
1426 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { | 1426 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { |
1427 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> | 1427 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> |
1428 model(); | 1428 model(); |
1429 } | 1429 } |
1430 | 1430 |
1431 bool DraggedTabController::AreTabsConsecutive() { | 1431 bool DraggedTabController::AreTabsConsecutive() { |
1432 for (size_t i = 1; i < drag_data_.size(); ++i) { | 1432 for (size_t i = 1; i < drag_data_.size(); ++i) { |
1433 if (drag_data_[i - 1].source_model_index + 1 != | 1433 if (drag_data_[i - 1].source_model_index + 1 != |
1434 drag_data_[i].source_model_index) { | 1434 drag_data_[i].source_model_index) { |
1435 return false; | 1435 return false; |
1436 } | 1436 } |
1437 } | 1437 } |
1438 return true; | 1438 return true; |
1439 } | 1439 } |
OLD | NEW |