diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:07:34 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:08:18 +0200 |
commit | d1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch) | |
tree | 3bdc16da993e5de56b669e6774fb0748075ddd90 /src/plugins | |
parent | 1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff) | |
parent | 0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/network/access/qnetworkreply.cpp
tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/plugins')
19 files changed, 116 insertions, 75 deletions
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 0a55f689c6..1ee81fa9c9 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -267,6 +267,9 @@ void QIBusPlatformInputContext::commitText(const QDBusVariant &text) void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint cursorPos, bool visible) { + if (!qApp) + return; + QObject *input = qApp->focusObject(); if (!input) return; diff --git a/src/plugins/platforms/android/androidjniclipboard.cpp b/src/plugins/platforms/android/androidjniclipboard.cpp index 17ff0e0bbb..833996403c 100644 --- a/src/plugins/platforms/android/androidjniclipboard.cpp +++ b/src/plugins/platforms/android/androidjniclipboard.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "androidjniclipboard.h" -#include "androidjnimain.h" #include <QtCore/private/qjni_p.h> QT_BEGIN_NAMESPACE @@ -46,10 +45,23 @@ QT_BEGIN_NAMESPACE using namespace QtAndroid; namespace QtAndroidClipboard { - void setClipboardListener(QAndroidPlatformClipboard *listener) + QAndroidPlatformClipboard *m_manager = nullptr; + + static char const *const QtNativeClassName = "org/qtproject/qt5/android/QtNative"; + static JNINativeMethod methods[] = { + {"onClipboardDataChanged", "()V", (void *)onClipboardDataChanged} + }; + + void setClipboardManager(QAndroidPlatformClipboard *manager) { - Q_UNUSED(listener); + m_manager = manager; QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "registerClipboardManager"); + jclass appClass = QtAndroid::applicationClass(); + QJNIEnvironmentPrivate env; + if (env->RegisterNatives(appClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) { + __android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed"); + return; + } } void setClipboardText(const QString &text) @@ -73,6 +85,11 @@ namespace QtAndroidClipboard "()Ljava/lang/String;"); return text.toString(); } + + void onClipboardDataChanged(JNIEnv */*env*/, jobject /*thiz*/) + { + m_manager->emitChanged(QClipboard::Clipboard); + } } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/androidjniclipboard.h b/src/plugins/platforms/android/androidjniclipboard.h index 9de6dc1f44..2ec566e729 100644 --- a/src/plugins/platforms/android/androidjniclipboard.h +++ b/src/plugins/platforms/android/androidjniclipboard.h @@ -41,6 +41,8 @@ #define ANDROIDJNICLIPBOARD_H #include <QString> +#include "qandroidplatformclipboard.h" +#include "androidjnimain.h" QT_BEGIN_NAMESPACE @@ -48,10 +50,11 @@ class QAndroidPlatformClipboard; namespace QtAndroidClipboard { // Clipboard support - void setClipboardListener(QAndroidPlatformClipboard *listener); + void setClipboardManager(QAndroidPlatformClipboard *manager); void setClipboardText(const QString &text); bool hasClipboardText(); QString clipboardText(); + void onClipboardDataChanged(JNIEnv */*env*/, jobject /*thiz*/); // Clipboard support } diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index a2bc802680..dc5147b259 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QAndroidPlatformClipboard::QAndroidPlatformClipboard() { - QtAndroidClipboard::setClipboardListener(this); + QtAndroidClipboard::setClipboardManager(this); } QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index cfa7541dfa..b6c64d4d10 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1556,6 +1556,8 @@ void QCocoaWindow::foreachChildNSWindow(void (^block)(QCocoaWindow *)) */ void QCocoaWindow::recreateWindowIfNeeded() { + QMacAutoReleasePool pool; + QPlatformWindow *parentWindow = QPlatformWindow::parent(); qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::recreateWindowIfNeeded" << window() << "parent" << (parentWindow ? parentWindow->window() : 0); diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 75a508370f..a78151ebbe 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -116,9 +116,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)resetMouseButtons; - (void)handleMouseEvent:(NSEvent *)theEvent; -- (bool)handleMouseDownEvent:(NSEvent *)theEvent; -- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent; -- (bool)handleMouseUpEvent:(NSEvent *)theEvent; +- (bool)handleMouseDownEvent:(NSEvent *)theEvent withButton:(int)buttonNumber; +- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent withButton:(int)buttonNumber; +- (bool)handleMouseUpEvent:(NSEvent *)theEvent withButton:(int)buttonNumber; - (void)mouseDown:(NSEvent *)theEvent; - (void)mouseDragged:(NSEvent *)theEvent; - (void)mouseUp:(NSEvent *)theEvent; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index bbdf9ad44f..1e4ccc96a7 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -724,12 +724,12 @@ static bool _q_dontOverrideCtrlLMB = false; QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); } -- (bool)handleMouseDownEvent:(NSEvent *)theEvent +- (bool)handleMouseDownEvent:(NSEvent *)theEvent withButton:(int)buttonNumber { if ([self isTransparentForUserInput]) return false; - Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + Qt::MouseButton button = cocoaButton2QtButton(buttonNumber); QPointF qtWindowPoint; QPointF qtScreenPoint; @@ -753,12 +753,12 @@ static bool _q_dontOverrideCtrlLMB = false; return true; } -- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent +- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent withButton:(int)buttonNumber { if ([self isTransparentForUserInput]) return false; - Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + Qt::MouseButton button = cocoaButton2QtButton(buttonNumber); // Forward the event to the next responder if Qt did not accept the // corresponding mouse down for this button @@ -769,12 +769,12 @@ static bool _q_dontOverrideCtrlLMB = false; return true; } -- (bool)handleMouseUpEvent:(NSEvent *)theEvent +- (bool)handleMouseUpEvent:(NSEvent *)theEvent withButton:(int)buttonNumber { if ([self isTransparentForUserInput]) return false; - Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + Qt::MouseButton button = cocoaButton2QtButton(buttonNumber); // Forward the event to the next responder if Qt did not accept the // corresponding mouse down for this button @@ -864,56 +864,59 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseDragged:(NSEvent *)theEvent { - const bool accepted = [self handleMouseDraggedEvent:theEvent]; + const bool accepted = [self handleMouseDraggedEvent:theEvent withButton:[theEvent buttonNumber]]; if (!accepted) [super mouseDragged:theEvent]; } - (void)mouseUp:(NSEvent *)theEvent { - const bool accepted = [self handleMouseUpEvent:theEvent]; + const bool accepted = [self handleMouseUpEvent:theEvent withButton:[theEvent buttonNumber]]; if (!accepted) [super mouseUp:theEvent]; } - (void)rightMouseDown:(NSEvent *)theEvent { - const bool accepted = [self handleMouseDownEvent:theEvent]; + // Wacom tablet might not return the correct button number for NSEvent buttonNumber + // on right clicks. Decide here that the button is the "right" button and forward + // the button number to the mouse (and tablet) handler. + const bool accepted = [self handleMouseDownEvent:theEvent withButton:1]; if (!accepted) [super rightMouseDown:theEvent]; } - (void)rightMouseDragged:(NSEvent *)theEvent { - const bool accepted = [self handleMouseDraggedEvent:theEvent]; + const bool accepted = [self handleMouseDraggedEvent:theEvent withButton:1]; if (!accepted) [super rightMouseDragged:theEvent]; } - (void)rightMouseUp:(NSEvent *)theEvent { - const bool accepted = [self handleMouseUpEvent:theEvent]; + const bool accepted = [self handleMouseUpEvent:theEvent withButton:1]; if (!accepted) [super rightMouseUp:theEvent]; } - (void)otherMouseDown:(NSEvent *)theEvent { - const bool accepted = [self handleMouseDownEvent:theEvent]; + const bool accepted = [self handleMouseDownEvent:theEvent withButton:[theEvent buttonNumber]]; if (!accepted) [super otherMouseDown:theEvent]; } - (void)otherMouseDragged:(NSEvent *)theEvent { - const bool accepted = [self handleMouseDraggedEvent:theEvent]; + const bool accepted = [self handleMouseDraggedEvent:theEvent withButton:[theEvent buttonNumber]]; if (!accepted) [super otherMouseDragged:theEvent]; } - (void)otherMouseUp:(NSEvent *)theEvent { - const bool accepted = [self handleMouseUpEvent:theEvent]; + const bool accepted = [self handleMouseUpEvent:theEvent withButton:[theEvent buttonNumber]]; if (!accepted) [super otherMouseUp:theEvent]; } @@ -1071,7 +1074,6 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) NSPoint tilt = [theEvent tilt]; int xTilt = qRound(tilt.x * 60.0); int yTilt = qRound(tilt.y * -60.0); - Qt::MouseButtons buttons = static_cast<Qt::MouseButtons>(static_cast<uint>([theEvent buttonMask])); qreal tangentialPressure = 0; qreal rotation = 0; int z = 0; @@ -1090,10 +1092,10 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) qCDebug(lcQpaTablet, "event on tablet %d with tool %d type %d unique ID %lld pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf", deviceId, deviceData.device, deviceData.pointerType, deviceData.uid, windowPoint.x(), windowPoint.y(), screenPoint.x(), screenPoint.y(), - static_cast<uint>(buttons), pressure, xTilt, yTilt, rotation); + static_cast<uint>(m_buttons), pressure, xTilt, yTilt, rotation); QWindowSystemInterface::handleTabletEvent(m_platformWindow->window(), timestamp, windowPoint, screenPoint, - deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt, + deviceData.device, deviceData.pointerType, m_buttons, pressure, xTilt, yTilt, tangentialPressure, rotation, z, deviceData.uid, keyboardModifiers); return true; diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp index 19a0e03212..f46206cab5 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp @@ -410,6 +410,8 @@ struct StateSaver f->glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &arrayBuf); if (vaoHelper->isValid()) f->glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &vao); + else + vao = 0; for (int i = 0; i < 2; ++i) { f->glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &va[i].enabled); f->glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_SIZE, &va[i].size); diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index 73110dba61..8b751a72bf 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -452,9 +452,8 @@ void QEglFSIntegration::createInputHandlers() } #endif - bool useTslib = false; #if QT_CONFIG(tslib) - useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB"); + bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB"); if (useTslib) new QTsLibMouseHandler(QLatin1String("TsLib"), QString() /* spec */); #endif @@ -462,7 +461,9 @@ void QEglFSIntegration::createInputHandlers() #if QT_CONFIG(evdev) m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this); new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this); +#if QT_CONFIG(tslib) if (!useTslib) +#endif new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() /* spec */, this); #endif } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index ce193bdf90..6f79cd96d3 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -156,9 +156,8 @@ void QLinuxFbIntegration::createInputHandlers() } #endif - bool useTslib = false; #if QT_CONFIG(tslib) - useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB"); + bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB"); if (useTslib) new QTsLibMouseHandler(QLatin1String("TsLib"), QString()); #endif @@ -166,7 +165,9 @@ void QLinuxFbIntegration::createInputHandlers() #if QT_CONFIG(evdev) && !defined(Q_OS_ANDROID) new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this); new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this); +#if QT_CONFIG(tslib) if (!useTslib) +#endif new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() /* spec */, this); #endif } diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp index cd43ce4e69..67d33de2f0 100644 --- a/src/plugins/platforms/vnc/qvncscreen.cpp +++ b/src/plugins/platforms/vnc/qvncscreen.cpp @@ -131,6 +131,8 @@ void QVncScreen::enableClientCursor(QVncClient *client) if (!clientCursor) clientCursor = new QVncClientCursor(); clientCursor->addClient(client); +#else + Q_UNUSED(client) #endif } @@ -144,6 +146,8 @@ void QVncScreen::disableClientCursor(QVncClient *client) } mCursor = new QFbCursor(this); +#else + Q_UNUSED(client) #endif } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 56275f7028..b2b5284350 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -875,6 +875,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, GetCursorPos(&msg.pt); } + QWindowsWindow *platformWindow = findPlatformWindow(hwnd); + *platformWindowPtr = platformWindow; + // Run the native event filters. long filterResult = 0; QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance(); @@ -883,8 +886,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return true; } - QWindowsWindow *platformWindow = findPlatformWindow(hwnd); - *platformWindowPtr = platformWindow; if (platformWindow) { filterResult = 0; if (QWindowSystemInterface::handleNativeEvent(platformWindow->window(), d->m_eventType, &msg, &filterResult)) { diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index e7ebf73d5d..8c228f588e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -229,7 +229,7 @@ void QWindowsInputContext::updateEnabled() const bool accepted = inputMethodAccepted(); if (QWindowsContext::verbose > 1) qCDebug(lcQpaInputMethods) << __FUNCTION__ << platformWindow->window() << "accepted=" << accepted; - QWindowsInputContext::setWindowsImeEnabled(platformWindow, accepted); + QWindowsInputContext::setWindowsImeEnabled(platformWindow, accepted); } } diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 7ac4bdac6c..c370c2ec50 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -100,27 +100,17 @@ QT_BEGIN_NAMESPACE struct KeyInfo { KeyInfo() - : virtualKey(0) - , isAutoRepeat(false) - { - } - - KeyInfo(const QString &text, quint32 virtualKey) - : text(text) - , virtualKey(virtualKey) - , isAutoRepeat(false) { } KeyInfo(quint32 virtualKey) : virtualKey(virtualKey) - , isAutoRepeat(false) { } QString text; - quint32 virtualKey; - bool isAutoRepeat; + quint32 virtualKey{0}; + bool isAutoRepeat{false}; }; static inline Qt::ScreenOrientations qtOrientationsFromNative(DisplayOrientations native) @@ -991,9 +981,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - d->activeKeys.value(key).isAutoRepeat, - !status.RepeatCount ? 1 : status.RepeatCount, - false); + d->activeKeys.value(key).isAutoRepeat); } else { d->activeKeys.insert(key, KeyInfo(virtualKey)); } @@ -1021,9 +1009,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - d->activeKeys.value(key).isAutoRepeat, - !status.RepeatCount ? 1 : status.RepeatCount, - false); + d->activeKeys.value(key).isAutoRepeat); return S_OK; } @@ -1048,9 +1034,7 @@ HRESULT QWinRTScreen::onKeyUp(ABI::Windows::UI::Core::ICoreWindow *, ABI::Window virtualKey, 0, info.text, - false, // The final key release does not have autoRepeat set on Windows - !status.RepeatCount ? 1 : status.RepeatCount, - false); + false); // The final key release does not have autoRepeat set on Windows return S_OK; } @@ -1071,7 +1055,8 @@ HRESULT QWinRTScreen::onCharacterReceived(ICoreWindow *, ICharacterReceivedEvent const Qt::KeyboardModifiers modifiers = keyboardModifiers(); const Qt::Key key = qKeyFromCode(keyCode, modifiers); const QString text = QChar(keyCode); - const KeyInfo info = d->activeKeys.value(key); + KeyInfo &info = d->activeKeys[key]; + info.text = text; QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, @@ -1081,9 +1066,7 @@ HRESULT QWinRTScreen::onCharacterReceived(ICoreWindow *, ICharacterReceivedEvent info.virtualKey, 0, text, - info.isAutoRepeat, - !status.RepeatCount ? 1 : status.RepeatCount, - false); + info.isAutoRepeat); return S_OK; } diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index c77e7b6269..47702741e0 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -750,7 +750,8 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << " area " << touchPoint.area << " pressure " << touchPoint.pressure; - QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values()); + Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective_mods); + QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values(), modifiers); if (touchPoint.state == Qt::TouchPointReleased) // If a touchpoint was released, we can forget it, because the ID won't be reused. dev->touchPoints.remove(touchPoint.id); @@ -1221,9 +1222,8 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD return; QWindow *window = xcbWindow->window(); const Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(ev->mods.effective_mods); - const double scale = 65536.0; - QPointF local(ev->event_x / scale, ev->event_y / scale); - QPointF global(ev->root_x / scale, ev->root_y / scale); + QPointF local(fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y)); + QPointF global(fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y)); double pressure = 0, rotation = 0, tangentialPressure = 0; int xTilt = 0, yTilt = 0; @@ -1265,8 +1265,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf modifiers 0x%x", tabletData->deviceId, toolName(tabletData->tool), pointerTypeName(tabletData->pointerType), ev->sequenceNumber, ev->detail, ev->time, - fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), - fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), + local.x(), local.y(), global.x(), global.y(), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation, (int)modifiers); QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global, diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp index a123c5aaec..0b67739095 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE +#if QT_CONFIG(shortcut) static guint qt_gdkKey(const QKeySequence &shortcut) { if (shortcut.isEmpty()) @@ -75,6 +76,7 @@ static GdkModifierType qt_gdkModifiers(const QKeySequence &shortcut) return static_cast<GdkModifierType>(mods); } +#endif QGtk3MenuItem::QGtk3MenuItem() : m_visible(true), @@ -125,10 +127,12 @@ GtkWidget *QGtk3MenuItem::create() if (m_menu) gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu->handle()); g_signal_connect(m_item, "select", G_CALLBACK(onSelect), this); +#if QT_CONFIG(shortcut) if (!m_shortcut.isEmpty()) { GtkWidget *label = gtk_bin_get_child(GTK_BIN(m_item)); gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut)); } +#endif } gtk_widget_set_sensitive(m_item, m_enabled); gtk_widget_set_visible(m_item, m_visible); @@ -256,6 +260,7 @@ void QGtk3MenuItem::setChecked(bool checked) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(m_item), checked); } +#if QT_CONFIG(shortcut) QKeySequence QGtk3MenuItem::shortcut() const { return m_shortcut; @@ -272,6 +277,7 @@ void QGtk3MenuItem::setShortcut(const QKeySequence& shortcut) gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut)); } } +#endif bool QGtk3MenuItem::isEnabled() const { diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.h b/src/plugins/platformthemes/gtk3/qgtk3menu.h index 002fe1c0ce..cce800fbd8 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.h +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.h @@ -79,8 +79,10 @@ public: bool isChecked() const; void setChecked(bool checked) override; +#if QT_CONFIG(shortcut) QKeySequence shortcut() const; void setShortcut(const QKeySequence &shortcut) override; +#endif bool isEnabled() const; void setEnabled(bool enabled) override; @@ -110,7 +112,9 @@ private: QGtk3Menu *m_menu; GtkWidget *m_item; QString m_text; +#if QT_CONFIG(shortcut) QKeySequence m_shortcut; +#endif }; class QGtk3Menu : public QPlatformMenu diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 47193f2a84..682d1d929d 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2109,7 +2109,12 @@ QMacStyle::QMacStyle() name:NSPreferredScrollerStyleDidChangeNotification object:nil]; - d->nsscroller = [[NSScroller alloc] init]; + // Create scroller objects. Scroller internal direction setup happens + // on initWithFrame and cannot be changed later on. Create two scrollers + // initialized with fake geometry. Correct geometry is set at draw time. + d->horizontalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; + d->verticalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)]; + d->indicatorBranchButtonCell = nil; } @@ -2118,7 +2123,8 @@ QMacStyle::~QMacStyle() Q_D(QMacStyle); QMacAutoReleasePool pool; - [reinterpret_cast<NSScroller*>(d->nsscroller) release]; + [d->horizontalScroller release]; + [d->verticalScroller release]; NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver); [[NSNotificationCenter defaultCenter] removeObserver:receiver]; @@ -2463,11 +2469,13 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case PM_ButtonDefaultIndicator: ret = 0; break; - case PM_TitleBarHeight: - // Always use NSTitledWindowMask since we never need any other type of window here + case PM_TitleBarHeight: { + NSUInteger style = NSTitledWindowMask; + if (widget && ((widget->windowFlags() & Qt::Tool) == Qt::Tool)) + style |= NSUtilityWindowMask; ret = int([NSWindow frameRectForContentRect:NSZeroRect - styleMask:NSTitledWindowMask].size.height); - break; + styleMask:style].size.height); + break; } case QStyle::PM_TabBarTabHSpace: switch (d->aquaSizeConstrain(opt, widget)) { case QAquaSizeLarge: @@ -2496,7 +2504,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = 0; break; case PM_TabBarBaseHeight: - ret = 21; + ret = 0; break; case PM_TabBarTabOverlap: ret = 1; @@ -5425,8 +5433,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]]; - NSScroller *scroller = reinterpret_cast<NSScroller*>(d->nsscroller); - [scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())]; + NSScroller *scroller = isHorizontal ? d->horizontalScroller : d-> verticalScroller; // mac os behaviour: as soon as one color channel is >= 128, // the bg is considered bright, scroller is dark const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget); @@ -5538,16 +5545,18 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex sl.intValue = slider->sliderValue; sl.enabled = slider->state & QStyle::State_Enabled; d->drawNSViewInRect(cw, sl, opt->rect, p, widget != 0, ^(NSRect rect, CGContextRef ctx) { + const bool isSierraOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra; if (slider->upsideDown) { if (isHorizontal) { CGContextTranslateCTM(ctx, rect.size.width, 0); CGContextScaleCTM(ctx, -1, 1); } - } else if (!isHorizontal) { + } else if (!isHorizontal && !isSierraOrLater) { CGContextTranslateCTM(ctx, 0, rect.size.height); CGContextScaleCTM(ctx, 1, -1); } - [sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:NO]; + const bool shouldFlip = isHorizontal || (slider->upsideDown && isSierraOrLater); + [sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:shouldFlip]; // No need to restore the CTM later, the context has been saved // and will be restored at the end of drawNSViewInRect() }); diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index 6fd6d0c900..35c2690c03 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -115,6 +115,9 @@ // We mean it. // +Q_FORWARD_DECLARE_OBJC_CLASS(NSView); +Q_FORWARD_DECLARE_OBJC_CLASS(NSScroller); + QT_BEGIN_NAMESPACE /* @@ -246,7 +249,8 @@ public: CFAbsoluteTime defaultButtonStart; bool mouseDown; void* receiver; - void *nsscroller; + NSScroller *horizontalScroller; + NSScroller *verticalScroller; void *indicatorBranchButtonCell; NSView *backingStoreNSView; QHash<QCocoaWidget, NSView *> cocoaControls; |