diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-14 09:05:42 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-14 09:06:31 +0200 |
commit | 5c23199d4e8ff21661dfa5aacc13149178e78cab (patch) | |
tree | 322aee61581d7c85f1ccb65e47d1e79eba1ba6c9 /src/plugins/platforms | |
parent | 252bad7c589e03d3e12df02354b00a84d8e3159a (diff) | |
parent | c8d9b17367cfdcb034d11f8a168ca4ae3993e7c3 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
configure
mkspecs/macx-xcode/Info.plist.app
mkspecs/macx-xcode/Info.plist.lib
qmake/doc/qmake.qdocconf
src/corelib/global/qglobal.h
tests/auto/other/exceptionsafety/exceptionsafety.pro
tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
Change-Id: I3c769a4a82dc2e99a12c69123fbf17613fd2ac2a
Diffstat (limited to 'src/plugins/platforms')
24 files changed, 184 insertions, 101 deletions
diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp index 4d741807d0..9d6d4003f7 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp @@ -46,6 +46,8 @@ #include <QtCore/qdebug.h> #include <qpa/qwindowsysteminterface.h> +#include <QtGui/private/qopenglcontext_p.h> + QT_BEGIN_NAMESPACE QAndroidOpenGLContext::QAndroidOpenGLContext(const QAndroidPlatformIntegration *integration, @@ -75,4 +77,17 @@ void QAndroidOpenGLContext::swapBuffers(QPlatformSurface *surface) } } +bool QAndroidOpenGLContext::makeCurrent(QPlatformSurface *surface) +{ + bool ret = QEglFSContext::makeCurrent(surface); + + const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) { + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); + ctx_d->workaround_missingPrecisionQualifiers = true; + } + + return ret; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.h b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.h index c4c5a430ad..c419ae8392 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.h +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.h @@ -58,6 +58,7 @@ public: EGLenum eglApi = EGL_OPENGL_ES_API); void swapBuffers(QPlatformSurface *surface); + bool makeCurrent(QPlatformSurface *surface); private: const QAndroidPlatformIntegration *m_platformIntegration; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 7224ee2ff8..59fda96dff 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -84,6 +84,8 @@ public: inline NSMenuItem *nsMenuItem() const { return m_nativeItem; } + inline bool isVisible() const { return m_visible; } + virtual QPlatformMenuItem *menuItemAt(int position) const; virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const; @@ -100,6 +102,7 @@ private: NSMenuItem *m_nativeItem; NSObject *m_delegate; bool m_enabled; + bool m_visible; quintptr m_tag; QCocoaMenuBar *m_menuBar; }; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 8c4325a775..3ac48df09e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -218,6 +218,7 @@ QT_BEGIN_NAMESPACE QCocoaMenu::QCocoaMenu() : m_enabled(true), + m_visible(true), m_tag(0), m_menuBar(0) { @@ -423,6 +424,7 @@ void QCocoaMenu::setEnabled(bool enabled) void QCocoaMenu::setVisible(bool visible) { [m_nativeItem setSubmenu:(visible ? m_nativeMenu : nil)]; + m_visible = visible; } void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index da2704f19c..0fea55ac68 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -149,15 +149,17 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) cocoaMenu->syncMenuItem(item); - // If the NSMenu has no visble items, or only separators, we should hide it - // on the menubar. This can happen after syncing the menu items since they - // can be moved to other menus. BOOL shouldHide = YES; - for (NSMenuItem *item in [cocoaMenu->nsMenu() itemArray]) - if (![item isSeparatorItem] && ![item isHidden]) { - shouldHide = NO; - break; - } + if (cocoaMenu->isVisible()) { + // If the NSMenu has no visble items, or only separators, we should hide it + // on the menubar. This can happen after syncing the menu items since they + // can be moved to other menus. + for (NSMenuItem *item in [cocoaMenu->nsMenu() itemArray]) + if (![item isSeparatorItem] && ![item isHidden]) { + shouldHide = NO; + break; + } + } [cocoaMenu->nsMenuItem() setHidden:shouldHide]; } diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index cc72f050d2..fcebb7e0dc 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -270,7 +270,6 @@ void QCocoaWindow::setGeometry(const QRect &rect) #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qDebug() << "QCocoaWindow::setGeometry" << this << rect; #endif - QPlatformWindow::setGeometry(rect); setCocoaGeometry(rect); } @@ -278,8 +277,10 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect) { QCocoaAutoReleasePool pool; - if (m_contentViewIsEmbedded) + if (m_contentViewIsEmbedded) { + QPlatformWindow::setGeometry(rect); return; + } if (m_nsWindow) { NSRect bounds = qt_mac_flipRect(rect, window()); @@ -287,6 +288,8 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect) } else { [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())]; } + + // will call QPlatformWindow::setGeometry(rect) during resize confirmation (see qnsview.mm) } void QCocoaWindow::setVisible(bool visible) @@ -423,11 +426,13 @@ NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags) if (type == Qt::ToolTip) windowLevel = NSScreenSaverWindowLevel; - // A window should be in at least the same level as its parent. - const QWindow * const transientParent = window()->transientParent(); - const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0; - if (transientParentWindow) - windowLevel = qMax([transientParentWindow->m_nsWindow level], windowLevel); + // Any "special" window should be in at least the same level as its parent. + if (type != Qt::Window) { + const QWindow * const transientParent = window()->transientParent(); + const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0; + if (transientParentWindow) + windowLevel = qMax([transientParentWindow->m_nsWindow level], windowLevel); + } return windowLevel; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 285e4aeb9f..b8f0fc3cce 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1049,7 +1049,7 @@ static QTouchDevice *touchDevice = 0; timestamp, (lastKnownModifiers & mac_mask) ? QEvent::KeyRelease : QEvent::KeyPress, modifier_key_symbols[i].qt_code, - qmodifiers); + qmodifiers ^ [QNSView convertKeyModifiers:mac_mask]); } } diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 2dedf99582..ee8d7ea157 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -187,10 +187,8 @@ void QMacPrintEnginePrivate::setPaperName(const QString &name) if (PMSessionGetCurrentPrinter(session(), &printer) == noErr) { CFArrayRef array; - if (PMPrinterGetPaperList(printer, &array) != noErr) { - PMRelease(printer); + if (PMPrinterGetPaperList(printer, &array) != noErr) return; - } int count = CFArrayGetCount(array); for (int i = 0; i < count; ++i) { PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i))); @@ -208,7 +206,6 @@ void QMacPrintEnginePrivate::setPaperName(const QString &name) } } } - PMRelease(printer); } } diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp index 1898cde886..e09154bb59 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp @@ -79,6 +79,9 @@ void QEglFSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo makeCurrent(); + QRectF sr = window->screen()->geometry(); + glViewport(0, 0, sr.width(), sr.height()); + #ifdef QEGL_EXTRA_DEBUG qWarning("QEglBackingStore::flush %p", window); #endif @@ -120,7 +123,6 @@ void QEglFSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo }; QRectF r = window->geometry(); - QRectF sr = window->screen()->geometry(); GLfloat x1 = (r.left() / sr.width()) * 2 - 1; GLfloat x2 = (r.right() / sr.width()) * 2 - 1; @@ -192,8 +194,6 @@ void QEglFSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo void QEglFSBackingStore::makeCurrent() { - // needed to prevent QOpenGLContext::makeCurrent() from failing - window()->setSurfaceType(QSurface::OpenGLSurface); (static_cast<QEglFSWindow *>(window()->handle()))->create(); m_context->makeCurrent(window()); } diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 1cc252d285..bf6e375ac0 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -55,12 +55,12 @@ QEglFSWindow::QEglFSWindow(QWindow *w) : QPlatformWindow(w) , m_surface(0) , m_window(0) + , has_window(false) { - static int serialNo = 0; - m_winid = ++serialNo; #ifdef QEGL_EXTRA_DEBUG - qWarning("QEglWindow %p: %p 0x%x\n", this, w, uint(m_winid)); + qWarning("QEglWindow %p: %p 0x%x\n", this, w, uint(m_window)); #endif + w->setSurfaceType(QSurface::OpenGLSurface); } QEglFSWindow::~QEglFSWindow() @@ -75,7 +75,7 @@ static inline bool supportsMultipleWindows() void QEglFSWindow::create() { - if (m_window) + if (has_window) return; setWindowState(Qt::WindowFullScreen); @@ -100,7 +100,7 @@ void QEglFSWindow::create() void QEglFSWindow::invalidateSurface() { // Native surface has been deleted behind our backs - m_window = 0; + has_window = false; if (m_surface != 0) { EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display(); eglDestroySurface(display, m_surface); @@ -113,6 +113,7 @@ void QEglFSWindow::resetSurface() EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display(); m_window = QEglFSHooks::hooks()->createNativeWindow(QEglFSHooks::hooks()->screenSize(), m_format); + has_window = true; m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); if (m_surface == EGL_NO_SURFACE) { @@ -138,9 +139,9 @@ void QEglFSWindow::destroy() m_surface = 0; } - if (m_window) { + if (has_window) { QEglFSHooks::hooks()->destroyNativeWindow(m_window); - m_window = 0; + has_window = false; } } @@ -160,7 +161,7 @@ void QEglFSWindow::setWindowState(Qt::WindowState) WId QEglFSWindow::winId() const { - return m_winid; + return WId(m_window); } EGLSurface QEglFSWindow::surface() const diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index ff360962ed..936537807a 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -75,9 +75,9 @@ protected: EGLNativeWindowType m_window; private: - WId m_winid; EGLConfig m_config; QSurfaceFormat m_format; + bool has_window; }; QT_END_NAMESPACE #endif // QEGLFSWINDOW_H diff --git a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp index cb245f2e5c..db6e5d94da 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp @@ -80,9 +80,6 @@ void QMinimalEglBackingStore::flush(QWindow *window, const QRegion ®ion, cons void QMinimalEglBackingStore::beginPaint(const QRegion &) { - // needed to prevent QOpenGLContext::makeCurrent() from failing - window()->setSurfaceType(QSurface::OpenGLSurface); - m_context->makeCurrent(window()); m_device = new QOpenGLPaintDevice(window()->size()); } diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp index 13640b73d6..956b5470e5 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp @@ -58,6 +58,7 @@ QMinimalEglWindow::QMinimalEglWindow(QWindow *w) if (w->geometry() != screenGeometry) { QWindowSystemInterface::handleGeometryChange(w, screenGeometry); } + w->setSurfaceType(QSurface::OpenGLSurface); } void QMinimalEglWindow::setGeometry(const QRect &) diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 92664826ab..377ca32e64 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -2,7 +2,9 @@ TEMPLATE = subdirs android:!android-no-sdk: SUBDIRS += android -SUBDIRS += minimal offscreen +SUBDIRS += minimal + +!win32|contains(QT_CONFIG, freetype):SUBDIRS += offscreen contains(QT_CONFIG, xcb) { SUBDIRS += xcb diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a9fd1d9836..de0a583e58 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -593,6 +593,11 @@ QWindow *QWindowsContext::windowUnderMouse() const return d->m_mouseHandler.windowUnderMouse(); } +void QWindowsContext::clearWindowUnderMouse() +{ + d->m_mouseHandler.clearWindowUnderMouse(); +} + /*! \brief Find a child window at a screen point. @@ -868,10 +873,15 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::CloseEvent: QWindowSystemInterface::handleCloseEvent(platformWindow->window()); return true; - case QtWindows::ThemeChanged: // ### fixme: Compress these events? + case QtWindows::ThemeChanged: { + // Switch from Aero to Classic changes margins. + const Qt::WindowFlags flags = platformWindow->window()->flags(); + if ((flags & Qt::WindowType_Mask) != Qt::Desktop && !(flags & Qt::FramelessWindowHint)) + platformWindow->setFlag(QWindowsWindow::FrameDirty); if (QWindowsTheme *theme = QWindowsTheme::instance()) theme->windowsThemeChanged(platformWindow->window()); return true; + } #ifndef Q_OS_WINCE case QtWindows::ActivateWindowEvent: #ifndef QT_NO_TABLETEVENT diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index b5c97cddc9..0d3476e00f 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -168,6 +168,7 @@ public: unsigned cwex_flags) const; QWindow *windowUnderMouse() const; + void clearWindowUnderMouse(); inline bool windowsProc(HWND hwnd, UINT message, QtWindows::WindowsEventType et, diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 17a6cd6579..354f6700b3 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -2098,7 +2098,7 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type) || QSysInfo::windowsVersion() <= QSysInfo::WV_2003) { return new QWindowsXpFileDialogHelper(); } - if (QSysInfo::windowsVersion() > QSysInfo::WV_XP) + if (QSysInfo::windowsVersion() > QSysInfo::WV_2003) return new QWindowsFileDialogHelper(); #else return new QWindowsFileDialogHelper(); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index caf30e6b1a..7a7b92ca7e 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -72,6 +72,7 @@ public: static Qt::MouseButtons queryMouseButtons(); QWindow *windowUnderMouse() const { return m_windowUnderMouse.data(); } + void clearWindowUnderMouse() { m_windowUnderMouse = 0; } private: inline bool translateMouseWheelEvent(QWindow *window, HWND hwnd, diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 83d93b08bd..882967d22c 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -226,7 +226,6 @@ static inline QPalette menuPalette(const QPalette &systemPalette) const QColor menuColor(getSysColor(COLOR_MENU)); const QColor menuTextColor(getSysColor(COLOR_MENUTEXT)); const QColor disabled(getSysColor(COLOR_GRAYTEXT)); - const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false); // we might need a special color group for the result. result.setColor(QPalette::Active, QPalette::Button, menuColor); result.setColor(QPalette::Active, QPalette::Text, menuTextColor); @@ -235,6 +234,7 @@ static inline QPalette menuPalette(const QPalette &systemPalette) result.setColor(QPalette::Disabled, QPalette::WindowText, disabled); result.setColor(QPalette::Disabled, QPalette::Text, disabled); #ifndef Q_OS_WINCE + const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false); result.setColor(QPalette::Disabled, QPalette::Highlight, getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT)); #else diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index dc51dbfc88..e7e964a128 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -871,6 +871,9 @@ void QWindowsWindow::destroyWindow() qDebug() << __FUNCTION__ << this << window() << m_data.hwnd; if (m_data.hwnd) { // Stop event dispatching before Window is destroyed. setFlag(WithinDestroy); + QWindowsContext *context = QWindowsContext::instance(); + if (context->windowUnderMouse() == window()) + context->clearWindowUnderMouse(); if (hasMouseCapture()) setMouseGrabEnabled(false); unregisterDropSite(); @@ -893,7 +896,7 @@ void QWindowsWindow::destroyWindow() #endif // !Q_OS_WINCE if (m_data.hwnd != GetDesktopWindow()) DestroyWindow(m_data.hwnd); - QWindowsContext::instance()->removeWindow(m_data.hwnd); + context->removeWindow(m_data.hwnd); m_data.hwnd = 0; } } @@ -1795,6 +1798,7 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const } #endif // !Q_OS_WINCE +#ifndef QT_NO_CURSOR // Return the default cursor (Arrow) from QWindowsCursor's cache. static inline QWindowsWindowCursor defaultCursor(const QWindow *w) { @@ -1805,6 +1809,24 @@ static inline QWindowsWindowCursor defaultCursor(const QWindow *w) return QWindowsWindowCursor(Qt::ArrowCursor); } +// Check whether to apply a new cursor. Either the window in question is +// currently under mouse, or it is the parent of the window under mouse and +// there is no other window with an explicitly set cursor in-between. +static inline bool applyNewCursor(const QWindow *w) +{ + const QWindow *underMouse = QWindowsContext::instance()->windowUnderMouse(); + if (underMouse == w) + return true; + for (const QWindow *p = underMouse; p ; p = p->parent()) { + if (p == w) + return true; + if (!QWindowsWindow::baseWindowOf(p)->cursor().isNull()) + return false; + } + return false; +} +#endif // !QT_NO_CURSOR + /*! \brief Applies to cursor property set on the window to the global cursor. @@ -1826,23 +1848,6 @@ void QWindowsWindow::applyCursor() #endif } -// Check whether to apply a new cursor. Either the window in question is -// currently under mouse, or it is the parent of the window under mouse and -// there is no other window with an explicitly set cursor in-between. -static inline bool applyNewCursor(const QWindow *w) -{ - const QWindow *underMouse = QWindowsContext::instance()->windowUnderMouse(); - if (underMouse == w) - return true; - for (const QWindow *p = underMouse; p ; p = p->parent()) { - if (p == w) - return true; - if (!QWindowsWindow::baseWindowOf(p)->cursor().isNull()) - return false; - } - return false; -} - void QWindowsWindow::setCursor(const QWindowsWindowCursor &c) { #ifndef QT_NO_CURSOR diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 5fbc23c049..2529fb8a83 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -583,7 +583,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = { Qt::AltModifier | Qt::ShiftModifier, // 5 Qt::AltModifier | Qt::ControlModifier, // 6 Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7 - Qt::NoModifier // Fall-back to raw Key_* + Qt::NoModifier // Fall-back to raw Key_*, for non-latin1 kb layouts }; Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const @@ -602,8 +602,9 @@ Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const return ret; } -void QXcbKeyboard::readXKBConfig(struct xkb_rule_names *xkb_names) +void QXcbKeyboard::readXKBConfig() { + clearXKBConfig(); xcb_generic_error_t *error; xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *config_reply; @@ -634,15 +635,30 @@ void QXcbKeyboard::readXKBConfig(struct xkb_rule_names *xkb_names) length -= len + 1; } while (p < end || i < 5); - xkb_names->rules = qstrdup(names[0]); - xkb_names->model = qstrdup(names[1]); - xkb_names->layout = qstrdup(names[2]); - xkb_names->variant = qstrdup(names[3]); - xkb_names->options = qstrdup(names[4]); + xkb_names.rules = qstrdup(names[0]); + xkb_names.model = qstrdup(names[1]); + xkb_names.layout = qstrdup(names[2]); + xkb_names.variant = qstrdup(names[3]); + xkb_names.options = qstrdup(names[4]); free(config_reply); } +void QXcbKeyboard::clearXKBConfig() +{ + if (xkb_names.rules) + delete[] xkb_names.rules; + if (xkb_names.model) + delete[] xkb_names.model; + if (xkb_names.layout) + delete[] xkb_names.layout; + if (xkb_names.variant) + delete[] xkb_names.variant; + if (xkb_names.options) + delete[] xkb_names.options; + memset(&xkb_names, 0, sizeof(xkb_names)); +} + void QXcbKeyboard::updateKeymap() { m_config = true; @@ -654,22 +670,13 @@ void QXcbKeyboard::updateKeymap() return; } } - - struct xkb_rule_names xkb_names = {0, 0, 0, 0, 0}; - - readXKBConfig(&xkb_names); + readXKBConfig(); // Compile a keymap from RMLVO (rules, models, layouts, variants and options) names if (xkb_keymap) xkb_keymap_unref(xkb_keymap); xkb_keymap = xkb_keymap_new_from_names(xkb_context, &xkb_names, (xkb_keymap_compile_flags)0); - delete[] xkb_names.rules; - delete[] xkb_names.model; - delete[] xkb_names.layout; - delete[] xkb_names.variant; - delete[] xkb_names.options; - if (!xkb_keymap) { qWarning("Qt: Failed to compile a keymap"); m_config = false; @@ -724,14 +731,14 @@ void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state) if (connection()->hasXKB()) { - xkb_state_component newState; - newState = xkb_state_update_mask(xkb_state, - state->baseMods, - state->latchedMods, - state->lockedMods, - state->baseGroup, - state->latchedGroup, - state->lockedGroup); + const xkb_state_component newState + = xkb_state_update_mask(xkb_state, + state->baseMods, + state->latchedMods, + state->lockedMods, + state->baseGroup, + state->latchedGroup, + state->lockedGroup); if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) { //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)"); @@ -745,17 +752,22 @@ void QXcbKeyboard::updateXKBStateFromCore(quint16 state) if (!m_config) return; - quint32 modsDepressed, modsLatched, modsLocked; - modsDepressed = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED); - modsLatched = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED); - modsLocked = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED); - - quint32 xkbMask = xkbModMask(state); - xkb_state_component newState; - newState = xkb_state_update_mask(xkb_state, - modsDepressed & xkbMask, - modsLatched & xkbMask, - modsLocked & xkbMask, + const quint32 modsDepressed = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED); + const quint32 modsLatched = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED); + const quint32 modsLocked = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED); + const quint32 xkbMask = xkbModMask(state); + + const quint32 latched = modsLatched & xkbMask; + const quint32 locked = modsLocked & xkbMask; + quint32 depressed = modsDepressed & xkbMask; + // set modifiers in depressed if they don't appear in any of the final masks + depressed |= ~(depressed | latched | locked) & xkbMask; + + const xkb_state_component newState + = xkb_state_update_mask(xkb_state, + depressed, + latched, + locked, 0, 0, (state >> 13) & 3); // bits 13 and 14 report the state keyboard group @@ -838,7 +850,7 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control"); xkb_mod_mask_t depressed; - + struct xkb_keymap *fallback_keymap = 0; int qtKey = 0; //obtain a list of possible shortcuts for the given key event for (uint i = 1; i < sizeof(ModsTbl) / sizeof(*ModsTbl) ; ++i) { @@ -854,8 +866,23 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const depressed |= (1 << controlMod); // update a keyboard state from a set of explicit masks - xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, - baseLayout, latchedLayout, lockedLayout); + if (i == 8) { + // Add a fall back key for layouts with non Latin-1 characters + if (baseQtKey > 255) { + struct xkb_rule_names names = { xkb_names.rules, xkb_names.model, "us", 0, 0 }; + fallback_keymap = xkb_keymap_new_from_names(xkb_context, &names, (xkb_keymap_compile_flags)0); + if (!fallback_keymap) + continue; + xkb_state_unref(kb_state); + kb_state = xkb_state_new(fallback_keymap); + if (!kb_state) + continue; + } else + continue; + } else { + xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, + baseLayout, latchedLayout, lockedLayout); + } sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode()); if (sym == XKB_KEY_NoSymbol) @@ -870,8 +897,11 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const result += (qtKey + mods); } } + if (kb_state) + xkb_state_unref(kb_state); + if (fallback_keymap) + xkb_keymap_unref(fallback_keymap); - xkb_state_unref(kb_state); return result; } @@ -941,6 +971,7 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection) , core_device_id(0) #endif { + memset(&xkb_names, 0, sizeof(xkb_names)); updateKeymap(); #ifndef QT_NO_XKB if (connection->hasXKB()) { @@ -982,6 +1013,7 @@ QXcbKeyboard::~QXcbKeyboard() #ifdef QT_NO_XKB xcb_key_symbols_free(m_key_symbols); #endif + clearXKBConfig(); } #ifndef QT_NO_XKB diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index 770a7eabea..0256602782 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -91,7 +91,8 @@ protected: int keysymToQtKey(xcb_keysym_t keysym) const; int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const; - void readXKBConfig(struct xkb_rule_names *names); + void readXKBConfig(); + void clearXKBConfig(); #ifdef QT_NO_XKB void updateModifiers(); @@ -107,6 +108,7 @@ private: struct xkb_context *xkb_context; struct xkb_keymap *xkb_keymap; struct xkb_state *xkb_state; + struct xkb_rule_names xkb_names; struct _mod_masks { uint alt; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c95c4d95ba..35b95b84a1 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1302,6 +1302,9 @@ QRect QXcbWindow::windowToWmGeometry(QRect r) const r.translate(m_frameMargins.left(), m_frameMargins.top()); } else if (!frameInclusive && m_gravity == XCB_GRAVITY_NORTH_WEST) { r.translate(-m_frameMargins.left(), -m_frameMargins.top()); + } else if (!frameInclusive && m_gravity == XCB_GRAVITY_CENTER) { + r.translate(-(m_frameMargins.left() - m_frameMargins.right())/2, + -(m_frameMargins.top() - m_frameMargins.bottom())/2); } return r; } @@ -1643,7 +1646,8 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) { - if (window() != QGuiApplication::focusWindow()) { + const bool isWheel = event->detail >= 4 && event->detail <= 7; + if (!isWheel && window() != QGuiApplication::focusWindow()) { QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); if (!(w->flags() & Qt::WindowDoesNotAcceptFocus)) w->requestActivate(); @@ -1665,7 +1669,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); - if (event->detail >= 4 && event->detail <= 7) { + if (isWheel) { // Logic borrowed from qapplication_x11.cpp int delta = 120 * ((event->detail == 4 || event->detail == 6) ? 1 : -1); bool hor = (((event->detail == 4 || event->detail == 5) diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index c106bd00f8..1423c6262d 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -221,6 +221,7 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen) xcb_intern_atom_reply_t *atom_reply = xcb_intern_atom_reply(screen->xcb_connection(),atom_cookie,&error); if (error) { qWarning() << Q_FUNC_INFO << "Failed to find XSETTINGS_S atom"; + free(error); return; } xcb_atom_t selection_owner_atom = atom_reply->atom; @@ -233,14 +234,15 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen) xcb_get_selection_owner_reply(screen->xcb_connection(), selection_cookie, &error); if (error) { qWarning() << Q_FUNC_INFO << "Failed to get selection owner for XSETTINGS_S atom"; + free(error); return; } d_ptr->x_settings_window = selection_result->owner; + free(selection_result); if (!d_ptr->x_settings_window) { return; } - free(selection_result); const uint32_t event = XCB_CW_EVENT_MASK; const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE }; |