Skip to content
Snippets Groups Projects
Commit 62a8dcb8 authored by George Nachman's avatar George Nachman
Browse files

Get rid of a gross hack when dragging the only tab in a window. We used to...

Get rid of a gross hack when dragging the only tab in a window. We used to move the window to a hopefully offscreen coordinate of -10000,-10000. That's not guaranteed to work and is silly. Instead, order it out. This tickled another design issue where a placeholder cell was removed while it still had a tracking rect. This commit prevents that crash by first removing the tracking rect.
parent 14cf193a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -219,4 +219,7 @@ enum {
 
- (void)setTabsHaveCloseButtons:(BOOL)tabsHaveCloseButtons;
 
// Safely remove a cell.
- (void)removeCell:(PSMTabBarCell *)cell;
@end
Loading
Loading
@@ -723,8 +723,7 @@ const NSInteger kPSMStartResizeAnimation = 0;
[self update:YES];
}
 
- (void)update
{
- (void)update {
[self update:NO];
}
 
Loading
Loading
@@ -869,8 +868,20 @@ const NSInteger kPSMStartResizeAnimation = 0;
return newWidths;
}
 
- (void)_removeCellTrackingRects
{
- (void)removeCell:(PSMTabBarCell *)cell {
if ([cell closeButtonTrackingTag] != 0) {
[self removeTrackingRect:[cell closeButtonTrackingTag]];
[cell setCloseButtonTrackingTag:0];
}
if ([cell cellTrackingTag] != 0) {
[self removeTrackingRect:[cell cellTrackingTag]];
[cell setCellTrackingTag:0];
}
[[self cells] removeObject:cell];
}
- (void)_removeCellTrackingRects {
// size all cells appropriately and create tracking rects
// nuke old tracking rects
int i, cellCount = [_cells count];
Loading
Loading
Loading
Loading
@@ -19,6 +19,14 @@
@property (nonatomic) BOOL isDragging;
@property (nonatomic) NSPoint currentMouseLoc;
@property (nonatomic, retain) PSMTabBarCell *targetCell;
// While the last tab in a window is being dragged, the window is hidden so
// that you can drop the tab on targets beneath the window. Setting the
// window's alpha to 0 is not sufficient to allow this, unfortunately. So we
// orderOut: the window temporarily until the drag operation is complete and
// then order it back in. This property remembers the window and keeps a
// reference to it.
@property (nonatomic, retain) NSWindow *temporarilyHiddenWindow;
@end
 
@implementation PSMTabDragAssistant {
Loading
Loading
@@ -67,6 +75,7 @@
[_animationTimer release];
[_sineCurveWidths release];
[_targetCell release];
[_temporarilyHiddenWindow release];
[super dealloc];
}
 
Loading
Loading
@@ -280,8 +289,8 @@
[[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:newTabBarForDraggedTabViewItem:atPoint:)]) {
 
[[[self sourceTabBar] window] setAlphaValue:0.0];
// Move the window out of the way so it doesn't block drop targets under it.
[[[self sourceTabBar] window] setFrameOrigin:NSMakePoint(-1000000, -1000000)];
self.temporarilyHiddenWindow = [[self sourceTabBar] window];
[self.temporarilyHiddenWindow orderOut:nil];
[_dragViewWindow setAlphaValue:kPSMTabDragWindowAlpha];
} else {
_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0
Loading
Loading
@@ -433,7 +442,7 @@
}
 
- (void)draggedImageEndedAt:(NSPoint)aPoint operation:(NSDragOperation)operation {
if ([self isDragging]){ // means there was not a successful drop (performDragOperation)
if ([self isDragging]) { // means there was not a successful drop (performDragOperation)
id sourceDelegate = [[self sourceTabBar] delegate];
 
//split off the dragged tab into a new window
Loading
Loading
@@ -482,6 +491,7 @@
NSLog(@"Delegate returned no control to add to.");
[[[self sourceTabBar] cells] insertObject:[self draggedCell] atIndex:[self draggedCellIndex]];
[[[self sourceTabBar] window] setAlphaValue:1]; // Make the window visible again.
[[[self sourceTabBar] window] orderFront:nil];
}
 
} else {
Loading
Loading
@@ -518,9 +528,7 @@
[self removeAllPlaceholdersFromTabBar:[self sourceTabBar]];
[self setSourceTabBar:nil];
[self setDestinationTabBar:nil];
NSEnumerator *e = [_participatingTabBars objectEnumerator];
PSMTabBarControl *tabBar;
while ( (tabBar = [e nextObject]) ) {
for (PSMTabBarControl *tabBar in _participatingTabBars) {
[self removeAllPlaceholdersFromTabBar:tabBar];
}
[_participatingTabBars removeAllObjects];
Loading
Loading
@@ -529,6 +537,7 @@
_animationTimer = nil;
[_sineCurveWidths removeAllObjects];
[self setTargetCell:nil];
self.temporarilyHiddenWindow = nil;
}
 
- (void)draggingBeganAt:(NSPoint)aPoint {
Loading
Loading
@@ -742,8 +751,9 @@
int i, cellCount = [[control cells] count];
for (i = (cellCount - 1); i >= 0; i--) {
PSMTabBarCell *cell = [[control cells] objectAtIndex:i];
if ([cell isPlaceholder])
[[control cells] removeObject:cell];
if ([cell isPlaceholder]) {
[control removeCell:cell];
}
}
// redraw
[[NSRunLoop currentRunLoop] performSelector:@selector(update)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment