Cocoa: Fix shadowless popups

The window shadow was never invalidated after setting the transparency
mask. We now do it right after the first draw after setting the mask.

Change-Id: Icc5c6002d25abeb25d58ee4d1f868e928121ae9b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-02-26 15:34:00 +01:00 committed by The Qt Project
parent 5a83785567
commit 544f1cbe27
2 changed files with 14 additions and 0 deletions

View File

@ -59,6 +59,7 @@ QT_END_NAMESPACE
QPoint m_backingStoreOffset;
CGImageRef m_maskImage;
uchar *m_maskData;
bool m_shouldInvalidateWindowShadow;
QWindow *m_window;
QCocoaWindow *m_platformWindow;
Qt::MouseButtons m_buttons;
@ -76,6 +77,7 @@ QT_END_NAMESPACE
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
- (void)flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset;
- (void)setMaskRegion:(const QRegion *)region;
- (void)invalidateWindowShadowIfNeeded;
- (void)drawRect:(NSRect)dirtyRect;
- (void)updateGeometry;
- (void)windowNotification : (NSNotification *) windowNotification;

View File

@ -80,6 +80,7 @@ static QTouchDevice *touchDevice = 0;
m_backingStore = 0;
m_maskImage = 0;
m_maskData = 0;
m_shouldInvalidateWindowShadow = false;
m_window = 0;
m_buttons = Qt::NoButton;
m_sendKeyEvent = false;
@ -266,6 +267,7 @@ static QTouchDevice *touchDevice = 0;
- (void) setMaskRegion:(const QRegion *)region
{
m_shouldInvalidateWindowShadow = true;
if (m_maskImage)
CGImageRelease(m_maskImage);
if (region->isEmpty()) {
@ -285,6 +287,14 @@ static QTouchDevice *touchDevice = 0;
m_maskImage = qt_mac_toCGImage(maskImage, true, &m_maskData);
}
- (void)invalidateWindowShadowIfNeeded
{
if (m_shouldInvalidateWindowShadow && m_platformWindow->m_nsWindow) {
[m_platformWindow->m_nsWindow invalidateShadow];
m_shouldInvalidateWindowShadow = false;
}
}
- (void) drawRect:(NSRect)dirtyRect
{
if (!m_backingStore)
@ -334,6 +344,8 @@ static QTouchDevice *touchDevice = 0;
CGContextRestoreGState(cgContext);
CGImageRelease(cleanImg);
CGImageRelease(subMask);
[self invalidateWindowShadowIfNeeded];
}
- (BOOL) isFlipped