diff options
author | JiDe Zhang <zhangjide@uniontech.com> | 2022-06-16 13:14:12 +0800 |
---|---|---|
committer | JiDe Zhang <zhangjide@uniontech.com> | 2022-06-18 02:59:22 +0800 |
commit | 8790da89882f833aedf26cf444e334ab14258679 (patch) | |
tree | ed46bd86b23ee26799d04d76cf446bfb69c89332 | |
parent | 2ed54dedf3783471716b21509db1f8279d5b5af8 (diff) |
xcb: Get some style hints from xsettings
According to
https://www.freedesktop.org/wiki/Specifications/XSettingsRegistry/.
Added support for Net/CursorBlinkTime Net/DoubleClickTime
Net/DoubleClickDistance Net/DndDragThreshold.
Change-Id: Ief208736ed2938792d935bfd730fefdd745394b6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/gui/kernel/qplatformintegration.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 25 |
4 files changed, 28 insertions, 4 deletions
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 66513a86e6..4d4f501ae4 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -408,6 +408,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines); case MouseQuickSelectionThreshold: return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseQuickSelectionThreshold); + case MouseDoubleClickDistance: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseDoubleClickDistance); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 46f1d74309..cc617faca9 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -160,7 +160,8 @@ public: UiEffects, WheelScrollLines, ShowShortcutsInContextMenus, - MouseQuickSelectionThreshold + MouseQuickSelectionThreshold, + MouseDoubleClickDistance }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 64c3a88be2..042f793a27 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -122,7 +122,7 @@ int QStyleHints::mouseDoubleClickDistance() const Q_D(const QStyleHints); return d->m_mouseDoubleClickDistance >= 0 ? d->m_mouseDoubleClickDistance : - themeableHint(QPlatformTheme::MouseDoubleClickDistance).toInt(); + themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt(); } /*! diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index c60269f9a0..8b49fb73ca 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -20,6 +20,7 @@ #ifndef QT_NO_SESSIONMANAGER #include "qxcbsessionmanager.h" #endif +#include "qxcbxsettings.h" #include <xcb/xcb.h> @@ -423,12 +424,30 @@ QPlatformTheme *QXcbIntegration::createPlatformTheme(const QString &name) const return QGenericUnixTheme::createUnixTheme(name); } +#define RETURN_VALID_XSETTINGS(key) { \ + auto value = connection()->primaryScreen()->xSettings()->setting(key); \ + if (value.isValid()) return value; \ +} + QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { switch (hint) { - case QPlatformIntegration::CursorFlashTime: - case QPlatformIntegration::KeyboardInputInterval: + case QPlatformIntegration::CursorFlashTime: { + bool ok = false; + // If cursor blinking is off, returns 0 to keep the cursor awlays display. + if (connection()->primaryScreen()->xSettings()->setting(QByteArrayLiteral("Net/CursorBlink")).toInt(&ok) == 0 && ok) + return 0; + + RETURN_VALID_XSETTINGS(QByteArrayLiteral("Net/CursorBlinkTime")); + break; + } case QPlatformIntegration::MouseDoubleClickInterval: + RETURN_VALID_XSETTINGS(QByteArrayLiteral("Net/DoubleClickTime")); + break; + case QPlatformIntegration::MouseDoubleClickDistance: + RETURN_VALID_XSETTINGS(QByteArrayLiteral("Net/DoubleClickDistance")); + break; + case QPlatformIntegration::KeyboardInputInterval: case QPlatformIntegration::StartDragTime: case QPlatformIntegration::KeyboardAutoRepeatRate: case QPlatformIntegration::PasswordMaskDelay: @@ -438,6 +457,8 @@ QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const // TODO using various xcb, gnome or KDE settings break; // Not implemented, use defaults case QPlatformIntegration::StartDragDistance: { + RETURN_VALID_XSETTINGS(QByteArrayLiteral("Net/DndDragThreshold")); + // The default (in QPlatformTheme::defaultThemeHint) is 10 pixels, but // on a high-resolution screen it makes sense to increase it. qreal dpi = 100.0; |