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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
6 | 6 |
7 #import "base/mac/mac_util.h" | 7 #import "base/mac/mac_util.h" |
8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
9 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 9 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
10 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" | 10 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // If we are dragging a tab, a window with a single tab should immediately | 101 // If we are dragging a tab, a window with a single tab should immediately |
102 // snap off and not drag within the tab strip. | 102 // snap off and not drag within the tab strip. |
103 if (!moveWindowOnDrag_) | 103 if (!moveWindowOnDrag_) |
104 draggingWithinTabStrip_ = [sourceController_ numberOfTabs] > 1; | 104 draggingWithinTabStrip_ = [sourceController_ numberOfTabs] > 1; |
105 | 105 |
106 dragOrigin_ = [NSEvent mouseLocation]; | 106 dragOrigin_ = [NSEvent mouseLocation]; |
107 | 107 |
108 // When spinning the event loop, a tab can get detached, which could lead to | 108 // When spinning the event loop, a tab can get detached, which could lead to |
109 // our own destruction. Keep ourselves around while spinning the loop as well | 109 // our own destruction. Keep ourselves around while spinning the loop as well |
110 // as the tab controller being dragged. | 110 // as the tab controller being dragged. |
111 scoped_nsobject<TabStripDragController> keepAlive([self retain]); | 111 base::scoped_nsobject<TabStripDragController> keepAlive([self retain]); |
112 scoped_nsobject<TabController> keepAliveTab([tab retain]); | 112 base::scoped_nsobject<TabController> keepAliveTab([tab retain]); |
113 | 113 |
114 // Because we move views between windows, we need to handle the event loop | 114 // Because we move views between windows, we need to handle the event loop |
115 // ourselves. Ideally we should use the standard event loop. | 115 // ourselves. Ideally we should use the standard event loop. |
116 while (1) { | 116 while (1) { |
117 const NSUInteger mask = | 117 const NSUInteger mask = |
118 NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSKeyUpMask; | 118 NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSKeyUpMask; |
119 theEvent = | 119 theEvent = |
120 [NSApp nextEventMatchingMask:mask | 120 [NSApp nextEventMatchingMask:mask |
121 untilDate:[NSDate distantFuture] | 121 untilDate:[NSDate distantFuture] |
122 inMode:NSDefaultRunLoopMode | 122 inMode:NSDefaultRunLoopMode |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 [[targetController_ window] makeMainWindow]; | 488 [[targetController_ window] makeMainWindow]; |
489 } else { | 489 } else { |
490 [dragWindow_ setAlphaValue:0.5]; | 490 [dragWindow_ setAlphaValue:0.5]; |
491 [[draggedController_ overlayWindow] setHasShadow:NO]; | 491 [[draggedController_ overlayWindow] setHasShadow:NO]; |
492 [[draggedController_ window] makeMainWindow]; | 492 [[draggedController_ window] makeMainWindow]; |
493 } | 493 } |
494 chromeIsVisible_ = shouldBeVisible; | 494 chromeIsVisible_ = shouldBeVisible; |
495 } | 495 } |
496 | 496 |
497 @end | 497 @end |
OLD | NEW |