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

Fix the origin of a new window that's created when you drag a tab out of the...

Fix the origin of a new window that's created when you drag a tab out of the tab bar and drop it on nothing. What happened was the window got resized after adding the first tab to it and its originally (approximately) correct origin changed. The location is much closer to correct now and has been tested for all tab bar locations. Issue 5832.
parent d0b51a2c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -268,7 +268,9 @@
[viewImage unlockFocus];
}
 
if (styleMask | NSBorderlessWindowMask) {
if (self.sourceTabBar.tabLocation == PSMTab_LeftTab) {
_dragWindowOffset.height += kPSMTabBarControlHeight;
} else if (!(styleMask & NSTitledWindowMask)) {
_dragWindowOffset.height += 22;
}
 
Loading
Loading
@@ -484,7 +486,31 @@
 
[[[self sourceTabBar] tabView] removeTabViewItem:[[self draggedCell] representedObject]];
 
void (^fixOriginBlock)() = nil;
switch (self.sourceTabBar.tabLocation) {
case PSMTab_BottomTab: {
NSPoint bottomLeft = control.window.frame.origin;
fixOriginBlock = ^{
[control.window setFrameOrigin:bottomLeft];
};
break;
}
case PSMTab_LeftTab:
case PSMTab_TopTab: {
NSPoint topLeft = control.window.frame.origin;
topLeft.y += control.window.frame.size.height;
fixOriginBlock = ^{
[control.window setFrameTopLeftPoint:topLeft];
};
break;
}
}
// This could cause an already correctly positioned window to resize.
[[control tabView] addTabViewItem:[[self draggedCell] representedObject]];
fixOriginBlock();
[[control window] makeKeyAndOrderFront:nil];
 
if ([sourceDelegate respondsToSelector:@selector(tabView:didDropTabViewItem:inTabBar:)]) {
Loading
Loading
Loading
Loading
@@ -4555,10 +4555,91 @@ ITERM_WEAKLY_REFERENCEABLE
 
NSWindowController<iTermWindowController> * term =
[self terminalDraggedFromAnotherWindowAtPoint:point];
if (([term windowType] == WINDOW_TYPE_NORMAL ||
[term windowType] == WINDOW_TYPE_NO_TITLE_BAR) &&
[iTermPreferences intForKey:kPreferenceKeyTabPosition] == PSMTab_TopTab) {
[[term window] setFrameTopLeftPoint:point];
switch ([iTermPreferences intForKey:kPreferenceKeyTabPosition]) {
case PSMTab_TopTab:
switch ([term windowType]) {
case WINDOW_TYPE_NORMAL: {
CGFloat contentHeight = [term.window contentRectForFrameRect:NSMakeRect(0, 0, 100, 100)].size.height;
CGFloat titleBarHeight = 100 - contentHeight;
point.y += titleBarHeight;
if ([iTermPreferences boolForKey:kPreferenceKeyHideTabBar]) {
point.y -= self.tabBarControl.frame.size.height;
}
[[term window] setFrameTopLeftPoint:point];
break;
}
case WINDOW_TYPE_NO_TITLE_BAR:
if ([iTermPreferences boolForKey:kPreferenceKeyHideTabBar]) {
point.y -= self.tabBarControl.frame.size.height;
}
[[term window] setFrameTopLeftPoint:point];
break;
case WINDOW_TYPE_TOP:
case WINDOW_TYPE_LEFT:
case WINDOW_TYPE_RIGHT:
case WINDOW_TYPE_BOTTOM:
case WINDOW_TYPE_TOP_PARTIAL:
case WINDOW_TYPE_LEFT_PARTIAL:
case WINDOW_TYPE_RIGHT_PARTIAL:
case WINDOW_TYPE_BOTTOM_PARTIAL:
case WINDOW_TYPE_LION_FULL_SCREEN:
case WINDOW_TYPE_TRADITIONAL_FULL_SCREEN:
break;
}
break;
case PSMTab_BottomTab:
switch ([term windowType]) {
case WINDOW_TYPE_NORMAL:
case WINDOW_TYPE_NO_TITLE_BAR:
if (![iTermPreferences boolForKey:kPreferenceKeyHideTabBar]) {
point.y -= self.tabBarControl.frame.size.height;
[[term window] setFrameOrigin:point];
}
break;
case WINDOW_TYPE_TOP:
case WINDOW_TYPE_LEFT:
case WINDOW_TYPE_RIGHT:
case WINDOW_TYPE_BOTTOM:
case WINDOW_TYPE_TOP_PARTIAL:
case WINDOW_TYPE_LEFT_PARTIAL:
case WINDOW_TYPE_RIGHT_PARTIAL:
case WINDOW_TYPE_BOTTOM_PARTIAL:
case WINDOW_TYPE_LION_FULL_SCREEN:
case WINDOW_TYPE_TRADITIONAL_FULL_SCREEN:
break;
}
break;
case PSMTab_LeftTab:
switch ([term windowType]) {
case WINDOW_TYPE_NO_TITLE_BAR: {
[[term window] setFrameTopLeftPoint:point];
break;
}
case WINDOW_TYPE_NORMAL: {
CGFloat contentHeight = [term.window contentRectForFrameRect:NSMakeRect(0, 0, 100, 100)].size.height;
CGFloat titleBarHeight = 100 - contentHeight;
point.y += titleBarHeight;
[[term window] setFrameTopLeftPoint:point];
break;
}
case WINDOW_TYPE_TOP:
case WINDOW_TYPE_LEFT:
case WINDOW_TYPE_RIGHT:
case WINDOW_TYPE_BOTTOM:
case WINDOW_TYPE_TOP_PARTIAL:
case WINDOW_TYPE_LEFT_PARTIAL:
case WINDOW_TYPE_RIGHT_PARTIAL:
case WINDOW_TYPE_BOTTOM_PARTIAL:
case WINDOW_TYPE_LION_FULL_SCREEN:
case WINDOW_TYPE_TRADITIONAL_FULL_SCREEN:
break;
}
break;
}
 
return [term tabBarControl];
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