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

Fix a bug where unused space was left at the bottom of a fullscreen window with a horizontal split:

- Set the showTitle flag in a tab's session viws when creating a tmux tab. This fixes a bug where there would be unused space at the bottom of a fullscreen window because -recompact would throw out the extra room left for the title bar.

Fix a bug where a fullscreen window with a horizontal split with cycle between two different sizes (issue 4933):

- Make addSplitter:toIntervalMap:forHeight:origin: use the size of the scrollview, not the size of the session view. If there is a per-pane titlebar it shouldn't be counted since the height is used to compute the number of rows.

- Get rid of maxTmuxSize, which double-counted the difference between the root splitter and the flexible view that contained it (tmuxSize already took that into account).

- Make tmuxSize use the floor of the charsDiff values. That's better behaved for negative values, since tmuxSize is meant to be equal to or smaller than the size that would fit on the screen.

Finally, make replaceViewHierarchyWithParseTree: set the showTitle flag. This is mostly on general principal.
parent 0089be46
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -50,7 +50,6 @@
 
// Size we should report to fit the current layout
@property(nonatomic, readonly) NSSize tmuxSize;
@property(nonatomic, readonly) NSSize maxTmuxSize;
@property(nonatomic, copy) NSString *tmuxWindowName;
@property (readonly, getter=isTmuxTab) BOOL tmuxTab;
 
