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

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

Issue 11085053: Improving window auto management between workspaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No auto movement for tab dragging Created 8 years, 2 months 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 | Annotate | Revision Log
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 29 matching lines...) Expand all
40 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/gfx/canvas.h" 41 #include "ui/gfx/canvas.h"
42 #include "ui/gfx/image/image_skia.h" 42 #include "ui/gfx/image/image_skia.h"
43 #include "ui/gfx/screen.h" 43 #include "ui/gfx/screen.h"
44 #include "ui/views/widget/root_view.h" 44 #include "ui/views/widget/root_view.h"
45 #include "ui/views/widget/widget.h" 45 #include "ui/views/widget/widget.h"
46 46
47 #if defined(USE_ASH) 47 #if defined(USE_ASH)
48 #include "ash/shell.h" 48 #include "ash/shell.h"
49 #include "ash/wm/property_util.h" 49 #include "ash/wm/property_util.h"
50 #include "ash/wm/window_util.h"
50 #include "ui/aura/env.h" 51 #include "ui/aura/env.h"
51 #include "ui/aura/root_window.h" 52 #include "ui/aura/root_window.h"
52 #include "ui/base/gestures/gesture_recognizer.h" 53 #include "ui/base/gestures/gesture_recognizer.h"
53 #endif 54 #endif
54 55
55 using content::OpenURLParams; 56 using content::OpenURLParams;
56 using content::UserMetricsAction; 57 using content::UserMetricsAction;
57 using content::WebContents; 58 using content::WebContents;
58 59
59 static const int kHorizontalMoveThreshold = 16; // Pixels. 60 static const int kHorizontalMoveThreshold = 16; // Pixels.
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 attached_tabstrip_->ReleaseDragController(); 822 attached_tabstrip_->ReleaseDragController();
822 target_tabstrip->OwnDragController(this); 823 target_tabstrip->OwnDragController(this);
823 // Disable animations so that we don't see a close animation on aero. 824 // Disable animations so that we don't see a close animation on aero.
824 browser_widget->SetVisibilityChangedAnimationsEnabled(false); 825 browser_widget->SetVisibilityChangedAnimationsEnabled(false);
825 // For aura we can't release capture, otherwise it'll cancel a gesture. 826 // For aura we can't release capture, otherwise it'll cancel a gesture.
826 // Instead we have to directly change capture. 827 // Instead we have to directly change capture.
827 #if !defined(USE_ASH) 828 #if !defined(USE_ASH)
828 browser_widget->ReleaseCapture(); 829 browser_widget->ReleaseCapture();
829 #else 830 #else
830 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); 831 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_);
832 // To avoid the auto window management to kick in we set the user changed
sky 2012/10/23 19:35:39 What we're saying is that when you drag a window a
Mr4D (OOO till 08-26) 2012/10/24 16:41:37 Done indirectly as requested.
833 // flag. Note that the browser might only have a single tab left at this
834 // point and if that happens it will be destroyed shortly after in which
835 // case we don't want to ever take back the flag.
836 bool old_state = true;
837 if (GetModel(attached_tabstrip_)->count() > 1)
838 old_state = ash::wm::HasUserChangedWindowPositionOrSize(
839 browser_widget->GetNativeWindow());
840 ash::wm::SetUserHasChangedWindowPositionOrSize(
841 browser_widget->GetNativeWindow(), true);
831 #endif 842 #endif
832 // EndMoveLoop is going to snap the window back to its original location. 843 // EndMoveLoop is going to snap the window back to its original location.
833 // Hide it so users don't see this. 844 // Hide it so users don't see this.
834 browser_widget->Hide(); 845 browser_widget->Hide();
835 browser_widget->EndMoveLoop(); 846 browser_widget->EndMoveLoop();
836 847
837 // Ideally we would always swap the tabs now, but on windows it seems that 848 // Ideally we would always swap the tabs now, but on windows it seems that
838 // running the move loop implicitly activates the window when done, leading 849 // running the move loop implicitly activates the window when done, leading
839 // to all sorts of flicker. So, on windows, instead we process the move 850 // to all sorts of flicker. So, on windows, instead we process the move
840 // after the loop completes. But on chromeos, we can do tab swapping now to 851 // after the loop completes. But on chromeos, we can do tab swapping now to
841 // avoid the tab flashing issue(crbug.com/116329). 852 // avoid the tab flashing issue(crbug.com/116329).
842 #if defined(USE_ASH) 853 #if defined(USE_ASH)
854 if (!old_state)
855 ash::wm::SetUserHasChangedWindowPositionOrSize(
856 browser_widget->GetNativeWindow(), old_state);
843 is_dragging_window_ = false; 857 is_dragging_window_ = false;
844 Detach(DONT_RELEASE_CAPTURE); 858 Detach(DONT_RELEASE_CAPTURE);
845 Attach(target_tabstrip, point_in_screen); 859 Attach(target_tabstrip, point_in_screen);
846 // Move the tabs into position. 860 // Move the tabs into position.
847 MoveAttached(point_in_screen); 861 MoveAttached(point_in_screen);
848 attached_tabstrip_->GetWidget()->Activate(); 862 attached_tabstrip_->GetWidget()->Activate();
849 #else 863 #else
850 tab_strip_to_attach_to_after_exit_ = target_tabstrip; 864 tab_strip_to_attach_to_after_exit_ = target_tabstrip;
851 #endif 865 #endif
852 866
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 1315
1302 browser->window()->Show(); 1316 browser->window()->Show();
1303 browser->window()->Activate(); 1317 browser->window()->Activate();
1304 dragged_browser_view->GetWidget()->SetVisibilityChangedAnimationsEnabled( 1318 dragged_browser_view->GetWidget()->SetVisibilityChangedAnimationsEnabled(
1305 true); 1319 true);
1306 RunMoveLoop(drag_offset); 1320 RunMoveLoop(drag_offset);
1307 } 1321 }
1308 1322
1309 void TabDragController::RunMoveLoop(const gfx::Point& drag_offset) { 1323 void TabDragController::RunMoveLoop(const gfx::Point& drag_offset) {
1310 // If the user drags the whole window we'll assume they are going to attach to 1324 // If the user drags the whole window we'll assume they are going to attach to
1311 // another window and therefor want to reorder. 1325 // another window and therefore want to reorder.
1312 move_behavior_ = REORDER; 1326 move_behavior_ = REORDER;
1313 1327
1314 move_loop_widget_ = GetAttachedBrowserWidget(); 1328 move_loop_widget_ = GetAttachedBrowserWidget();
1315 DCHECK(move_loop_widget_); 1329 DCHECK(move_loop_widget_);
1316 move_loop_widget_->AddObserver(this); 1330 move_loop_widget_->AddObserver(this);
1317 is_dragging_window_ = true; 1331 is_dragging_window_ = true;
1318 bool destroyed = false; 1332 bool destroyed = false;
1319 destroyed_ = &destroyed; 1333 destroyed_ = &destroyed;
1320 #if !defined(USE_ASH) 1334 #if !defined(USE_ASH)
1321 // Running the move loop releases mouse capture on Windows, which triggers 1335 // Running the move loop releases mouse capture on Windows, which triggers
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 gfx::Point TabDragController::GetWindowOffset( 2011 gfx::Point TabDragController::GetWindowOffset(
1998 const gfx::Point& point_in_screen) { 2012 const gfx::Point& point_in_screen) {
1999 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2013 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2000 attached_tabstrip_ : source_tabstrip_; 2014 attached_tabstrip_ : source_tabstrip_;
2001 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2015 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2002 2016
2003 gfx::Point offset = point_in_screen; 2017 gfx::Point offset = point_in_screen;
2004 views::View::ConvertPointFromScreen(toplevel_view, &offset); 2018 views::View::ConvertPointFromScreen(toplevel_view, &offset);
2005 return offset; 2019 return offset;
2006 } 2020 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698