From 283ba0ef014b0af64318c238819e54f1fa9d876f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 24 Sep 2013 15:45:11 +0200 Subject: Android: remove environment variable warnings at app startup. Change-Id: I8542809fd16465a29b4fb7e8276b63d71e1b9c0e Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/android/src/androidjnimain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 5941737fde..b51c15c5d9 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -455,7 +455,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para env->ReleaseStringUTFChars(environmentString, nativeString); m_applicationParams=string.split('\t'); foreach (string, m_applicationParams) { - if (putenv(string.constData())) + if (!string.isEmpty() && putenv(string.constData())) qWarning() << "Can't set environment" << string; } -- cgit v1.2.3 From 9a683bfb84464bbf051236c4e3c2710219cbf0d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 19:37:39 +0200 Subject: QCocoaApplicationDelegate: Play nice with the user's application delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We tended to ignore the original application delegate a bit too often. Change-Id: I0844c8658d128e4fbb9a6fc5000025f55e5293c2 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 423d552627..f9767ce716 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -210,9 +210,10 @@ static void cleanupCocoaApplicationDelegate() - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { // The reflection delegate gets precedence - if (reflectionDelegate - && [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) { - return [reflectionDelegate applicationShouldTerminate:sender]; + if (reflectionDelegate) { + if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) + return [reflectionDelegate applicationShouldTerminate:sender]; + return NSTerminateNow; } if ([self canQuit]) { @@ -327,12 +328,11 @@ static void cleanupCocoaApplicationDelegate() - (void)applicationDidBecomeActive:(NSNotification *)notification { - Q_UNUSED(notification); -/* if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationDidBecomeActive:)]) [reflectionDelegate applicationDidBecomeActive:notification]; +/* onApplicationChangedActivation(true); if (!QWidget::mouseGrabber()){ @@ -351,12 +351,11 @@ static void cleanupCocoaApplicationDelegate() - (void)applicationDidResignActive:(NSNotification *)notification { - Q_UNUSED(notification); -/* if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationDidResignActive:)]) [reflectionDelegate applicationDidResignActive:notification]; +/* onApplicationChangedActivation(false); if (!QWidget::mouseGrabber()) -- cgit v1.2.3 From 279db88c39ae51db2cde80559e30e52457536d12 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 26 Sep 2013 15:55:03 +0200 Subject: Correct the detection of Windows-generated mouse events Check only bit 8 to decide if the mouse event is generated from a touch or pen event. Task-number: QTBUG-33460 Change-Id: I83b23267b5de6df5e0e6b7113ecf377dd7e86c84 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge --- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3782b7e020..3dd8c5a0cd 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -168,11 +168,13 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, return translateMouseWheelEvent(window, hwnd, msg, result); #ifndef Q_OS_WINCE - // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. static const bool passSynthesizedMouseEvents = QWindowsIntegration::instance()->options() & QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch; if (!passSynthesizedMouseEvents) { + // Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch. + // However, when tablet support is active, extraInfo is a packet serial number. This is not a problem + // since we do not want to ignore mouse events coming from a tablet. const quint64 extraInfo = GetMessageExtraInfo(); - const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff); + const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0x80); if (fromTouch) return false; } -- cgit v1.2.3 From 5889b239b17b27f0c93fe4f8a56fc1cc32708e8b Mon Sep 17 00:00:00 2001 From: Vitalii Shastun Date: Fri, 20 Sep 2013 18:23:33 +0300 Subject: Fix QT_NO_PRINTER build on Mac On Mac the QT_NO_PRINTER build was not implemented. Task-number: QTBUG-33565 Change-Id: I118472f9400aa0a0d0e192ae39a11ea38a66f340 Reviewed-by: John Layt --- src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 4 ++-- src/plugins/platforms/cocoa/qcocoaprintersupport.h | 2 ++ src/plugins/platforms/cocoa/qcocoaprintersupport.mm | 4 ++++ src/plugins/platforms/cocoa/qpaintengine_mac.mm | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 873fa3eed9..a53a6bca46 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -133,7 +133,7 @@ void QCocoaNativeInterface::beep() QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() { -#ifndef QT_NO_WIDGETS +#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) return new QCocoaPrinterSupport(); #else qFatal("Printing is not supported when Qt is configured with -no-widgets"); @@ -143,7 +143,7 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine) { -#ifndef QT_NO_WIDGETS +#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) QMacPrintEnginePrivate *macPrintEnginePriv = static_cast(printEngine)->d_func(); if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized()) macPrintEnginePriv->initialize(); diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.h b/src/plugins/platforms/cocoa/qcocoaprintersupport.h index 83cf1ffada..a48790ef34 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.h +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.h @@ -43,6 +43,7 @@ #define QCOCOAPRINTERSUPPORT_H #include +#ifndef QT_NO_PRINTER #include "qt_mac_p.h" @@ -64,4 +65,5 @@ private: QPrinterInfo printerInfoFromPMPrinter(const PMPrinter &printer); }; +#endif // QT_NO_PRINTER #endif // QCOCOAPRINTERSUPPORT_H diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm index cfa23b7a30..cb2aa7132b 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm @@ -40,6 +40,8 @@ ****************************************************************************/ #include "qcocoaprintersupport.h" + +#ifndef QT_NO_PRINTER #include "qprintengine_mac_p.h" #include @@ -169,3 +171,5 @@ QList > QCocoaPrinterSupport::supportedSizesWithNames(con PMRelease(printer); return returnValue; } + +#endif //QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index dc3757ce3c..40d60a6a0a 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -117,8 +117,10 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor QMacCGContext::QMacCGContext(QPainter *p) { QPaintEngine *pe = p->paintEngine(); +#ifndef QT_NO_PRINTER if (pe->type() == QPaintEngine::MacPrinter) pe = static_cast(pe)->paintEngine(); +#endif pe->syncState(); context = 0; if (pe->type() == QPaintEngine::CoreGraphics) -- cgit v1.2.3 From 5b70efb1258fd7435e8cfbed1a54abb46db0adcc Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 26 Sep 2013 13:37:08 +0200 Subject: Mac: QWizard default background pixmap works again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-26722 Change-Id: I579111b5d34f8e3cdc6bb016d9c0e42ec3ffb8c9 Reviewed-by: Morten Johan Sørvig Reviewed-by: Gabriel de Dietrich Reviewed-by: Stephen Chu --- .../platforms/cocoa/qcocoanativeinterface.h | 6 +++++ .../platforms/cocoa/qcocoanativeinterface.mm | 26 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 2e5e65f577..d30b281eb8 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -45,6 +45,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -91,6 +92,11 @@ private: Needed by the native print dialog in the Qt Print Support module. */ Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine); + /* + Function to return the default background pixmap. + Needed by QWizard in the Qt widget module. + */ + Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard(); // QMacPastebardMime support. The mac pasteboard void pointers are // QMacPastebardMime instances from the cocoa plugin or qtmacextras diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index a53a6bca46..972c171f69 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,6 +50,7 @@ #include #include +#include #include #include "qsurfaceformat.h" #include @@ -154,6 +155,31 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine #endif } +QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() +{ + QCFType url; + const int ExpectedImageWidth = 242; + const int ExpectedImageHeight = 414; + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), + 0, 0, &url) == noErr) { + QCFType bundle = CFBundleCreate(kCFAllocatorDefault, url); + if (bundle) { + url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); + if (url) { + QCFType imageSource = CGImageSourceCreateWithURL(url, 0); + QCFType image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); + if (image) { + int width = CGImageGetWidth(image); + int height = CGImageGetHeight(image); + if (width == ExpectedImageWidth && height == ExpectedImageHeight) + return QPixmap::fromImage(qt_mac_toQImage(image)); + } + } + } + } + return QPixmap(); +} + void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window) { Q_UNUSED(window); -- cgit v1.2.3 From f37990712b217b4f8136d70675cb259f61548556 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 26 Sep 2013 16:22:19 +0200 Subject: [QNSView viewWillMoveToWindow:] remove observer from previous window Even if there is not a new window, the notifications from the old one are not needed. Change-Id: I9c1858d25e49379ca4737e23beec06623e91b69c Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b8a31329fe..ab098b08bf 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -204,9 +204,9 @@ static QTouchDevice *touchDevice = 0; selector:@selector(windowNotification:) name:nil // Get all notifications object:newWindow]; - } else { - [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]]; } + if ([self window]) + [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]]; } - (void)updateGeometry { -- cgit v1.2.3 From 79fc0ff67a4f0b606d3a321914c156fc66d8fb58 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Sep 2013 18:18:47 +0200 Subject: QCocoaBackingStore: Initialize non-opaque images with transparent color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In particular, this is needed when a QWidget has WA_TranslucentBackground set and nobody is painting anything behind it (except maybe some native view). Change-Id: Ib1f0714f85fa7eeced527617ecd09bb2ed6ddfc9 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 4881dcef71..665b3d4c13 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -77,6 +77,8 @@ QPaintDevice *QCocoaBackingStore::paintDevice() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; m_qImage = QImage(m_requestedSize * scaleFactor, format); m_qImage.setDevicePixelRatio(scaleFactor); + if (format == QImage::Format_ARGB32_Premultiplied) + m_qImage.fill(Qt::transparent); } return &m_qImage; } -- cgit v1.2.3 From 06e7d61b688778c47d2a29093384801ce6c9d55e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 19:40:44 +0200 Subject: Cocoa: Allow widgets to receive events event when no app is running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is necessary for QMacNativeWidget, where there exists a QApplication, but is never executed. This directly translates in calls to the event dispatcher's processEvents() function, whose calls we keep track. If no calls have been made, we always allow timer and posted events to be processed. Change-Id: Ia0062ee8c59a2572082f520a2eb85ed44a9856a7 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.h | 1 + src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 93476ee1b4..33d7dcbcf4 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -165,6 +165,7 @@ public: bool currentExecIsNSAppRun; bool nsAppRunCalledByQt; bool cleanupModalSessionsNeeded; + uint processEventsCalled; NSModalSession currentModalSessionCached; NSModalSession currentModalSession(); void updateChildrenWorksWhenModal(); diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 8dfaacdf13..ee69cd7d86 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -118,7 +118,7 @@ static Boolean runLoopSourceEqualCallback(const void *info1, const void *info2) void QCocoaEventDispatcherPrivate::runLoopTimerCallback(CFRunLoopTimerRef, void *info) { QCocoaEventDispatcherPrivate *d = static_cast(info); - if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { + if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // processEvents() was called "manually," ignore this source for now d->maybeCancelWaitForMoreEvents(); return; @@ -364,6 +364,12 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) uint oldflags = d->processEventsFlags; d->processEventsFlags = flags; + + // Used to determine whether any eventloop has been exec'ed, and allow posted + // and timer events to be processed even if this function has never been called + // instead of being kept on hold for the next run of processEvents(). + ++d->processEventsCalled; + bool excludeUserEvents = d->processEventsFlags & QEventLoop::ExcludeUserInputEvents; bool retVal = false; forever { @@ -517,6 +523,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) } d->processEventsFlags = oldflags; + --d->processEventsCalled; // If we're interrupted, we need to interrupt the _current_ // recursion as well to check if it is still supposed to be @@ -770,6 +777,7 @@ QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate() currentExecIsNSAppRun(false), nsAppRunCalledByQt(false), cleanupModalSessionsNeeded(false), + processEventsCalled(0), currentModalSessionCached(0), lastSerial(-1), interrupt(false) @@ -893,7 +901,7 @@ void QCocoaEventDispatcherPrivate::firstLoopEntry(CFRunLoopObserverRef ref, void QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *info) { QCocoaEventDispatcherPrivate *d = static_cast(info); - if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { + if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // processEvents() was called "manually," ignore this source for now d->maybeCancelWaitForMoreEvents(); return; -- cgit v1.2.3