Loading
Loading
Loading
Loading
@@ -437,7 +437,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
- (void)numberOfSessionsDidChange {
if ([self updatePaneTitles] && [self isTmuxTab]) {
DLog(@"PTTab numberOfSessionsDidChange triggering windowDidResize");
DLog(@"PTYTab numberOfSessionsDidChange triggering windowDidResize");
[tmuxController_ windowDidResize:realParentWindow_];
}
int i = 1;
Loading
Loading
@@ -2624,7 +2624,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
BOOL isVertical = NO;
switch ([[parseTree objectForKey:kLayoutDictNodeType] intValue]) {
case kLeafLayoutNode:
DLog(@"Leafe node. Compute size of session");
DLog(@"Leaf node. Compute size of session");
size = [PTYTab _sessionSizeWithCellSize:[self cellSizeForBookmark:bookmark]
dimensions:NSMakeSize([[parseTree objectForKey:kLayoutDictWidthKey] intValue],
[[parseTree objectForKey:kLayoutDictHeightKey] intValue])
Loading
Loading
@@ -2874,6 +2874,17 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
hasFlexibleView:YES
viewMap:nil
sessionMap:nil];
NSArray *theChildren = [parseTree objectForKey:kLayoutDictChildrenKey];
BOOL haveMultipleSessions = ([theChildren count] > 1);
if ([iTermPreferences boolForKey:kPreferenceKeyShowPaneTitles] && haveMultipleSessions) {
// Set the showTitle flag so recompact does not make the views too small.
for (PTYSession *aSession in [theTab sessions]) {
[aSession.view setShowTitle:YES adjustScrollView:NO];
}
}
theTab->tmuxWindow_ = tmuxWindow;
theTab->tmuxController_ = [tmuxController retain];
theTab->parseTree_ = [parseTree retain];
Loading
Loading
@@ -2923,8 +2934,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
- (void)addSplitter:(NSSplitView *)splitter
toIntervalMap:(IntervalMap *)intervalMap
forHeight:(BOOL)forHeight
origin:(NSPoint)origin
{
origin:(NSPoint)origin {
BOOL first = YES;
int minPos, size;
NSSize cellSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
Loading
Loading
@@ -2962,7 +2972,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
// Look at the amount of space this SessionView could possibly
// contain. The PTYScrollView might be smaller than it so it's not
// relevant.
NSRect sessionViewFrame = [session.view frame];
NSRect sessionViewFrame = [session.view.scrollview frame];
NSSize contentSize = [NSScrollView contentSizeForFrameSize:sessionViewFrame.size
horizontalScrollerClass:nil
verticalScrollerClass:[realParentWindow_ scrollbarShouldBeVisible] ? [[session.view.scrollview verticalScroller] class] : nil
Loading
Loading
@@ -3001,8 +3011,8 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
// So:
// When forHeight is true, we want the tallest column.
// intervalMap maps (min x pixel, max x pixel) -> number of rows (plus 1 for each splitter)
// Then the largest value is the tallest column.
// intervalMap maps (min x pixel, max x pixel) -> number of cells (plus 1 for each splitter)
// Then the largest value is the last row/column.
IntervalMap *intervalMap = [[[IntervalMap alloc] init] autorelease];
[self addSplitter:root_
toIntervalMap:intervalMap
Loading
Loading
@@ -3013,31 +3023,6 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
return [[sortedValues lastObject] intValue];
}
 
// Returns the size (in characters) of the largest layout that can fit in this tab.
- (NSSize)maxTmuxSize {
DLog(@"Computing the size fo the largest layout that can fit in this tab");
NSSize rootSize = root_.frame.size;
NSSize containerSize = flexibleView_.frame.size;
NSSize overage = NSMakeSize(MAX(0, rootSize.width - containerSize.width),
MAX(0, rootSize.height - containerSize.height));
NSSize charSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
overage.width = ceil(overage.width / charSize.width);
overage.height = ceil(overage.height / charSize.height);
NSSize tmuxSize = [self tmuxSize];
NSSize result = NSMakeSize(tmuxSize.width - overage.width,
tmuxSize.height - overage.height);
DLog(@"rootSize=%@ containerSize=%@ overage=%@ charSize=%@ tmuxSize=%@ result=%@",
NSStringFromSize(rootSize),
NSStringFromSize(containerSize),
NSStringFromSize(overage),
NSStringFromSize(charSize),
NSStringFromSize(tmuxSize),
NSStringFromSize(result));
return result;
}
// Returns the size (in characters) of the window size that fits this tab's
// contents, while going over as little as possible. It picks the smallest
// height that can contain every column and every row (counting characters and
Loading
Loading
@@ -3077,12 +3062,12 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
NSSize charSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
 
// The characters growth (+ growth, - shrinkage) needed to attain the target
NSSize charsDiff = NSMakeSize(sizeDiff.width / charSize.width,
sizeDiff.height / charSize.height);
NSSize charsDiff = NSMakeSize(floor(sizeDiff.width / charSize.width),
floor(sizeDiff.height / charSize.height));
 
// The character size closest to the target.
NSSize tmuxSize = NSMakeSize((int) (rootSizeChars.width + charsDiff.width),
(int) (rootSizeChars.height + charsDiff.height));
NSSize tmuxSize = NSMakeSize(rootSizeChars.width + charsDiff.width,
rootSizeChars.height + charsDiff.height);
 
DLog(@"tmuxSize: rootSizeChars=%@, targetSizePixels=%@, rootSizePixels=%@, sizeDiff=%@, charSize=%@, charsDiff=%@, tmuxSize=%@",
NSStringFromSize(rootSizeChars),
Loading
Loading
@@ -3265,6 +3250,9 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
}
}
 
const BOOL showTitles = ([iTermPreferences boolForKey:kPreferenceKeyShowPaneTitles] &&
self.sessions.count > 1);
for (PTYSession *aSession in [self sessions]) {
NSNumber *n = [NSNumber numberWithInt:[aSession tmuxPane]];
if (![preexistingPanes containsObject:n]) {
Loading
Loading
@@ -3274,6 +3262,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
inWindow:tmuxWindow_];
[aSession setTmuxController:tmuxController_];
}
[aSession.view setShowTitle:showTitles adjustScrollView:NO];
}
[self fitSubviewsToRoot];
[self numberOfSessionsDidChange];
Loading
Loading
Loading
Loading
@@ -489,7 +489,7 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
NSSize minSize = NSMakeSize(INFINITY, INFINITY);
for (id windowKey in windows_) {
PTYTab *tab = [[windows_ objectForKey:windowKey] objectAtIndex:0];
NSSize size = [tab maxTmuxSize];
NSSize size = [tab tmuxSize];
minSize.width = MIN(minSize.width, size.width);
minSize.height = MIN(minSize.height, size.height);
}
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