diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-27 11:31:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-27 11:31:32 +0200 |
commit | 150b8ca29417de2cd423ff92478eaf4cb2906601 (patch) | |
tree | aa1c43ee9d096a4464636bcb5f294a11846572f4 /src/plugins | |
parent | bd78389fc4fe0a4367696ba2fdcc6e8d09863698 (diff) | |
parent | 16a36239ab9e9be45a940aeff94f35e29bdeb944 (diff) |
Merge "Merge branch 'stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/plugins')
12 files changed, 68 insertions, 16 deletions
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; } 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()) 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; } 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<QCocoaEventDispatcherPrivate *>(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<QCocoaEventDispatcherPrivate *>(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; 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 <ApplicationServices/ApplicationServices.h> #include <qpa/qplatformnativeinterface.h> +#include <QtGui/qpixmap.h> 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 873fa3eed9..972c171f69 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,6 +50,7 @@ #include <qbytearray.h> #include <qwindow.h> +#include <qpixmap.h> #include <qpa/qplatformwindow.h> #include "qsurfaceformat.h" #include <qpa/qplatformopenglcontext.h> @@ -133,7 +134,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 +144,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<QMacPrintEngine *>(printEngine)->d_func(); if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized()) macPrintEnginePriv->initialize(); @@ -154,6 +155,31 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine #endif } +QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() +{ + QCFType<CFURLRef> url; + const int ExpectedImageWidth = 242; + const int ExpectedImageHeight = 414; + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), + 0, 0, &url) == noErr) { + QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); + if (bundle) { + url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); + if (url) { + QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); + QCFType<CGImageRef> 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); 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 <qpa/qplatformprintersupport.h> +#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 <QtPrintSupport/QPrinter> @@ -169,3 +171,5 @@ QList<QPair<QString, QSizeF> > QCocoaPrinterSupport::supportedSizesWithNames(con PMRelease(printer); return returnValue; } + +#endif //QT_NO_PRINTER 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 { 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<QMacPrintEngine*>(pe)->paintEngine(); +#endif pe->syncState(); context = 0; if (pe->type() == QPaintEngine::CoreGraphics) 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; } |