Compatibility issue with iTerm2

A user reported an issue against iTerm2 when using BetterSnapTool. Under certain circumstances, double-clicking the title bar causes the window to zoom and then unzoom immediately. The original report is here:

I have been able to reproduce this with BetterSnapTool. I suspect the issue occurs because when using the minimal theme, iTerm2 does not have a regular title bar. It uses the NSWindowStyleMaskFullSizeContentView style mask, and then emulates standard title bar behavior, including double-click to zoom.

The way it happens is that iTerm2 handles a double-click calling -[NSWindow performZoom:] in -mouseUp: for one of the views that is at the top of the window.

I have observed that the OS then invokes -zoom and resizes the window synchronously (i.e., -performZoom: does not return until the window is done resizing).

Immediately after that finishes, the window gets resized via accessibility. This is the doing of BetterSnapTool:

    10  AppKit                              0x00007fff451bc847 -[NSWindow setFrame:display:] + 51
    11  iTerm2                              0x00000001000d3ef9 -[iTermWindow setFrame:display:] + 329
    12  AppKit                              0x00007fff459cf6d1 -[NSWindow(NSWindowAccessibility) accessibilitySetSizeAttribute:] + 718
    13  AppKit                              0x00007fff45788f45 NSAccessibilityPerformEntryPoint.llvm.9564667887440073428 + 16
    14  AppKit                              0x00007fff45785ca0 NSAccessibilityEntryPointSetValueForAttribute + 177
    15  AppKit                              0x00007fff4557fb58 SetAttributeValue + 320
    16  HIServices                          0x00007fff462e10f1 _AXXMIGSetAttributeValue + 678
    17  HIServices                          0x00007fff462ea0c2 _XSetAttributeValue + 554
    18  HIServices                          0x00007fff462c0c9d mshMIGPerform + 203
    19  CoreFoundation                      0x00007fff47b00b97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
    20  CoreFoundation                      0x00007fff47b00af5 __CFRunLoopDoSource1 + 527
    21  CoreFoundation                      0x00007fff47ae8aec __CFRunLoopRun + 2524
    22  CoreFoundation                      0x00007fff47ae7ebe CFRunLoopRunSpecific + 455
    23  HIToolbox                           0x00007fff46d471ab RunCurrentEventLoopInMode + 292
    24  HIToolbox                           0x00007fff46d46ded ReceiveNextEventCommon + 355
    25  HIToolbox                           0x00007fff46d46c76 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    26  AppKit                              0x00007fff450df79d _DPSNextEvent + 1135
    27  AppKit                              0x00007fff450de48b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
    28  AppKit                              0x00007fff450d85a8 -[NSApplication run] + 699
    29  AppKit                              0x00007fff450c7ae8 NSApplicationMain + 777
    30  iTerm2                              0x000000010000255b main + 315
    31  libdyld.dylib                       0x00007fff73a603d5 start + 1

In conclusion, it seems to me that BetterSnapTool is using some kind of heuristic to guess if there is a title bar at the top of the window. I need to find a way to prevent it from doing the accessibility resize in this case. It's not an issue in other themes of iTerm2, such as those that have regular NSWindow titlebars.

Videos of the issue can be seen at the link posted above.

thanks for the detailed report! I’ll add a fix to BTT/BetterSnapTool. They are using various heuristics, I’ll check which one goes wrong.

@Andreas_Hegenberg just to highlight one important note from the original issue - the problem occurs only when you have 2 or more open tabs in iTerm2 - if you just have one then everything is working correctly (even with Minimal theme).

1 Like