diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-09-09 12:13:01 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-09-09 12:13:02 +0200 |
commit | 1f1e2aa57b480f0b227e11d0cff0b3cfcffb1f39 (patch) | |
tree | 9d5a045b3fea13486cf6108fd9ef641f3a1f5135 /src/plugins | |
parent | 3bac18da8ef9f5750207ddf47192b5db3137c4ac (diff) | |
parent | 9da5b6f7432dc1d87cec94040ede69cb2f7ff537 (diff) |
Merge remote-tracking branch 'origin/5.11.2' into 5.11
Change-Id: I2fa26fa061cbf5d2bded203a299a19b7d1c31d0a
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 21 | ||||
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 36 |
2 files changed, 31 insertions, 26 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 79f7ebda54..55b3805df3 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -70,12 +70,6 @@ #include <IOKit/graphics/IOGraphicsLib.h> -#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) -@interface NSApplication (MojaveForwardDeclarations) -@property (strong) NSAppearance *appearance NS_AVAILABLE_MAC(10_14); -@end -#endif - static void initResources() { Q_INIT_RESOURCE(qcocoaresources); @@ -137,21 +131,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) NSApplication *cocoaApplication = [QNSApplication sharedApplication]; qt_redirectNSApplicationSendEvent(); - if (__builtin_available(macOS 10.14, *)) { - // Disable dark appearance, unless the Info.plist or environment requests that it should be enabled - bool plistEnablesDarkAppearance = [[[NSBundle mainBundle] objectForInfoDictionaryKey: - @"NSRequiresAquaSystemAppearance"] boolValue]; - - bool hasEnvironmentRequiresAquaAppearance; - int environmentRequiresAquaAppearance = qEnvironmentVariableIntValue( - "QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE", &hasEnvironmentRequiresAquaAppearance); - bool environmentEnablesDarkAppearance = hasEnvironmentRequiresAquaAppearance - && environmentRequiresAquaAppearance == 0; - - if (!(plistEnablesDarkAppearance || environmentEnablesDarkAppearance)) - NSApp.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; - } - if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { // Applications launched from plain executables (without an app // bundle) are "background" applications that does not take keybaord diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 45da5fbd84..3405f01046 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1880,20 +1880,46 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const return cell; } -void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &qtRect, QPainter *p, +void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock) const { QMacCGContext ctx(p); setupNSGraphicsContext(ctx, YES); - const CGRect rect = qtRect.toCGRect(); + // FIXME: The rect that we get in is relative to the widget that we're drawing + // style on behalf of, and doesn't take into account the offset of that widget + // to the widget that owns the backingstore, which we are placing the native + // view into below. This means most of the views are placed in the upper left + // corner of backingStoreNSView, which does not map to where the actual widget + // is, and which may cause problems such as triggering a setNeedsDisplay of the + // backingStoreNSView for the wrong rect. We work around this by making the view + // layer-backed, which prevents triggering display of the backingStoreNSView, but + // but there may be other issues lurking here due to the wrong position. QTBUG-68023 + view.wantsLayer = YES; + + // FIXME: We are also setting the frame of the incoming view a lot at the call + // sites of this function, making it unclear who's actually responsible for + // maintaining the size and position of the view. In theory the call sites + // should ensure the _size_ of the view is correct, and then let this code + // take care of _positioning_ the view at the right place inside backingStoreNSView. + // For now we pass on the rect as is, to prevent any regressions until this + // can be investigated properly. + view.frame = rect.toCGRect(); [backingStoreNSView addSubview:view]; - view.frame = rect; + + // FIXME: Based on the code below, this method isn't drawing an NSView into + // a rect, it's drawing _part of the NSView_, defined by the incoming clip + // or dirty rect, into the current graphics context. We're doing some manual + // translations at the call sites that would indicate that this relationship + // is a bit fuzzy. + const CGRect dirtyRect = rect.toCGRect(); + if (drawRectBlock) - drawRectBlock(ctx, rect); + drawRectBlock(ctx, dirtyRect); else - [view drawRect:rect]; + [view drawRect:dirtyRect]; + [view removeFromSuperviewWithoutNeedingDisplay]; restoreNSGraphicsContext(ctx); |