[Interest] Prevent tabbing of Qt application on macOS Sierra

Morten Sorvig Morten.Sorvig at qt.io
Mon Sep 26 22:41:47 CEST 2016


> On 26 Sep 2016, at 17:39, Adam Light <aclight at gmail.com> wrote:
> 
> macOS Sierra added an automatic tabbing mechanism that is enabled for applications by default. This behavior is entirely inappropriate for our Qt 5.6 based application, and I'd like to be able to have my application opt-out of this behavior.
> 
> https://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKit/#10_12Window Tabbing describes the API behind this feature, and includes this:
> "The application should explicitly opt-out of automatic window tabbing by calling [NSWindow setAllowsAutomaticWindowTabbing:NO]"
> 
> Does anyone know how I can do this in a Qt application? My understanding of Cocoa/Objective-C is minimal, and I have no idea where I would make such a call.

Hi, this should be doable. I’ve tested this as far as it compiles, but did not have a test app at hand.

Create disableWindowTabbbing.mm with:

#import <AppKit/AppKit.h>

// Disables auto window tabbing where supported, otherwise a no-op.
void disableWindowTabbing()
{
    if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) {
        NSWindow.allowsAutomaticWindowTabbing = NO;
    }
}

Add it to the build (qmake example shown):

OBJECTIVE_SOURCES += disableWindowTabbbing.mm
LIBS += -framework AppKit

Then I think you can call it anywhere in main, before creating the window(s).

extern void disableWindowTabbing();
disableWindowTabbing();


Now perhaps Qt should disable this by default. We could do that during the
QGuiApplication constructor, giving apps that want to opt-in the opportunity
to do so afterwards.

- Morten



More information about the Interest mailing list