From fb4c976a0e0b5c6b8dfb7d7c35fe8e6772d4a876 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Fri, 16 Mar 2012 16:19:13 +0100 Subject: Cocoa: Send keyboard modifiers with wheel events. Read and save the modifiers at the beginning of the event stream to keep the event interpretation constant for the entire event stream. Change-Id: I66046dea8f8fd3ff2f88c48da5f076377bda32dd Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index f09c9331f6..2b7caae688 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -61,6 +61,7 @@ QT_END_NAMESPACE QString m_composingText; bool m_keyEventsAccepted; QStringList *currentCustomDragTypes; + Qt::KeyboardModifiers currentWheelModifiers; } - (id)init; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3a697a3602..ed67fd50fc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -545,7 +545,31 @@ static QTouchDevice *touchDevice = 0; NSTimeInterval timestamp = [theEvent timestamp]; ulong qt_timestamp = timestamp * 1000; - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta); + // Set keyboard modifiers depending on event phase. A two-finger trackpad flick + // generates a stream of scroll events. We want the keyboard modifier state to + // be the state at the beginning of the flick in order to avoid changing the + // interpretation of the events mid-stream. One example of this happening would + // be when pressing cmd after scrolling in Qt Creator: not taking the phase into + // account causes the end of the event stream to be interpreted as font size changes. + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) { + NSEventPhase phase = [theEvent phase]; + if (phase == NSEventPhaseBegan) { + currentWheelModifiers = [self convertKeyModifiers:[theEvent modifierFlags]]; + } + + QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta, currentWheelModifiers); + + if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) { + currentWheelModifiers = Qt::NoModifier; + } + } +#else + QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta, + [self convertKeyModifiers:[theEvent modifierFlags]]); +#endif + } #endif //QT_NO_WHEELEVENT -- cgit v1.2.3 From 4bcd8fc2dee683da632466e6de5d782f52263951 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 19 Mar 2012 15:31:17 +0200 Subject: Fix infinite recursion crash in QPrinterInfo::supportedPaperSizes() This function calls platform specific function QWindowsPrinterSupport::supportedPaperSizes(), which then called back to QPrinterInfo::supportedPaperSizes(), causing infinite recursion. Fixed by providing a proper implementation for querying supported paper sizes in QWin32PrintEngine - the same implementation was used in Qt 4.8. Task-number: QTBUG-24190 Change-Id: I64a2773d83596df19818bf2636f1255943d7851d Reviewed-by: Friedemann Kleint --- src/plugins/printsupport/windows/qwindowsprintersupport.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp index 9444038997..2905063c51 100644 --- a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp @@ -87,15 +87,9 @@ QPaintEngine *QWindowsPrinterSupport::createPaintEngine(QPrintEngine *engine, QP return static_cast(engine); } -QList QWindowsPrinterSupport::supportedPaperSizes(const QPrinterInfo &) const +QList QWindowsPrinterSupport::supportedPaperSizes(const QPrinterInfo &printerInfo) const { - QList returnList; - foreach (const QPrinterInfo &info, mPrinterList) { - foreach (const QPrinter::PaperSize supportedSize, info.supportedPaperSizes()) - if (!returnList.contains(supportedSize)) - returnList.append(supportedSize); - } - return returnList; + return QWin32PrintEngine::supportedPaperSizes(printerInfo); } QList QWindowsPrinterSupport::availablePrinters() -- cgit v1.2.3 From 336f24465a106553dae26ac84a3c43f9ad939a57 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Sun, 18 Mar 2012 18:44:31 -0700 Subject: Improves configure checks for XCB. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The XCB plugin requries libxcb >= 1.5. Configure and config.tests/qpa/xcb now check for this. Change-Id: I96c688b79bf5b49fd3ecc4ddc12ebdc2d3788790 Reviewed-by: Samuel Rødal Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/xcb/README | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README index 17e8bb53eb..eede0cc149 100644 --- a/src/plugins/platforms/xcb/README +++ b/src/plugins/platforms/xcb/README @@ -1,3 +1,5 @@ +Requires libxcb >= 1.5. + Required packages: libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev -- cgit v1.2.3 From 6d9f04422ac2b64e43f0e78c1fdb9ced29e4b187 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Tue, 13 Mar 2012 10:37:53 +0100 Subject: Cocoa: Implement support for child windows. On OS X, child windows (in the Qt sense) are not windows. Add special case to window creation that links the content views instead of creating a NSWindow. Add a similar special case to setGeometry(). Refactor window (re)creation into recreateWindow(), which is called from both the QCocoaWindow constructor and setParent(). m_nsWindow may now be null, add null-pointer checks to all usages. Change winId() to return the m_contentView pointer instead of m_nsWindow. QGLWidget now works, but probably has sibling window stacking issues which we won't be able to fix without moving to client-side compositing. Change-Id: I2e74cf27734dba7076c150e0d8341f0a62d3de2d Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qcocoawindow.h | 2 + src/plugins/platforms/cocoa/qcocoawindow.mm | 88 ++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 21 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 8bdb5535d5..0920bc7b4b 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -92,6 +92,7 @@ public: ~QCocoaWindow(); void setGeometry(const QRect &rect); + void setCocoaGeometry(const QRect &rect); void setVisible(bool visible); Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); void setWindowTitle(const QString &title); @@ -117,6 +118,7 @@ public: protected: // NSWindow handling. The QCocoaWindow/QNSView can either be displayed // in an existing NSWindow or in one created by Qt. + void recreateWindow(const QPlatformWindow *parentWindow); NSWindow *createNSWindow(); void setNSWindow(NSWindow *window); void clearNSWindow(NSWindow *window); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5c30e7f38b..d4327405cb 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -90,6 +90,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) : QPlatformWindow(tlw) + , m_nsWindow(0) , m_glContext(0) , m_inConstructor(true) { @@ -98,8 +99,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) m_contentView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this]; setGeometry(tlw->geometry()); - m_nsWindow = createNSWindow(); - setNSWindow(m_nsWindow); + recreateWindow(parent()); m_inConstructor = false; } @@ -119,10 +119,18 @@ void QCocoaWindow::setGeometry(const QRect &rect) qDebug() << "QCocoaWindow::setGeometry" << this << rect; #endif QPlatformWindow::setGeometry(rect); + setCocoaGeometry(rect); +} - NSRect bounds = qt_mac_flipRect(rect, window()); - [m_nsWindow setContentSize : bounds.size]; - [m_nsWindow setFrameOrigin : bounds.origin]; +void QCocoaWindow::setCocoaGeometry(const QRect &rect) +{ + if (m_nsWindow) { + NSRect bounds = qt_mac_flipRect(rect, window()); + [m_nsWindow setContentSize : bounds.size]; + [m_nsWindow setFrameOrigin : bounds.origin]; + } else { + [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())]; + } } void QCocoaWindow::setVisible(bool visible) @@ -151,13 +159,16 @@ void QCocoaWindow::setVisible(bool visible) // Make sure the QWindow has a frame ready before we show the NSWindow. QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size())); - if ([m_nsWindow canBecomeKeyWindow]) - [m_nsWindow makeKeyAndOrderFront:nil]; - else - [m_nsWindow orderFront: nil]; + if (m_nsWindow) { + if ([m_nsWindow canBecomeKeyWindow]) + [m_nsWindow makeKeyAndOrderFront:nil]; + else + [m_nsWindow orderFront: nil]; + } } else { // qDebug() << "close" << this; - [m_nsWindow orderOut:m_nsWindow]; + if (m_nsWindow) + [m_nsWindow orderOut:m_nsWindow]; } } @@ -170,6 +181,8 @@ Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) void QCocoaWindow::setWindowTitle(const QString &title) { QCocoaAutoReleasePool pool; + if (!m_nsWindow) + return; CFStringRef windowTitle = QCFString::toCFStringRef(title); [m_nsWindow setTitle: const_cast(reinterpret_cast(windowTitle))]; @@ -180,17 +193,21 @@ void QCocoaWindow::raise() { //qDebug() << "raise" << this; // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm) - [m_nsWindow orderFront: m_nsWindow]; + if (m_nsWindow) + [m_nsWindow orderFront: m_nsWindow]; } void QCocoaWindow::lower() { - [m_nsWindow orderBack: m_nsWindow]; + if (m_nsWindow) + [m_nsWindow orderBack: m_nsWindow]; } void QCocoaWindow::propagateSizeHints() { QCocoaAutoReleasePool pool; + if (!m_nsWindow) + return; [m_nsWindow setMinSize : qt_mac_toNSSize(window()->minimumSize())]; [m_nsWindow setMaxSize : qt_mac_toNSSize(window()->maximumSize())]; @@ -213,6 +230,9 @@ void QCocoaWindow::propagateSizeHints() bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) { + if (!m_nsWindow) + return false; + if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) @@ -222,6 +242,9 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) bool QCocoaWindow::setMouseGrabEnabled(bool grab) { + if (!m_nsWindow) + return false; + if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) @@ -231,23 +254,19 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab) WId QCocoaWindow::winId() const { - return WId(m_nsWindow); + return WId(m_contentView); } -void QCocoaWindow::setParent(const QPlatformWindow *window) +void QCocoaWindow::setParent(const QPlatformWindow *parentWindow) { // recreate the window for compatibility - clearNSWindow(m_nsWindow); - [m_nsWindow close]; - [m_nsWindow release]; - - m_nsWindow = createNSWindow(); - setNSWindow(m_nsWindow); + recreateWindow(parentWindow); + setCocoaGeometry(geometry()); } NSView *QCocoaWindow::contentView() const { - return [m_nsWindow contentView]; + return m_contentView; } void QCocoaWindow::windowWillMove() @@ -266,6 +285,9 @@ void QCocoaWindow::windowDidMove() void QCocoaWindow::windowDidResize() { + if (!m_nsWindow) + return; + NSRect rect = [[m_nsWindow contentView]frame]; // Call setFrameSize which will trigger a frameDidChangeNotification on QNSView. [[m_nsWindow contentView] setFrameSize:rect.size]; @@ -286,6 +308,27 @@ QCocoaGLContext *QCocoaWindow::currentContext() const return m_glContext; } +void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) +{ + // Remove current window (if any) + if (m_nsWindow) { + clearNSWindow(m_nsWindow); + [m_nsWindow close]; + [m_nsWindow release]; + m_nsWindow = 0; + } + + if (!parentWindow) { + // Create a new NSWindow if this is a top-level window. + m_nsWindow = createNSWindow(); + setNSWindow(m_nsWindow); + } else { + // Child windows have no NSWindow, link the NSViews instead. + const QCocoaWindow *parentCococaWindow = static_cast(parentWindow); + [parentCococaWindow->m_contentView addSubview : m_contentView]; + } +} + NSWindow * QCocoaWindow::createNSWindow() { QCocoaAutoReleasePool pool; @@ -378,6 +421,9 @@ void QCocoaWindow::clearNSWindow(NSWindow *window) // Returns the current global screen geometry for the nswindow associated with this window. QRect QCocoaWindow::windowGeometry() const { + if (!m_nsWindow) + return geometry(); + NSRect rect = [m_nsWindow frame]; QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window()); int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y. -- cgit v1.2.3 From 9f4d567f4357392f1a7cfdb7408dec2fc2793b41 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 19 Mar 2012 13:51:53 +0100 Subject: Cocoa: set font engine glyph format based on display type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the QCoreTextFontEngine::glyphFormat depend on the primary display's subpixel layout (if any). This change also refactors the antialiasing threshold setting to live beside the defaultGlyphFormat. Change-Id: I27f94f775d91d2a68cd647cc24503b31b6ff5e61 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/cocoa.pro | 2 +- src/plugins/platforms/cocoa/qpaintengine_mac.mm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index e861f48e7b..2ae39dd16c 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -73,7 +73,7 @@ HEADERS += qcocoaintegration.h \ FORMS += $$PWD/../../../widgets/dialogs/qfiledialog.ui RESOURCES += qcocoaresources.qrc -LIBS += -framework Cocoa +LIBS += -framework Cocoa -framework IOKit QT += core-private gui-private widgets-private platformsupport-private printsupport diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index 8b8445c995..87f3713920 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -73,8 +73,6 @@ QT_BEGIN_NAMESPACE -extern int qt_antialiasing_threshold; // from qcoretextfontdatabase.mm - /***************************************************************************** QCoreGraphicsPaintEngine utility functions *****************************************************************************/ @@ -1182,7 +1180,9 @@ void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem QFontEngine *fe = ti.fontEngine; - const bool textAA = state->renderHints() & QPainter::TextAntialiasing && fe->fontDef.pointSize > qt_antialiasing_threshold && !(fe->fontDef.styleStrategy & QFont::NoAntialias); + const bool textAA = ((state->renderHints() & QPainter::TextAntialiasing) + && (fe->fontDef.pointSize > QCoreTextFontEngine::antialiasingThreshold) + && !(fe->fontDef.styleStrategy & QFont::NoAntialias)); const bool lineAA = state->renderHints() & QPainter::Antialiasing; if (textAA != lineAA) CGContextSetShouldAntialias(d->hd, textAA); -- cgit v1.2.3 From 10537187b978df899a20e9997b859c60841bb5cc Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Tue, 20 Mar 2012 08:32:55 +0100 Subject: Cocoa: Panels can become key windows too. The cocoa plugin uses NSPanel instead of NSWindow for popup-type windows. With the exception of tooltips and splash screens these windows should take input focus as well. Change-Id: Icdf0854e7c511ccc106e035dae4763ae90c23aa5 Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qcocoawindow.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index d4327405cb..a76830f0b8 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -83,7 +83,12 @@ - (BOOL)canBecomeKeyWindow { - return NO; + // Most panels can be come the key window. Exceptions are: + if (m_cocoaPlatformWindow->window()->windowType() == Qt::ToolTip) + return NO; + if (m_cocoaPlatformWindow->window()->windowType() == Qt::SplashScreen) + return NO; + return YES; } @end @@ -357,6 +362,7 @@ NSWindow * QCocoaWindow::createNSWindow() defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up // before the window is shown and needs a proper window.). [window setHasShadow:YES]; + window->m_cocoaPlatformWindow = this; createdWindow = window; } else { styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask); -- cgit v1.2.3 From 9cf35d124192e09848ceda2c5af291935cef221a Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 16 Mar 2012 17:07:42 -0700 Subject: Add egl include paths and link lines to eglfs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the equivalent of 821fc4cf4e520a74b8d4c834f2fb46e4e2f27001 from qt4 but done differently because qt5 has egl.prf. Change-Id: I52114239bdeda6c300db04a7859cae52aa9e9b41 Reviewed-by: Samuel Rødal --- src/plugins/platforms/eglfs/eglfs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index ed8503b53c..80c5579cfb 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -24,7 +24,7 @@ HEADERS = qeglfsintegration.h \ qeglfsbackingstore.h \ qeglfsscreen.h -CONFIG += qpa/genericunixfontdatabase +CONFIG += egl qpa/genericunixfontdatabase target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v1.2.3 From 2003b83f6f09d478aa490334076d8870f6e32a6e Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Mon, 19 Mar 2012 13:45:42 +0000 Subject: Avoid Qt/X11 header contamination via egl.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit egl.h on certain platforms directly includes X11 headers, resulting in an all too familiar header conflict. There are existing defines we merely need to set in order to avoid this eventuality. Change-Id: Ic91b66286ad6cc329f9c88b5e47834690a8eb96a Reviewed-by: Samuel Rødal --- src/plugins/platforms/eglfs/eglfs.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 80c5579cfb..86a1b8239c 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -13,6 +13,9 @@ DESTDIR = $$QT.gui.plugins/platforms #DEFINES += Q_OPENKODE +#Avoid X11 header collision +DEFINES += MESA_EGL_NO_X11_HEADERS + SOURCES = main.cpp \ qeglfsintegration.cpp \ qeglfswindow.cpp \ -- cgit v1.2.3 From b936b959650128bb8befaaa069477629105c680d Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Wed, 7 Mar 2012 14:07:07 +0000 Subject: EGLFS: Integrate building into configure. With the move to the QPA architecture EGL is now only required by individual platform plugins and the configure script has been adjusted to reflect this. Change-Id: Ieadacef0b970f29752d9e3e36a007e5cbb005b0d Reviewed-by: Oswald Buddenhagen Reviewed-by: Girish Ramakrishnan --- src/plugins/platforms/platforms.pro | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index c97c1def0c..692332291c 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -15,3 +15,7 @@ win32: SUBDIRS += windows qnx-*-qcc { SUBDIRS += qnx } + +contains(QT_CONFIG, eglfs) { + SUBDIRS += eglfs +} -- cgit v1.2.3 From bf469e923ef97ed260ddfb9b529fd503a841485e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 20 Mar 2012 10:53:45 +0100 Subject: Cocoa: fix inactive palette text color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QPalette::Inactive text color should be the same as kThemeTextColorDialogActive. kThemeTextColorDialogInactive is for disabled widgets/windows. Change-Id: I55eb63fff213cb9870a991455cbc3254b9d1538e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoasystemsettings.mm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index c2f5df4d38..d02154b006 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -122,24 +122,25 @@ QPalette * qt_mac_createSystemPalette() palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); // System palette initialization: - palette->setBrush( QPalette::Active, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushPrimaryHighlightColor) ); - palette->setBrush( QPalette::Inactive, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor) ); + palette->setBrush(QPalette::Active, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushPrimaryHighlightColor)); + qc = qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor); + palette->setBrush(QPalette::Inactive, QPalette::Highlight, qc); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, qc); - palette->setBrush( QPalette::Disabled, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor) ); - palette->setBrush( QPalette::Active, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonActiveDarkShadow) ); - - palette->setBrush( QPalette::Inactive, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow) ); - palette->setBrush( QPalette::Disabled, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow) ); + palette->setBrush(QPalette::Active, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonActiveDarkShadow)); + qc = qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow); + palette->setBrush(QPalette::Inactive, QPalette::Shadow, qc); + palette->setBrush(QPalette::Disabled, QPalette::Shadow, qc); qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogActive); palette->setColor(QPalette::Active, QPalette::Text, qc); palette->setColor(QPalette::Active, QPalette::WindowText, qc); palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); - - qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogInactive); palette->setColor(QPalette::Inactive, QPalette::Text, qc); palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + + qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogInactive); palette->setColor(QPalette::Disabled, QPalette::Text, qc); palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); -- cgit v1.2.3 From 7f18dbc30c86464f8b86d8ab82966a40f5834fcf Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Fri, 16 Mar 2012 14:26:15 +0100 Subject: Cocoa: Implement screen availableGeometry. As usual the y coordinate needs to be inverted. Change-Id: Iac9b48f9bdb475a3d5a76b930c2e138a625f1ef8 Reviewed-by: Bradley T. Hughes Reviewed-by: Marius Storm-Olsen --- src/plugins/platforms/cocoa/qcocoaintegration.h | 2 ++ src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 97e7a7ffde..fb3ee3290e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -61,6 +61,7 @@ public: ~QCocoaScreen(); QRect geometry() const { return m_geometry; } + QRect availableGeometry() const { return m_availableGeometry; } int depth() const { return m_depth; } QImage::Format format() const { return m_format; } QSizeF physicalSize() const { return m_physicalSize; } @@ -69,6 +70,7 @@ public: public: NSScreen *m_screen; QRect m_geometry; + QRect m_availableGeometry; int m_depth; QImage::Format m_format; QSizeF m_physicalSize; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index f5febd4a16..f91351ad46 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -69,8 +69,12 @@ QCocoaScreen::QCocoaScreen(int screenIndex) :QPlatformScreen() { m_screen = [[NSScreen screens] objectAtIndex:screenIndex]; - NSRect rect = [m_screen frame]; - m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); + NSRect frameRect = [m_screen frame]; + m_geometry = QRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height); + NSRect visibleRect = [m_screen visibleFrame]; + m_availableGeometry = QRect(visibleRect.origin.x, + frameRect.size.height - (visibleRect.origin.y + visibleRect.size.height), // invert y + visibleRect.size.width, visibleRect.size.height); m_format = QImage::Format_RGB32; -- cgit v1.2.3 From 7445d41e32e5d241b5c124b7f81c0ae31c36ffc2 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Wed, 21 Mar 2012 08:47:16 +0100 Subject: Cocoa: Improve window activation handling. Make Qt window activation follow the Cocoa key window, with one exception: Popup windows become the key window but not the Qt active window. Change-Id: Ic4d8685737fa3ec5c15a68b81844929370c9cd8e Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 11 ++++++++++- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 0920bc7b4b..90c5a050d0 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -111,6 +111,7 @@ public: void windowDidMove(); void windowDidResize(); void windowWillClose(); + bool windowIsPopupType() const; void setCurrentContext(QCocoaGLContext *context); QCocoaGLContext *currentContext() const; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a76830f0b8..b4c4e31753 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -303,6 +303,15 @@ void QCocoaWindow::windowWillClose() QWindowSystemInterface::handleSynchronousCloseEvent(window()); } +bool QCocoaWindow::windowIsPopupType() const +{ + Qt::WindowType type = window()->windowType(); + if (type == Qt::Tool) + return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac. + + return ((type & Qt::Popup) == Qt::Popup); +} + void QCocoaWindow::setCurrentContext(QCocoaGLContext *context) { m_glContext = context; @@ -348,7 +357,7 @@ NSWindow * QCocoaWindow::createNSWindow() // Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen) if ((type & Qt::Popup) == Qt::Popup) { - if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::SplashScreen) { + if (windowIsPopupType()) { styleMask = NSBorderlessWindowMask; } else { styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask | diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ed67fd50fc..52f40ea01c 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -146,24 +146,24 @@ static QTouchDevice *touchDevice = 0; - (void)windowDidBecomeKey { -// QWindowSystemInterface::handleWindowActivated(m_window); + if (!m_platformWindow->windowIsPopupType()) + QWindowSystemInterface::handleWindowActivated(m_window); } - (void)windowDidResignKey { -// QWindowSystemInterface::handleWindowActivated(0); + if (!m_platformWindow->windowIsPopupType()) + QWindowSystemInterface::handleWindowActivated(0); } - (void)windowDidBecomeMain { // qDebug() << "window did become main" << m_window; - QWindowSystemInterface::handleWindowActivated(m_window); } - (void)windowDidResignMain { // qDebug() << "window did resign main" << m_window; - QWindowSystemInterface::handleWindowActivated(0); } -- cgit v1.2.3 From 5672e1affe3885fe74a4b55444f0ab0c989dbfcb Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 11:08:14 +0100 Subject: Cocoa: improve mouse button tracking warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warnings about "Internal mouse button tracking invalid" should check for the correct button before emitting a warning. The warning should also mention the correct button as well. For otherMouseDragged, we simply check for any button that's not the left or right button. Change-Id: I9eb6d6bd7fb5919e745b7f8eb517b4bc9efd36a6 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 52f40ea01c..d7f6310f6e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -304,7 +304,7 @@ static QTouchDevice *touchDevice = 0; - (void)mouseDragged:(NSEvent *)theEvent { if (!(m_buttons & Qt::LeftButton)) - qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + qWarning("QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)"); [self handleMouseEvent:theEvent]; } @@ -339,8 +339,8 @@ static QTouchDevice *touchDevice = 0; - (void)rightMouseDragged:(NSEvent *)theEvent { - if (!(m_buttons & Qt::LeftButton)) - qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + if (!(m_buttons & Qt::RightButton)) + qWarning("QNSView rightMouseDragged: Internal mouse button tracking invalid (missing Qt::RightButton)"); [self handleMouseEvent:theEvent]; } @@ -404,8 +404,8 @@ static QTouchDevice *touchDevice = 0; - (void)otherMouseDragged:(NSEvent *)theEvent { - if (!(m_buttons & Qt::LeftButton)) - qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + if (!(m_buttons & ~(Qt::LeftButton | Qt::RightButton))) + qWarning("QNSView otherMouseDragged: Internal mouse button tracking invalid (missing Qt::MiddleButton or Qt::ExtraButton*)"); [self handleMouseEvent:theEvent]; } -- cgit v1.2.3 From 9dc86ac0f2d019f93665c1ae0e3c2cd33fd88bce Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Tue, 20 Mar 2012 11:27:52 +0100 Subject: Use main thread event loop for navigator event processing Removes the need for an extra thread by creating the event handler's socket notifier in the context of the main thread. Change-Id: If8c7bb986074083b5b9a7b9c96734a970ba32f92 Reviewed-by: Sean Harmer Reviewed-by: Robin Burchell --- src/plugins/platforms/qnx/qnx.pro | 6 +- src/plugins/platforms/qnx/qqnxintegration.cpp | 18 +- src/plugins/platforms/qnx/qqnxintegration.h | 4 +- .../platforms/qnx/qqnxnavigatoreventhandler.cpp | 258 +++++++++++++++++++ .../platforms/qnx/qqnxnavigatoreventhandler.h | 77 ++++++ src/plugins/platforms/qnx/qqnxnavigatorthread.cpp | 280 --------------------- src/plugins/platforms/qnx/qqnxnavigatorthread.h | 78 ------ 7 files changed, 352 insertions(+), 369 deletions(-) create mode 100644 src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp create mode 100644 src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h delete mode 100644 src/plugins/platforms/qnx/qqnxnavigatorthread.cpp delete mode 100644 src/plugins/platforms/qnx/qqnxnavigatorthread.h (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 1bd3548b7d..cf82084de0 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -16,7 +16,7 @@ QT += opengl opengl-private platformsupport platformsupport-private widgets-priv #DEFINES += QQNXINPUTCONTEXT_DEBUG #DEFINES += QQNXINPUTCONTEXT_IMF_EVENT_DEBUG #DEFINES += QQNXINTEGRATION_DEBUG -#DEFINES += QQNXNAVIGATORTHREAD_DEBUG +#DEFINES += QQNXNAVIGATOREVENTHANDLER_DEBUG #DEFINES += QQNXRASTERBACKINGSTORE_DEBUG #DEFINES += QQNXROOTWINDOW_DEBUG #DEFINES += QQNXSCREEN_DEBUG @@ -29,7 +29,7 @@ SOURCES = main.cpp \ qqnxglcontext.cpp \ qqnxglbackingstore.cpp \ qqnxintegration.cpp \ - qqnxnavigatorthread.cpp \ + qqnxnavigatoreventhandler.cpp \ qqnxscreen.cpp \ qqnxwindow.cpp \ qqnxrasterbackingstore.cpp \ @@ -41,7 +41,7 @@ HEADERS = qqnxbuffer.h \ qqnxeventthread.h \ qqnxkeytranslator.h \ qqnxintegration.h \ - qqnxnavigatorthread.h \ + qqnxnavigatoreventhandler.h \ qqnxglcontext.h \ qqnxglbackingstore.h \ qqnxscreen.h \ diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 2811661269..cb7f14f963 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -43,7 +43,7 @@ #include "qqnxeventthread.h" #include "qqnxglbackingstore.h" #include "qqnxglcontext.h" -#include "qqnxnavigatorthread.h" +#include "qqnxnavigatoreventhandler.h" #include "qqnxrasterbackingstore.h" #include "qqnxscreen.h" #include "qqnxwindow.h" @@ -77,7 +77,7 @@ QMutex QQnxIntegration::ms_windowMapperMutex; QQnxIntegration::QQnxIntegration() : QPlatformIntegration() , m_eventThread(0) - , m_navigatorThread(0) + , m_navigatorEventHandler(0) , m_inputContext(0) , m_fontDatabase(new QGenericUnixFontDatabase()) , m_paintUsingOpenGL(false) @@ -109,9 +109,15 @@ QQnxIntegration::QQnxIntegration() m_eventThread = new QQnxEventThread(m_screenContext, *QQnxScreen::primaryDisplay()); m_eventThread->start(); - // Create/start navigator thread - m_navigatorThread = new QQnxNavigatorThread(*QQnxScreen::primaryDisplay()); - m_navigatorThread->start(); + // Create/start navigator event handler + // Not on BlackBerry, it has specialised event dispatcher which also handles navigator events +#ifndef Q_OS_BLACKBERRY + m_navigatorEventHandler = new QQnxNavigatorEventHandler(*QQnxScreen::primaryDisplay()); + + // delay invocation of start() to the time the event loop is up and running + // needed to have the QThread internals of the main thread properly initialized + QMetaObject::invokeMethod(m_navigatorEventHandler, "start", Qt::QueuedConnection); +#endif // Create/start the keyboard class. QQnxVirtualKeyboard::instance(); @@ -137,7 +143,7 @@ QQnxIntegration::~QQnxIntegration() delete m_eventThread; // Stop/destroy navigator thread - delete m_navigatorThread; + delete m_navigatorEventHandler; // Destroy all displays QQnxScreen::destroyDisplays(); diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 51d06bd0e6..892bb6e16f 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE class QQnxEventThread; class QQnxInputContext; -class QQnxNavigatorThread; +class QQnxNavigatorEventHandler; class QQnxWindow; #ifndef QT_NO_CLIPBOARD @@ -99,7 +99,7 @@ private: screen_context_t m_screenContext; QQnxEventThread *m_eventThread; - QQnxNavigatorThread *m_navigatorThread; + QQnxNavigatorEventHandler *m_navigatorEventHandler; QQnxInputContext *m_inputContext; QPlatformFontDatabase *m_fontDatabase; bool m_paintUsingOpenGL; diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp new file mode 100644 index 0000000000..4db86cb5cf --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp @@ -0,0 +1,258 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqnxnavigatoreventhandler.h" +#include "qqnxscreen.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +static const char *navigatorControlPath = "/pps/services/navigator/control"; +static const int ppsBufferSize = 4096; + +QQnxNavigatorEventHandler::QQnxNavigatorEventHandler(QQnxScreen& primaryScreen) + : m_primaryScreen(primaryScreen), + m_fd(-1), + m_readNotifier(0) +{ +} + +QQnxNavigatorEventHandler::~QQnxNavigatorEventHandler() +{ + delete m_readNotifier; + + // close connection to navigator + if (m_fd != -1) + close(m_fd); + +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "QQNX: navigator event handler stopped"; +#endif +} + +void QQnxNavigatorEventHandler::start() +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "QQNX: navigator event handler started"; +#endif + + // open connection to navigator + errno = 0; + m_fd = open(navigatorControlPath, O_RDWR); + if (m_fd == -1) { + qWarning("QQNX: failed to open navigator pps, errno=%d", errno); + return; + } + + m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); + connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData())); +} + +void QQnxNavigatorEventHandler::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id) +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: data=" << ppsData; +#endif + + // tokenize pps data into lines + QList lines = ppsData.split('\n'); + + // validate pps object + if (lines.size() == 0 || lines.at(0) != "@control") { + qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); + } + + // parse pps object attributes and extract values + for (int i = 1; i < lines.size(); i++) { + + // tokenize current attribute + const QByteArray &attr = lines.at(i); + +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: attr=" << attr; +#endif + + int firstColon = attr.indexOf(':'); + if (firstColon == -1) { + // abort - malformed attribute + continue; + } + + int secondColon = attr.indexOf(':', firstColon + 1); + if (secondColon == -1) { + // abort - malformed attribute + continue; + } + + QByteArray key = attr.left(firstColon); + QByteArray value = attr.mid(secondColon + 1); + +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: key=" << key; + qDebug() << "PPS: val=" << value; +#endif + + // save attribute value + if (key == "msg") { + msg = value; + } else if (key == "dat") { + dat = value; + } else if (key == "id") { + id = value; + } else { + qFatal("QQNX: unrecognized pps attribute, attr=%s", key.constData()); + } + } +} + +void QQnxNavigatorEventHandler::replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat) +{ + // construct pps message + QByteArray ppsData = "res::"; + ppsData += res; + ppsData += "\nid::"; + ppsData += id; + if (!dat.isEmpty()) { + ppsData += "\ndat::"; + ppsData += dat; + } + ppsData += "\n"; + +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS reply=" << ppsData; +#endif + + // send pps message to navigator + errno = 0; + int bytes = write(m_fd, ppsData.constData(), ppsData.size()); + if (bytes == -1) { + qFatal("QQNX: failed to write navigator pps, errno=%d", errno); + } +} + +void QQnxNavigatorEventHandler::handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id) +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: msg=" << msg << ", dat=" << dat << ", id=" << id; +#endif + + // check message type + if (msg == "orientationCheck") { + + // reply to navigator that (any) orientation is acceptable +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: orientation check, o=" << dat; +#endif + replyPPS(msg, id, "true"); + + } else if (msg == "orientation") { + + // update screen geometry and reply to navigator that we're ready +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: orientation, o=" << dat; +#endif + m_primaryScreen.setRotation( dat.toInt() ); + QWindowSystemInterface::handleScreenGeometryChange(0, m_primaryScreen.geometry()); + replyPPS(msg, id, ""); + + } else if (msg == "SWIPE_DOWN") { + + // simulate menu key press +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: menu"; +#endif + QWindow *w = QGuiApplication::focusWindow(); + QWindowSystemInterface::handleKeyEvent(w, QEvent::KeyPress, Qt::Key_Menu, Qt::NoModifier); + QWindowSystemInterface::handleKeyEvent(w, QEvent::KeyRelease, Qt::Key_Menu, Qt::NoModifier); + + } else if (msg == "exit") { + + // shutdown everything +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "PPS: exit"; +#endif + QCoreApplication::quit(); + } +} + +void QQnxNavigatorEventHandler::readData() +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << "QQNX: reading navigator data"; +#endif + // allocate buffer for pps data + char buffer[ppsBufferSize]; + + // attempt to read pps data + errno = 0; + int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); + if (bytes == -1) { + qFatal("QQNX: failed to read navigator pps, errno=%d", errno); + } + + // check if pps data was received + if (bytes > 0) { + + // ensure data is null terminated + buffer[bytes] = '\0'; + + // process received message + QByteArray ppsData(buffer); + QByteArray msg; + QByteArray dat; + QByteArray id; + parsePPS(ppsData, msg, dat, id); + handleMessage(msg, dat, id); + } +} diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h new file mode 100644 index 0000000000..2e0bd1fa14 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h @@ -0,0 +1,77 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQNXNAVIGATOREVENTHANDLER_H +#define QQNXNAVIGATOREVENTHANDLER_H + +#include + +QT_BEGIN_NAMESPACE + +class QQnxScreen; +class QSocketNotifier; + +class QQnxNavigatorEventHandler : public QObject +{ + Q_OBJECT +public: + QQnxNavigatorEventHandler(QQnxScreen &primaryScreen); + virtual ~QQnxNavigatorEventHandler(); + +public Q_SLOTS: + void start(); + +private Q_SLOTS: + void readData(); + +private: + void parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id); + void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat); + void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id); + + QQnxScreen &m_primaryScreen; + int m_fd; + QSocketNotifier *m_readNotifier; +}; + +QT_END_NAMESPACE + +#endif // QQNXNAVIGATOREVENTHANDLER_H diff --git a/src/plugins/platforms/qnx/qqnxnavigatorthread.cpp b/src/plugins/platforms/qnx/qqnxnavigatorthread.cpp deleted file mode 100644 index def4cb7eb1..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorthread.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2011 - 2012 Research In Motion -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxnavigatorthread.h" -#include "qqnxscreen.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static const char *navigatorControlPath = "/pps/services/navigator/control"; -static const int ppsBufferSize = 4096; - -QQnxNavigatorThread::QQnxNavigatorThread(QQnxScreen& primaryScreen) - : m_primaryScreen(primaryScreen), - m_fd(-1), - m_readNotifier(0) -{ -} - -QQnxNavigatorThread::~QQnxNavigatorThread() -{ - // block until thread terminates - shutdown(); - - delete m_readNotifier; -} - -void QQnxNavigatorThread::run() -{ -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "QQNX: navigator thread started"; -#endif - - // open connection to navigator - errno = 0; - m_fd = open(navigatorControlPath, O_RDWR); - if (m_fd == -1) { - qWarning("QQNX: failed to open navigator pps, errno=%d", errno); - return; - } - - m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - // using direct connection to get the slot called in this thread's context - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData()), Qt::DirectConnection); - - exec(); - - // close connection to navigator - close(m_fd); - -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "QQNX: navigator thread stopped"; -#endif -} - -void QQnxNavigatorThread::shutdown() -{ -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "QQNX: navigator thread shutdown begin"; -#endif - - // signal thread to terminate - quit(); - - // block until thread terminates - wait(); - -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "QQNX: navigator thread shutdown end"; -#endif -} - -void QQnxNavigatorThread::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id) -{ -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: data=" << ppsData; -#endif - - // tokenize pps data into lines - QList lines = ppsData.split('\n'); - - // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") { - qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); - } - - // parse pps object attributes and extract values - for (int i = 1; i < lines.size(); i++) { - - // tokenize current attribute - const QByteArray &attr = lines.at(i); - -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: attr=" << attr; -#endif - - int firstColon = attr.indexOf(':'); - if (firstColon == -1) { - // abort - malformed attribute - continue; - } - - int secondColon = attr.indexOf(':', firstColon + 1); - if (secondColon == -1) { - // abort - malformed attribute - continue; - } - - QByteArray key = attr.left(firstColon); - QByteArray value = attr.mid(secondColon + 1); - -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: key=" << key; - qDebug() << "PPS: val=" << value; -#endif - - // save attribute value - if (key == "msg") { - msg = value; - } else if (key == "dat") { - dat = value; - } else if (key == "id") { - id = value; - } else { - qFatal("QQNX: unrecognized pps attribute, attr=%s", key.constData()); - } - } -} - -void QQnxNavigatorThread::replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat) -{ - // construct pps message - QByteArray ppsData = "res::"; - ppsData += res; - ppsData += "\nid::"; - ppsData += id; - if (!dat.isEmpty()) { - ppsData += "\ndat::"; - ppsData += dat; - } - ppsData += "\n"; - -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS reply=" << ppsData; -#endif - - // send pps message to navigator - errno = 0; - int bytes = write(m_fd, ppsData.constData(), ppsData.size()); - if (bytes == -1) { - qFatal("QQNX: failed to write navigator pps, errno=%d", errno); - } -} - -void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id) -{ -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: msg=" << msg << ", dat=" << dat << ", id=" << id; -#endif - - // check message type - if (msg == "orientationCheck") { - - // reply to navigator that (any) orientation is acceptable -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: orientation check, o=" << dat; -#endif - replyPPS(msg, id, "true"); - - } else if (msg == "orientation") { - - // update screen geometry and reply to navigator that we're ready -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: orientation, o=" << dat; -#endif - m_primaryScreen.setRotation( dat.toInt() ); - QWindowSystemInterface::handleScreenGeometryChange(0, m_primaryScreen.geometry()); - replyPPS(msg, id, ""); - - } else if (msg == "SWIPE_DOWN") { - - // simulate menu key press -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: menu"; -#endif - QWindow *w = QGuiApplication::focusWindow(); - QWindowSystemInterface::handleKeyEvent(w, QEvent::KeyPress, Qt::Key_Menu, Qt::NoModifier); - QWindowSystemInterface::handleKeyEvent(w, QEvent::KeyRelease, Qt::Key_Menu, Qt::NoModifier); - - } else if (msg == "exit") { - - // shutdown everything -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "PPS: exit"; -#endif - QCoreApplication::quit(); - } -} - -void QQnxNavigatorThread::readData() -{ -#if defined(QQNXNAVIGATORTHREAD_DEBUG) - qDebug() << "QQNX: reading navigator data"; -#endif - // allocate buffer for pps data - char buffer[ppsBufferSize]; - - // attempt to read pps data - errno = 0; - int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); - if (bytes == -1) { - qFatal("QQNX: failed to read navigator pps, errno=%d", errno); - } - - // check if pps data was received - if (bytes > 0) { - - // ensure data is null terminated - buffer[bytes] = '\0'; - - // process received message - QByteArray ppsData(buffer); - QByteArray msg; - QByteArray dat; - QByteArray id; - parsePPS(ppsData, msg, dat, id); - handleMessage(msg, dat, id); - } -} diff --git a/src/plugins/platforms/qnx/qqnxnavigatorthread.h b/src/plugins/platforms/qnx/qqnxnavigatorthread.h deleted file mode 100644 index 40b217db73..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorthread.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2011 - 2012 Research In Motion -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXNAVIGATORTHREAD_H -#define QQNXNAVIGATORTHREAD_H - -#include - -QT_BEGIN_NAMESPACE - -class QQnxScreen; -class QSocketNotifier; - -class QQnxNavigatorThread : public QThread -{ - Q_OBJECT -public: - QQnxNavigatorThread(QQnxScreen &primaryScreen); - virtual ~QQnxNavigatorThread(); - -protected: - virtual void run(); - -private Q_SLOTS: - void readData(); - -private: - void shutdown(); - void parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id); - void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat); - void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id); - - QQnxScreen &m_primaryScreen; - int m_fd; - QSocketNotifier *m_readNotifier; -}; - -QT_END_NAMESPACE - -#endif // QQNXNAVIGATORTHREAD_H -- cgit v1.2.3 From 03238488ebee2a7f1adff63fb90b9f5317aa6605 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Thu, 15 Mar 2012 11:10:39 +0000 Subject: Use delete[] instead of delete. Change-Id: Idfa039a56ce0f7af92e91ec1657d91c79c400d6c Reviewed-by: David Faure --- src/plugins/platforms/openkode/qopenkodeintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index d34bd8e029..705f332826 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -149,7 +149,7 @@ QOpenKODEIntegration::QOpenKODEIntegration() return; } if (displayNameLength) - delete displayName; + delete[] displayName; KDchar *desktopName = 0; KDsize desktopNameLength = 0; -- cgit v1.2.3 From f900da75823f4cafb4fe3b4bc3d00d5b0abd62b6 Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Wed, 21 Mar 2012 13:01:55 +0100 Subject: Need to check new rotation against initial rotation instead of current Only swap width/height of initial geometry if orthogonal to initial rotation not orthogonal to current rotation Change-Id: I825954e98dee6c0d07a284307dfb8e1f9fd538e6 Reviewed-by: Robin Burchell Reviewed-by: Sean Harmer --- src/plugins/platforms/qnx/qqnxscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index e0e3d6d57d..cd77c3088a 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -207,7 +207,7 @@ void QQnxScreen::setRotation(int rotation) m_rootWindow->setRotation(rotation); // Swap dimensions if we've rotated 90 or 270 from initial orientation - if (isOrthogonal(m_currentRotation, rotation)) { + if (isOrthogonal(m_initialRotation, rotation)) { m_currentGeometry = QRect(0, 0, m_initialGeometry.height(), m_initialGeometry.width()); m_currentPhysicalSize = QSize(m_initialPhysicalSize.height(), m_initialPhysicalSize.width()); } else { -- cgit v1.2.3 From 89b5244310d6765f6afd61ea5bd4acc2aed34c3b Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Thu, 22 Mar 2012 13:27:21 +0200 Subject: Cocoa: fix setting color with alpha channel value for color dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that if ShowAlphaChannel option is set then also setShowsAlpha needs to be set for the panel before setting the current color, otherwise alpha channel value is omitted. Task-number: QTBUG-24320 Change-Id: Ifb3822711af8ffd0cf6cb4c8aab2b0020d296663 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index bfc626fdba..fd4d6605a9 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -404,6 +404,11 @@ void QCocoaColorDialogHelper::setCurrentColor_sys(const QColor &color) if (!mDelegate) createNSColorPanelDelegate(); QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); + + // make sure that if ShowAlphaChannel option is set then also setShowsAlpha + // needs to be set, otherwise alpha value is omitted + [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; + NSColor *nsColor; const QColor::Spec spec = color.spec(); if (spec == QColor::Cmyk) { -- cgit v1.2.3 From 1a414cbc2664621431028593ea7b6de3e730d556 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Mar 2012 15:00:56 +0100 Subject: Fix QSysInfo::WindowsVersion checking (QSysInfo::WV_NT_based is a mask) Manual merge of the original fix 1ef309e9 in the Qt 4.8 repo. Task-number: QTBUG-20480 Change-Id: Id08500c2dd16965af3942e65cff1f4afa24180b0 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index f61e40ef77..17420d271d 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -362,7 +362,7 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) style = CS_DBLCLKS; if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) { if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) { + && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) { style |= CS_DROPSHADOW; } cname += QStringLiteral("QToolTip"); @@ -375,7 +375,7 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) cname += QStringLiteral("QPopup"); style = CS_DBLCLKS|CS_SAVEBITS; if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) + && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) style |= CS_DROPSHADOW; icon = false; } else { -- cgit v1.2.3 From 29518b04a619fdd7784e88eebe687fb87ae8a8b5 Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Thu, 22 Mar 2012 13:54:00 +0100 Subject: Make QNX virtual keyboard handling main event loop driven Refactor from polling in an endless loop running in a separate thread to using a QSocketNotifier working on the main thread. Similar to "de-threading" of the navigator event handling in 9dc86ac0f2d019f93665c1ae0e3c2cd33fd88bce Change-Id: I994dceed07312a3846737c8bea34cffa4ab408f1 Reviewed-by: Sean Harmer Reviewed-by: Robin Burchell --- src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp | 165 +++++++++++----------- src/plugins/platforms/qnx/qqnxvirtualkeyboard.h | 17 ++- 2 files changed, 92 insertions(+), 90 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp index 9d7fe92660..20c89d3e32 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp @@ -46,6 +46,8 @@ #include #include +#include +#include #include #include @@ -65,17 +67,17 @@ static QQnxVirtualKeyboard *s_instance = 0; // Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP. #define KEYBOARD_SHADOW_HEIGHT 8 -QQnxVirtualKeyboard::QQnxVirtualKeyboard() : - m_encoder(NULL), - m_decoder(NULL), - m_buffer(NULL), - m_height(0), - m_fd(-1), - m_keyboardMode(Default), - m_visible(false), - m_locale(QLatin1String("en_US")) +QQnxVirtualKeyboard::QQnxVirtualKeyboard() + : m_encoder(0), + m_decoder(0), + m_buffer(0), + m_height(0), + m_fd(-1), + m_keyboardMode(Default), + m_visible(false), + m_locale(QLatin1String("en_US")), + m_readNotifier(0) { - connect(); } QQnxVirtualKeyboard::~QQnxVirtualKeyboard() @@ -88,12 +90,24 @@ QQnxVirtualKeyboard& QQnxVirtualKeyboard::instance() { if (!s_instance) { s_instance = new QQnxVirtualKeyboard(); - s_instance->start(); + + // delay invocation of start() to the time the event loop is up and running + // needed to have the QThread internals of the main thread properly initialized + QMetaObject::invokeMethod(s_instance, "start", Qt::QueuedConnection); } return *s_instance; } +void QQnxVirtualKeyboard::start() +{ +#ifdef QQNXVIRTUALKEYBOARD_DEBUG + qDebug() << "QQNX: starting keyboard event processing"; +#endif + if (!connect()) + return; +} + /* static */ void QQnxVirtualKeyboard::destroy() { @@ -105,35 +119,28 @@ void QQnxVirtualKeyboard::destroy() void QQnxVirtualKeyboard::close() { - if (m_fd) { - // any reads will fail after we close the fd, which is basically what we want. - ::close(m_fd); - } - - // Wait for the thread to die (should be immediate), then continue the cleanup. - wait(); + delete m_readNotifier; + m_readNotifier = 0; - if (m_fd) { + if (m_fd != -1) { + ::close(m_fd); m_fd = -1; } - - if (m_decoder) - { + if (m_decoder) { pps_decoder_cleanup(m_decoder); delete m_decoder; - m_decoder = NULL; + m_decoder = 0; } - if (m_encoder) - { + if (m_encoder) { pps_encoder_cleanup(m_encoder); delete m_encoder; - m_encoder = NULL; + m_encoder = 0; } delete [] m_buffer; - m_buffer = NULL; + m_buffer = 0; } bool QQnxVirtualKeyboard::connect() @@ -165,7 +172,8 @@ bool QQnxVirtualKeyboard::connect() if (!queryPPSInfo()) return false; - start(); + m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); + QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady())); return true; } @@ -192,74 +200,63 @@ void QQnxVirtualKeyboard::notifyClientActiveStateChange(bool active) hideKeyboard(); } -void QQnxVirtualKeyboard::run() -{ - ppsDataReady(); -} - void QQnxVirtualKeyboard::ppsDataReady() { - while (1) { - ssize_t nread = read(m_fd, m_buffer, ms_bufferSize - 1); + ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1); #ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: keyboardMessage size: " << nread; + qDebug() << "QQNX: keyboardMessage size: " << nread; #endif - if (nread < 0) - break; + if (nread < 0){ + connect(); // reconnect + return; + } - // nread is the real space necessary, not the amount read. - if (static_cast(nread) > ms_bufferSize - 1) { - qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); - break; - } + // nread is the real space necessary, not the amount read. + if (static_cast(nread) > ms_bufferSize - 1) { + qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); + connect(); // reconnect + return; + } - m_buffer[nread] = 0; - pps_decoder_parse_pps_str(m_decoder, m_buffer); - pps_decoder_push(m_decoder, NULL); + m_buffer[nread] = 0; + pps_decoder_parse_pps_str(m_decoder, m_buffer); + pps_decoder_push(m_decoder, NULL); #ifdef QQNXVIRTUALKEYBOARD_DEBUG - pps_decoder_dump_tree(m_decoder, stderr); + pps_decoder_dump_tree(m_decoder, stderr); #endif - const char *value; - if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); - continue; - } - - if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) { - if (strcmp(value, "show") == 0) { - const bool oldVisible = m_visible; - m_visible = true; - handleKeyboardStateChangeMessage(true); - if (oldVisible != m_visible) - emit visibilityChanged(m_visible); - } else if (strcmp(value, "hide") == 0) { - const bool oldVisible = m_visible; - m_visible = false; - handleKeyboardStateChangeMessage(false); - if (oldVisible != m_visible) - emit visibilityChanged(m_visible); - } else if (strcmp(value, "info") == 0) - handleKeyboardInfoMessage(); - else if (strcmp(value, "connect") == 0) { } - else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]"); - } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) { - if (strcmp(value, "info") == 0) - handleKeyboardInfoMessage(); - else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]"); - } else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type"); + const char *value; + if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); + return; } -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: exiting keyboard thread"; -#endif - - if (m_decoder) - pps_decoder_cleanup(m_decoder); + if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) { + if (strcmp(value, "show") == 0) { + const bool oldVisible = m_visible; + m_visible = true; + handleKeyboardStateChangeMessage(true); + if (oldVisible != m_visible) + emit visibilityChanged(m_visible); + } else if (strcmp(value, "hide") == 0) { + const bool oldVisible = m_visible; + m_visible = false; + handleKeyboardStateChangeMessage(false); + if (oldVisible != m_visible) + emit visibilityChanged(m_visible); + } else if (strcmp(value, "info") == 0) + handleKeyboardInfoMessage(); + else if (strcmp(value, "connect") == 0) { } + else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]"); + } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) { + if (strcmp(value, "info") == 0) + handleKeyboardInfoMessage(); + else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]"); + } else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type"); } void QQnxVirtualKeyboard::handleKeyboardInfoMessage() diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h index 21b2e8736c..73a296fb9f 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h @@ -42,7 +42,7 @@ #ifndef VIRTUALKEYBOARD_H_ #define VIRTUALKEYBOARD_H_ -#include +#include #include #include #include @@ -52,10 +52,12 @@ #include #include +class QSocketNotifier; + QT_BEGIN_NAMESPACE /* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */ -class QQnxVirtualKeyboard : public QThread +class QQnxVirtualKeyboard : public QObject { Q_OBJECT public: @@ -83,10 +85,16 @@ public: bool isVisible() const { return m_visible; } QLocale locale() const { return m_locale; } +public Q_SLOTS: + void start(); + Q_SIGNALS: void localeChanged(const QLocale &locale); void visibilityChanged(bool visible); +private Q_SLOTS: + void ppsDataReady(); + private: QQnxVirtualKeyboard(); virtual ~QQnxVirtualKeyboard(); @@ -94,7 +102,6 @@ private: // Will be called internally if needed. bool connect(); void close(); - void ppsDataReady(); bool queryPPSInfo(); void handleKeyboardInfoMessage(); void handleKeyboardStateChangeMessage(bool visible); @@ -110,9 +117,6 @@ private: void addPhoneModeOptions(); void addPinModeOptions(); - // QThread overrides - virtual void run(); - pps_encoder_t *m_encoder; pps_decoder_t *m_decoder; char *m_buffer; @@ -121,6 +125,7 @@ private: KeyboardMode m_keyboardMode; bool m_visible; QLocale m_locale; + QSocketNotifier *m_readNotifier; // Path to keyboardManager in PPS. static const char *ms_PPSPath; -- cgit v1.2.3 From 63e56b90c57578b0fe1d2143a3fec08ba4d08fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 22 Mar 2012 14:14:39 +0100 Subject: Fixed QScreen::name() return value on xcb. Previously the primary sceen number wasn't stripped before adding the actual screen number, resulting in names such as ":0.0.0". Change-Id: Ifbcf12dcf1c200fd6bc5e4b95a5d82483957e0d2 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbscreen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8b66ef4603..a076dd4282 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -367,7 +367,11 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) QString QXcbScreen::name() const { - return connection()->displayName() + QLatin1String(".") + QString::number(screenNumber()); + QByteArray displayName = connection()->displayName(); + int dotPos = displayName.lastIndexOf('.'); + if (dotPos != -1) + displayName.truncate(dotPos); + return displayName + QLatin1Char('.') + QString::number(screenNumber()); } QT_END_NAMESPACE -- cgit v1.2.3 From 07029c23f155616b2e31fe557d0c2d6d8def774b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 19 Feb 2012 10:02:11 +0100 Subject: Fix compilation: std::min is in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I89227bb9fca0f081a232c2ede10c4d455edb2ee9 Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index b7369525a5..6e90594631 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -58,6 +58,7 @@ #include #include +#include QT_BEGIN_NAMESPACE class QXcbShmImage : public QXcbObject -- cgit v1.2.3 From b188221fee0eaacec115b514185a0508ef655897 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 21 Mar 2012 17:17:42 +0200 Subject: Fix QPrinter test in Windows Fixed Q_WS_WIN flagging to Q_OS_WIN in QPrinter API and related implementation to make API match the documentation and Qt 4.8. Also Removed the unused internal HDC related functions from the API, that were previously behind Q_WS_WIN flag. Some of the properties tested are documented to be valid for native print engine only in X11 environment, so skipped testing those in non-xcb environments. Copy collation is also apparently not supported in Windows native print engine, though this seems to be undocumented, so skipped that only in Windows. At least one of the test blocks in tst_QPrinter::valuePreservation() failed due to default printer not getting set properly, so fixed that, too. Task-number: QTBUG-24191 Task-number: QTBUG-22927 Change-Id: I44a5e3d647a1279fcc7f1e99de6881f9be330246 Reviewed-by: Friedemann Kleint --- src/plugins/printsupport/windows/qwindowsprintersupport.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp index 2905063c51..c5c60ae5cc 100644 --- a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp @@ -58,12 +58,13 @@ QWindowsPrinterSupport::QWindowsPrinterSupport() LPBYTE buffer = new BYTE[needed]; if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) { PPRINTER_INFO_4 infoList = reinterpret_cast(buffer); - QPrinterInfo defPrn = defaultPrinter(); + QString defaultPrinterName; + QWin32PrintEngine::queryDefaultPrinter(defaultPrinterName, QString(), QString()); for (uint i = 0; i < returned; ++i) { QString printerName(QString::fromWCharArray(infoList[i].pPrinterName)); QPrinterInfo printerInfo(printerName); - if (printerInfo.printerName() == defPrn.printerName()) + if (printerInfo.printerName() == defaultPrinterName) printerInfo.d_ptr->isDefault = true; mPrinterList.append(printerInfo); } -- cgit v1.2.3 From 96e89ddbf99f3d16869eee8fa1dcfd2a0992e674 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Thu, 22 Mar 2012 11:21:32 +0100 Subject: Add QPA readme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibc3a95f3560af909a45d147098184c2194187932 Reviewed-by: Robin Burchell Reviewed-by: Samuel Rødal Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/README | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/plugins/platforms/README (limited to 'src/plugins') diff --git a/src/plugins/platforms/README b/src/plugins/platforms/README new file mode 100644 index 0000000000..b44d04f58c --- /dev/null +++ b/src/plugins/platforms/README @@ -0,0 +1,49 @@ +The Qt Platform Abstraction - QPA + +QPA is the platform abstraction layer for Qt 5 and replaces QWS and the +platform ports from Qt 4. + +There is currently little documentation for QPA. The best approach for +developing a new platform plugin is to look at the other plugins and +see how they implement the APIs in question. The "minimal" plugin +is a good starting point. The xcb, windows, cocoa, and qnx plugins +are also actively developed and up to date. + +QPA plugins are implemented by subclassing various QPlatform* +classes. There are two "root" classes: QPlatformIntegration for +window system integration and QPlatformTheme for deeper platform +theming and integration. QStyle is not a part of QPA. + +The APIs provided by QPlatformIntegration are at this point (5.0 Alpha) +mostly stable. QPlatformTheme still has ongoing development. There +are no source or binary compatibility guarantees for the QPA classes, +meaning that a platform plugin is only guaranteed to work with the Qt +version it was developed against. API changes will however only be +made in minor releases. (5.1, 5.2, and so on.) + +Class Overview: + +QPlatformIntegration + QPlatformWindow + QPlatformBackingStore + QPlatformOpenGLContext + QPlatformSharedGraphicsCache + QPlatformFontDatabase + QPlatformClipboard + QPlatformDrag + QAbstractEventDispatcher + QPlatformInputContext + QPlatformAccessibility + QPlatformNativeInterface + QPlatformServices + +QPlatformTheme + QPlatformMenu + QPlatformMenuBar + QPlatformDialogHelper + platform palettes + platform fonts + theme hints + +src/platformsupport contains several helper classes for implementing +platform plugins on unix-like systems. -- cgit v1.2.3 From fd379ae7d3952cf423f87afbaed943d10e790432 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Wed, 21 Mar 2012 14:58:20 +0100 Subject: Cocoa: Add window fullscreen button on OS X Lion. Use the heuristic that windows that are not an NSPanel and has the MaximizedButtonHint get the fullscreen button. Change-Id: I9a3520b7e4cd1833421d5d2f5b73da7edbfc3e74 Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qcocoawindow.mm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b4c4e31753..b5e8ff2246 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -382,6 +382,15 @@ NSWindow * QCocoaWindow::createNSWindow() defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up // before the window is shown and needs a proper window.). window->m_cocoaPlatformWindow = this; + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { + // All windows with the WindowMaximizeButtonHint set also get a full-screen button. + if (flags & Qt::WindowMaximizeButtonHint) + [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } +#endif + createdWindow = window; } return createdWindow; -- cgit v1.2.3 From 68f44a7f98de4d60c39c9374ecd470eab74b22dd Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 19 Mar 2012 11:04:26 +0900 Subject: Check if Qt::ImEnabled is true before handling im events on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Key events were not sent to items on graphics view after the change 412dbdf410c765e75c60d1f48143dd6c02a69493. This is because the change only checks if QGuiApplication::focusObject() exists. Qt::ImEnabled needs to be checked too. Change-Id: I2a78af717a7a1a5d84fbc8b521253bdc25b43286 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoainputcontext.h | 3 +- src/plugins/platforms/cocoa/qcocoainputcontext.mm | 10 +++- src/plugins/platforms/cocoa/qnsview.mm | 64 ++++++++++++++++++----- 3 files changed, 60 insertions(+), 17 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.h b/src/plugins/platforms/cocoa/qcocoainputcontext.h index 172c87e2dc..1fda29209d 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.h +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.h @@ -59,7 +59,8 @@ public: virtual void reset(); private Q_SLOTS: - void inputItemChanged(); + void connectSignals(); + void focusObjectChanged(QObject *focusObject); private: QPointer mWindow; diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm index db3488a0f5..5ac7f72acf 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm @@ -83,7 +83,7 @@ QCocoaInputContext::QCocoaInputContext() : QPlatformInputContext() , mWindow(QGuiApplication::focusWindow()) { - connect(qApp->inputMethod(), SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged())); + QMetaObject::invokeMethod(this, "connectSignals", Qt::QueuedConnection); } QCocoaInputContext::~QCocoaInputContext() @@ -114,7 +114,13 @@ void QCocoaInputContext::reset() } } -void QCocoaInputContext::inputItemChanged() +void QCocoaInputContext::connectSignals() +{ + connect(qApp, SIGNAL(focusObjectChanged(QObject*)), this, SLOT(focusObjectChanged(QObject*))); + focusObjectChanged(qApp->focusObject()); +} + +void QCocoaInputContext::focusObjectChanged(QObject *focusObject) { mWindow = QGuiApplication::focusWindow(); } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index d7f6310f6e..d249158db3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -614,10 +614,11 @@ static QTouchDevice *touchDevice = 0; QObject *fo = QGuiApplication::focusObject(); if (!m_keyEventsAccepted && fo) { - QInputMethodQueryEvent queryEvent(Qt::ImHints); + QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImHints); if (QCoreApplication::sendEvent(fo, &queryEvent)) { + bool imEnabled = queryEvent.value(Qt::ImEnabled).toBool(); Qt::InputMethodHints hints = static_cast(queryEvent.value(Qt::ImHints).toUInt()); - if (!(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhHiddenText)) + if (imEnabled && !(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhHiddenText)) [self interpretKeyEvents:[NSArray arrayWithObject:nsevent]]; } } @@ -654,10 +655,15 @@ static QTouchDevice *touchDevice = 0; } QObject *fo = QGuiApplication::focusObject(); if (fo) { - QInputMethodEvent e; - e.setCommitString(commitString); - QCoreApplication::sendEvent(fo, &e); - m_keyEventsAccepted = true; + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (QCoreApplication::sendEvent(fo, &queryEvent)) { + if (queryEvent.value(Qt::ImEnabled).toBool()) { + QInputMethodEvent e; + e.setCommitString(commitString); + QCoreApplication::sendEvent(fo, &e); + m_keyEventsAccepted = true; + } + } } m_composingText.clear(); @@ -715,9 +721,14 @@ static QTouchDevice *touchDevice = 0; QObject *fo = QGuiApplication::focusObject(); if (fo) { - QInputMethodEvent e(preeditString, attrs); - QCoreApplication::sendEvent(fo, &e); - m_keyEventsAccepted = true; + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (QCoreApplication::sendEvent(fo, &queryEvent)) { + if (queryEvent.value(Qt::ImEnabled).toBool()) { + QInputMethodEvent e(preeditString, attrs); + QCoreApplication::sendEvent(fo, &e); + m_keyEventsAccepted = true; + } + } } } @@ -726,9 +737,14 @@ static QTouchDevice *touchDevice = 0; if (!m_composingText.isEmpty()) { QObject *fo = QGuiApplication::focusObject(); if (fo) { - QInputMethodEvent e; - e.setCommitString(m_composingText); - QCoreApplication::sendEvent(fo, &e); + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (QCoreApplication::sendEvent(fo, &queryEvent)) { + if (queryEvent.value(Qt::ImEnabled).toBool()) { + QInputMethodEvent e; + e.setCommitString(m_composingText); + QCoreApplication::sendEvent(fo, &e); + } + } } } m_composingText.clear(); @@ -749,9 +765,11 @@ static QTouchDevice *touchDevice = 0; QObject *fo = QGuiApplication::focusObject(); if (!fo) return nil; - QInputMethodQueryEvent queryEvent(Qt::ImCurrentSelection); + QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImCurrentSelection); if (!QCoreApplication::sendEvent(fo, &queryEvent)) return nil; + if (!queryEvent.value(Qt::ImEnabled).toBool()) + return nil; QString selectedText = queryEvent.value(Qt::ImCurrentSelection).toString(); if (selectedText.isEmpty()) @@ -785,9 +803,12 @@ static QTouchDevice *touchDevice = 0; QObject *fo = QGuiApplication::focusObject(); if (!fo) return selRange; - QInputMethodQueryEvent queryEvent(Qt::ImCurrentSelection); + QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImCurrentSelection); if (!QCoreApplication::sendEvent(fo, &queryEvent)) return selRange; + if (!queryEvent.value(Qt::ImEnabled).toBool()) + return selRange; + QString selectedText = queryEvent.value(Qt::ImCurrentSelection).toString(); if (!selectedText.isEmpty()) { @@ -804,6 +825,12 @@ static QTouchDevice *touchDevice = 0; if (!fo) return NSZeroRect; + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (!QCoreApplication::sendEvent(fo, &queryEvent)) + return NSZeroRect; + if (!queryEvent.value(Qt::ImEnabled).toBool()) + return NSZeroRect; + if (!m_window) return NSZeroRect; @@ -828,10 +855,19 @@ static QTouchDevice *touchDevice = 0; - (NSArray*) validAttributesForMarkedText { + if (m_window != QGuiApplication::focusWindow()) + return nil; + QObject *fo = QGuiApplication::focusObject(); if (!fo) return nil; + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (!QCoreApplication::sendEvent(fo, &queryEvent)) + return nil; + if (!queryEvent.value(Qt::ImEnabled).toBool()) + return nil; + // Support only underline color/style. return [NSArray arrayWithObjects:NSUnderlineColorAttributeName, NSUnderlineStyleAttributeName, nil]; -- cgit v1.2.3