summaryrefslogtreecommitdiff
path: root/src/plugins/platforms/cocoa/qnsview.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm79
1 files changed, 48 insertions, 31 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 0916a1faa8..94b414a882 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -251,6 +251,15 @@ static QTouchDevice *touchDevice = 0;
}
}
+- (void)notifyWindowStateChanged:(Qt::WindowState)newState
+{
+ QWindowSystemInterface::handleWindowStateChanged(m_window, newState);
+ // We want to read the window state back from the window,
+ // but the event we just sent may be asynchronous.
+ QWindowSystemInterface::flushWindowSystemEvents();
+ m_platformWindow->setSynchedWindowStateFromWindow();
+}
+
- (void)windowNotification : (NSNotification *) windowNotification
{
//qDebug() << "windowNotification" << QCFString::toQString([windowNotification name]);
@@ -269,10 +278,11 @@ static QTouchDevice *touchDevice = 0;
if (!m_platformWindow->windowIsPopupType())
QWindowSystemInterface::handleWindowActivated(0);
}
- } else if (notificationName == NSWindowDidMiniaturizeNotification) {
- QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowMinimized);
- } else if (notificationName == NSWindowDidDeminiaturizeNotification) {
- QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowNoState);
+ } else if (notificationName == NSWindowDidMiniaturizeNotification
+ || notificationName == NSWindowDidDeminiaturizeNotification) {
+ Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
+ Qt::WindowMinimized : Qt::WindowNoState;
+ [self notifyWindowStateChanged:newState];
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
m_platformWindow->obscureWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
@@ -290,10 +300,11 @@ static QTouchDevice *touchDevice = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (notificationName == NSWindowDidEnterFullScreenNotification) {
- QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowFullScreen);
- } else if (notificationName == NSWindowDidExitFullScreenNotification) {
- QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowNoState);
+ if (notificationName == NSWindowDidEnterFullScreenNotification
+ || notificationName == NSWindowDidExitFullScreenNotification) {
+ Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
+ Qt::WindowFullScreen : Qt::WindowNoState;
+ [self notifyWindowStateChanged:newState];
}
}
#endif
@@ -301,6 +312,12 @@ static QTouchDevice *touchDevice = 0;
}
}
+- (void)notifyWindowWillZoom:(BOOL)willZoom
+{
+ Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState;
+ [self notifyWindowStateChanged:newState];
+}
+
- (void)viewDidHide
{
m_platformWindow->obscureWindow();
@@ -340,15 +357,20 @@ static QTouchDevice *touchDevice = 0;
}
const QRect &rect = region->boundingRect();
- QImage maskImage(rect.size(), QImage::Format_RGB888);
- maskImage.fill(Qt::white);
- QPainter p(&maskImage);
- p.setRenderHint(QPainter::Antialiasing);
+ QImage tmp(rect.size(), QImage::Format_RGB32);
+ tmp.fill(Qt::white);
+ QPainter p(&tmp);
p.setClipRegion(*region);
- p.fillRect(rect, QBrush(Qt::black));
+ p.fillRect(rect, Qt::black);
p.end();
-
- maskImage = maskImage.convertToFormat(QImage::Format_Indexed8);
+ QImage maskImage = QImage(rect.size(), QImage::Format_Indexed8);
+ for (int y=0; y<rect.height(); ++y) {
+ const uint *src = (const uint *) tmp.constScanLine(y);
+ uchar *dst = maskImage.scanLine(y);
+ for (int x=0; x<rect.width(); ++x) {
+ dst[x] = src[x] & 0xff;
+ }
+ }
m_maskImage = qt_mac_toCGImage(maskImage, true, &m_maskData);
}
@@ -904,30 +926,25 @@ static QTouchDevice *touchDevice = 0;
EventRef eventRef = EventRef([nsevent eventRef]);
GetEventParameter(eventRef, kEventParamKeyCode, typeUInt32, 0, sizeof(nativeVirtualKey), 0, &nativeVirtualKey);
- QChar ch;
- int keyCode;
- if ([charactersIgnoringModifiers length] > 0) { // convert the first character into a key code
- if ((modifiers & Qt::ControlModifier) && ([characters length] != 0)) {
- ch = QChar([characters characterAtIndex:0]);
- } else {
+ QChar ch = QChar::ReplacementCharacter;
+ int keyCode = Qt::Key_unknown;
+ if ([characters length] != 0) {
+ if ((modifiers & Qt::MetaModifier) && ([charactersIgnoringModifiers length] != 0))
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
- }
+ else
+ ch = QChar([characters characterAtIndex:0]);
keyCode = [self convertKeyCode:ch];
- } else {
- // might be a dead key
- ch = QChar::ReplacementCharacter;
- keyCode = Qt::Key_unknown;
}
// we will send a key event unless the input method sets m_sendKeyEvent to false
m_sendKeyEvent = true;
-
QString text;
+ // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when
+ // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.)
+ if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)
+ text = QCFString::toQString(characters);
+
if (eventType == QEvent::KeyPress) {
- // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when
- // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.)
- if ([charactersIgnoringModifiers length] == 1 && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff))
- text = QCFString::toQString(characters);
if (m_composingText.isEmpty())
m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(m_window, timestamp, keyCode, modifiers, text);