TOF : Mac Full Screen Windows / Tabs

No need to invest in expensive plugins to solve this


//
// Disable auto tabbing in Sierra
#If TargetCocoa
  Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr
  Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr
  Declare Sub setAllowsAutomaticWindowTabbing Lib "Cocoa" selector "setAllowsAutomaticWindowTabbing:" (cls As Ptr, ena As Boolean)
  Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Ptr, sel As Ptr) As Boolean
  Dim nswCls As Ptr = NSClassFromString ("NSWindow")
  If respondsToSelector (nswCls, NSSelectorFromString ("setAllowsAutomaticWindowTabbing:")) Then
    setAllowsAutomaticWindowTabbing (nswCls, False)
  End If
#EndIf

Just found you from the code above. I was hoping for a way of combining windows into a single tabbed window on going full screen and then splitting them when I came back into windowed. Rather than disabling the tabbed mode in full screen. That kinda works nicely.

I discovered functions for “mergeAllWindows” and “moveTabToNewWindow” which kinda suggest a way forward. However, my attempts to use them failed.

Bingo. I’ve worked it out:

Using MacOSLib NSWindow class, which I converted to API2 and the following code allows me to pop all windows into one.

Declare Sub mergeAllWindows Lib "Cocoa" Selector "mergeAllWindows:" ( Any As Ptr )
Var oNSWindow As New NSWindow( Self )
mergeAllWindows oNSWindow

The following code will split the tabs into separate windows when you return from fullscreen (or any other time you want):

Declare Sub moveTabToNewWindow Lib "Cocoa" Selector "moveTabToNewWindow:" ( Any As Ptr )

For iWindow As Integer = 0 To App.WindowCount - 1
  If App.Window( iWindow ) IsA Window1 Then
    Var oNSWindow As New NSWindow( App.Window( iWindow ) )
    moveTabToNewWindow oNSWindow
  End If
Next

The “IsA Window1” part is to identify the class of the document windows you have. It could equally be any other code you wish to distinguish your documents from any other form of window, that likely wouldn’t be in a tab.

1 Like