Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 2467053002: Revert of Linux Aura: Make tab dragging great again (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/base/x/x11_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 // On windows SaveFocus() may trigger a capture lost, which destroys us. 373 // On windows SaveFocus() may trigger a capture lost, which destroys us.
374 { 374 {
375 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); 375 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr());
376 SaveFocus(); 376 SaveFocus();
377 if (!ref) 377 if (!ref)
378 return; 378 return;
379 } 379 }
380 started_drag_ = true; 380 started_drag_ = true;
381 Attach(source_tabstrip_, gfx::Point()); 381 Attach(source_tabstrip_, gfx::Point());
382 gfx::Point drag_point_in_screen = point_in_screen;
383 if (static_cast<int>(drag_data_.size()) == 382 if (static_cast<int>(drag_data_.size()) ==
384 GetModel(source_tabstrip_)->count()) { 383 GetModel(source_tabstrip_)->count()) {
385 if (was_source_maximized_ || was_source_fullscreen_) { 384 if (was_source_maximized_ || was_source_fullscreen_) {
386 did_restore_window_ = true; 385 did_restore_window_ = true;
387 // When all tabs in a maximized browser are dragged the browser gets 386 // When all tabs in a maximized browser are dragged the browser gets
388 // restored during the drag and maximized back when the drag ends. 387 // restored during the drag and maximized back when the drag ends.
389 views::Widget* widget = GetAttachedBrowserWidget(); 388 views::Widget* widget = GetAttachedBrowserWidget();
390 const int last_tabstrip_width = attached_tabstrip_->GetTabAreaWidth(); 389 const int last_tabstrip_width = attached_tabstrip_->GetTabAreaWidth();
391 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); 390 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs();
392 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); 391 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds);
393 gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_, 392 gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_,
394 point_in_screen, 393 point_in_screen,
395 &drag_bounds)); 394 &drag_bounds));
396 new_bounds.Offset(-widget->GetRestoredBounds().x() + 395 new_bounds.Offset(-widget->GetRestoredBounds().x() +
397 point_in_screen.x() - 396 point_in_screen.x() -
398 mouse_offset_.x(), 0); 397 mouse_offset_.x(), 0);
399 widget->SetVisibilityChangedAnimationsEnabled(false); 398 widget->SetVisibilityChangedAnimationsEnabled(false);
400 widget->Restore(); 399 widget->Restore();
401 widget->SetBounds(new_bounds); 400 widget->SetBounds(new_bounds);
402 AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width, 401 AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width,
403 point_in_screen, 402 point_in_screen,
404 &drag_bounds); 403 &drag_bounds);
405 widget->SetVisibilityChangedAnimationsEnabled(true); 404 widget->SetVisibilityChangedAnimationsEnabled(true);
406 } else { 405 } else {
407 #if !defined(OS_LINUX) || defined(OS_CHROMEOS)
408 // The user has to move the mouse some amount of pixels before the drag 406 // The user has to move the mouse some amount of pixels before the drag
409 // starts. Offset the window by this amount so that the relative offset 407 // starts. Offset the window by this amount so that the relative offset
410 // of the initial location is consistent. See crbug.com/518740 408 // of the initial location is consistent. See crbug.com/518740
411 views::Widget* widget = GetAttachedBrowserWidget(); 409 views::Widget* widget = GetAttachedBrowserWidget();
412 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); 410 gfx::Rect bounds = widget->GetWindowBoundsInScreen();
413 bounds.Offset(point_in_screen.x() - start_point_in_screen_.x(), 411 bounds.Offset(point_in_screen.x() - start_point_in_screen_.x(),
414 point_in_screen.y() - start_point_in_screen_.y()); 412 point_in_screen.y() - start_point_in_screen_.y());
415 widget->SetBounds(bounds); 413 widget->SetBounds(bounds);
416 #else
417 // Linux does not need the window offset behavior above because all drag
418 // implementations move windows relative to a passed-in cursor position
419 // instead of the implicit current cursor position like on Windows.
420 drag_point_in_screen = start_point_in_screen_;
421 #endif
422 } 414 }
423 RunMoveLoop(GetWindowOffset(drag_point_in_screen)); 415 RunMoveLoop(GetWindowOffset(point_in_screen));
424 return; 416 return;
425 } 417 }
426 } 418 }
427 419
428 if (ContinueDragging(point_in_screen) == Liveness::DELETED) 420 if (ContinueDragging(point_in_screen) == Liveness::DELETED)
429 return; 421 return;
430 } 422 }
431 423
432 void TabDragController::EndDrag(EndDragReason reason) { 424 void TabDragController::EndDrag(EndDragReason reason) {
433 TRACE_EVENT0("views", "TabDragController::EndDrag"); 425 TRACE_EVENT0("views", "TabDragController::EndDrag");
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 // TODO(pkotwicz): Fix this properly (crbug.com/358482) 1838 // TODO(pkotwicz): Fix this properly (crbug.com/358482)
1847 for (auto* browser : *BrowserList::GetInstance()) { 1839 for (auto* browser : *BrowserList::GetInstance()) {
1848 if (browser->tab_strip_model()->empty()) 1840 if (browser->tab_strip_model()->empty())
1849 exclude.insert(browser->window()->GetNativeWindow()); 1841 exclude.insert(browser->window()->GetNativeWindow());
1850 } 1842 }
1851 #endif 1843 #endif
1852 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); 1844 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr());
1853 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); 1845 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude);
1854 return ref ? Liveness::ALIVE : Liveness::DELETED; 1846 return ref ? Liveness::ALIVE : Liveness::DELETED;
1855 } 1847 }
OLDNEW
« no previous file with comments | « no previous file | ui/base/x/x11_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698