@@ -1688,100 +1688,116 @@ - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint {
1688
1688
1689
1689
// NSDraggingDestination
1690
1690
- (NSDragOperation )draggingEntered : (id <NSDraggingInfo >)sender {
1691
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1692
- if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1693
- ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1694
- return NSDragOperationNone;
1695
- }
1691
+ if (self.window .alphaValue > 0.0 ) {
1692
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1693
+ if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1694
+ ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1695
+ return NSDragOperationNone;
1696
+ }
1696
1697
1697
- [[PSMTabDragAssistant sharedDragAssistant ] draggingEnteredTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1698
- return NSDragOperationMove;
1698
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingEnteredTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1699
+ return NSDragOperationMove;
1700
+ }
1699
1701
}
1700
-
1701
1702
return NSDragOperationNone;
1702
1703
}
1703
1704
1704
1705
- (NSDragOperation )draggingUpdated : (id <NSDraggingInfo >)sender {
1705
- PSMTabBarCell *cell = [self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ];
1706
+ if (self.window .alphaValue > 0.0 ) {
1707
+ PSMTabBarCell *cell = [self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ];
1706
1708
1707
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1708
- if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1709
- ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1710
- return NSDragOperationNone;
1711
- }
1709
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1710
+ if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1711
+ ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1712
+ return NSDragOperationNone;
1713
+ }
1712
1714
1713
- [[PSMTabDragAssistant sharedDragAssistant ] draggingUpdatedInTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1714
- return NSDragOperationMove;
1715
- } else if (cell) {
1716
- // something that was accepted by the delegate was dragged on
1717
-
1718
- // Test for the space bar (the skip-the-delay key).
1719
- /* enum { virtualKeycodeForSpace = 49 }; //Source: IM:Tx (Fig. C-2)
1720
- union {
1721
- KeyMap keymap;
1722
- char bits[16];
1723
- } keymap;
1724
- GetKeys(keymap.keymap);
1725
- if ((GetCurrentEventKeyModifiers() == 0) && bit_test(keymap.bits, virtualKeycodeForSpace)) {
1726
- //The user pressed the space bar. This skips the delay; the user wants to pop the spring on this tab *now*.
1727
-
1728
- //For some reason, it crashes if I call -fire here. I don't know why. It doesn't crash if I simply set the fire date to now.
1729
- [_springTimer setFireDate:[NSDate date]];
1730
- } else {*/
1731
- // Wind the spring for a spring-loaded drop.
1732
- // The delay time comes from Finder's defaults, which specifies it in milliseconds.
1733
- // If the delegate can't handle our spring-loaded drop, we'll abort it when the timer fires. See fireSpring:. This is simpler than constantly (checking for spring-loaded awareness and tearing down/rebuilding the timer) at every delegate change.
1734
-
1735
- // If the user has dragged to a different tab, reset the timer.
1736
- if (_tabViewItemWithSpring != [cell representedObject ]) {
1737
- [_springTimer invalidate ];
1738
- [_springTimer release ]; _springTimer = nil ;
1739
- _tabViewItemWithSpring = [cell representedObject ];
1740
- }
1741
- if (!_springTimer) {
1742
- // Finder's default delay time, as of Tiger, is 668 ms. If the user has never changed it, there's no setting in its defaults, so we default to that amount.
1743
- NSNumber *delayNumber = NSMakeCollectable ([(NSNumber *)CFPreferencesCopyAppValue ((CFStringRef )@" SpringingDelayMilliseconds" , (CFStringRef )@" com.apple.finder" ) autorelease ]);
1744
- NSTimeInterval delaySeconds = delayNumber ?[delayNumber doubleValue ] / 1000.0 : 0.668 ;
1745
- _springTimer = [[NSTimer scheduledTimerWithTimeInterval: delaySeconds
1746
- target: self
1747
- selector: @selector (fireSpring: )
1748
- userInfo: sender
1749
- repeats: NO ] retain ];
1715
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingUpdatedInTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1716
+ return NSDragOperationMove;
1717
+ } else if (cell) {
1718
+ // something that was accepted by the delegate was dragged on
1719
+
1720
+ // Test for the space bar (the skip-the-delay key).
1721
+ /* enum { virtualKeycodeForSpace = 49 }; //Source: IM:Tx (Fig. C-2)
1722
+ union {
1723
+ KeyMap keymap;
1724
+ char bits[16];
1725
+ } keymap;
1726
+ GetKeys(keymap.keymap);
1727
+ if ((GetCurrentEventKeyModifiers() == 0) && bit_test(keymap.bits, virtualKeycodeForSpace)) {
1728
+ //The user pressed the space bar. This skips the delay; the user wants to pop the spring on this tab *now*.
1729
+
1730
+ //For some reason, it crashes if I call -fire here. I don't know why. It doesn't crash if I simply set the fire date to now.
1731
+ [_springTimer setFireDate:[NSDate date]];
1732
+ } else {*/
1733
+ // Wind the spring for a spring-loaded drop.
1734
+ // The delay time comes from Finder's defaults, which specifies it in milliseconds.
1735
+ // If the delegate can't handle our spring-loaded drop, we'll abort it when the timer fires. See fireSpring:. This is simpler than constantly (checking for spring-loaded awareness and tearing down/rebuilding the timer) at every delegate change.
1736
+
1737
+ // If the user has dragged to a different tab, reset the timer.
1738
+ if (_tabViewItemWithSpring != [cell representedObject ]) {
1739
+ [_springTimer invalidate ];
1740
+ [_springTimer release ]; _springTimer = nil ;
1741
+ _tabViewItemWithSpring = [cell representedObject ];
1742
+ }
1743
+ if (!_springTimer) {
1744
+ // Finder's default delay time, as of Tiger, is 668 ms. If the user has never changed it, there's no setting in its defaults, so we default to that amount.
1745
+ NSNumber *delayNumber = NSMakeCollectable ([(NSNumber *)CFPreferencesCopyAppValue ((CFStringRef )@" SpringingDelayMilliseconds" , (CFStringRef )@" com.apple.finder" ) autorelease ]);
1746
+ NSTimeInterval delaySeconds = delayNumber ?[delayNumber doubleValue ] / 1000.0 : 0.668 ;
1747
+ _springTimer = [[NSTimer scheduledTimerWithTimeInterval: delaySeconds
1748
+ target: self
1749
+ selector: @selector (fireSpring: )
1750
+ userInfo: sender
1751
+ repeats: NO ] retain ];
1752
+ }
1753
+ return NSDragOperationCopy;
1750
1754
}
1751
- return NSDragOperationCopy;
1752
1755
}
1753
1756
1754
1757
return NSDragOperationNone;
1755
1758
}
1756
1759
1757
1760
- (void )draggingExited : (id <NSDraggingInfo >)sender {
1758
- [_springTimer invalidate ];
1759
- [_springTimer release ]; _springTimer = nil ;
1761
+ if (self.window .alphaValue > 0.0 ) {
1762
+ [_springTimer invalidate ];
1763
+ [_springTimer release ]; _springTimer = nil ;
1760
1764
1761
- [[PSMTabDragAssistant sharedDragAssistant ] draggingExitedTabBarControl: self ];
1765
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingExitedTabBarControl: self ];
1766
+ }
1762
1767
}
1763
1768
1764
1769
- (BOOL )prepareForDragOperation : (id <NSDraggingInfo >)sender {
1765
- // validate the drag operation only if there's a valid tab bar to drop into
1766
- return [[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] == NSNotFound ||
1767
- [[PSMTabDragAssistant sharedDragAssistant ] destinationTabBar ] != nil ;
1770
+ if (self.window .alphaValue > 0.0 ) {
1771
+ // validate the drag operation only if there's a valid tab bar to drop into
1772
+ return [[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] == NSNotFound ||
1773
+ [[PSMTabDragAssistant sharedDragAssistant ] destinationTabBar ] != nil ;
1774
+ }
1775
+ return NO ;
1768
1776
}
1769
1777
1770
1778
- (BOOL )performDragOperation : (id <NSDraggingInfo >)sender {
1771
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1772
- [[PSMTabDragAssistant sharedDragAssistant ] performDragOperation ];
1773
- } else if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:acceptedDraggingInfo:onTabViewItem: )]) {
1774
- // forward the drop to the delegate
1775
- [[self delegate ] tabView: tabView acceptedDraggingInfo: sender onTabViewItem: [[self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ] representedObject ]];
1779
+ if (self.window .alphaValue > 0.0 ) {
1780
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1781
+ [[PSMTabDragAssistant sharedDragAssistant ] performDragOperation ];
1782
+ } else if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:acceptedDraggingInfo:onTabViewItem: )]) {
1783
+ // forward the drop to the delegate
1784
+ [[self delegate ] tabView: tabView acceptedDraggingInfo: sender onTabViewItem: [[self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ] representedObject ]];
1785
+ }
1786
+ return YES ;
1776
1787
}
1777
- return YES ;
1788
+ return NO ;
1789
+ }
1790
+
1791
+ - (BOOL )wantsPeriodicDraggingUpdates {
1792
+ return NO ;
1778
1793
}
1779
1794
1780
1795
- (void )draggedImage : (NSImage *)anImage endedAt : (NSPoint )aPoint operation : (NSDragOperation )operation {
1781
- [[PSMTabDragAssistant sharedDragAssistant ] draggedImageEndedAt: aPoint operation: operation];
1796
+ [[PSMTabDragAssistant sharedDragAssistant ] draggedImageEndedAt: aPoint operation: operation];
1782
1797
}
1783
1798
1784
1799
- (void )concludeDragOperation : (id <NSDraggingInfo >)sender {
1800
+ self.window .alphaValue = 1.0 ;
1785
1801
}
1786
1802
1787
1803
#pragma mark -
0 commit comments