Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:alarrosa:branches:YaST:Head
libqt5-qtbase
add-scale-change-shortcut.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File add-scale-change-shortcut.patch of Package libqt5-qtbase
Index: qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qguiapplication.cpp =================================================================== --- qtbase-everywhere-src-5.15.2+kde200.orig/src/gui/kernel/qguiapplication.cpp +++ qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qguiapplication.cpp @@ -124,6 +124,55 @@ #include <ctype.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> +#include <time.h> + + +void antlarr_log_base(int printtime, int newline, const char * fmt, ...) +{ + va_list arg; + char s[1024]; + int fd = open("/tmp/antlarr.log", O_WRONLY | O_CREAT | O_CLOEXEC | O_APPEND, 0666); + + if (printtime) + { + time_t currentTime = time(0); + strftime(s, 50, "%Y-%m-%d %H:%M:%S", localtime(¤tTime)); + dprintf(fd, "[%s] ", s); + printf("[%s] ", s); + } + + va_start(arg, fmt); + vsprintf(s, fmt, arg); + va_end(arg); + + if (newline) + { + dprintf(fd, "%s\n", s); + printf("%s\n", s); + } + else + { + dprintf(fd, "%s", s); + printf("%s", s); + } + + close(fd); +} + + +void antlarr_log_base(int printtime, int newline, const char * fmt, ...) __attribute__ ((format (printf, 3, 4))); +#define antlarr_log(fmt, ...) antlarr_log_base(1, 1, fmt, ##__VA_ARGS__) +#define antlarr_log_n(fmt, ...) antlarr_log_base(1, 0, fmt, ##__VA_ARGS__) +#define antlarr_log_c(fmt, ...) antlarr_log_base(0, 1, fmt, ##__VA_ARGS__) +#define antlarr_log_cn(fmt, ...) antlarr_log_base(0, 0, fmt, ##__VA_ARGS__) + + QT_BEGIN_NAMESPACE // Helper macro for static functions to check on the existence of the application class. @@ -660,6 +709,7 @@ QGuiApplication::QGuiApplication(int &ar : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) { d_func()->init(); + antlarr_log("QGuiApplication::QGuiApplication"); QCoreApplicationPrivate::eventDispatcher->startingUp(); } @@ -670,6 +720,8 @@ QGuiApplication::QGuiApplication(int &ar QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) : QCoreApplication(p) { + antlarr_log("QGuiApplication::QGuiApplication2"); + QHighDpiScaling::setHiDpiShortcuts(true); } /*! @@ -1997,6 +2049,7 @@ void QGuiApplicationPrivate::processWind { Q_TRACE_SCOPE(QGuiApplicationPrivate_processWindowSystemEvent, e->type); + antlarr_log("QGuiApplicationPrivate::processWindowSystemEvent %d", (int)e->type); switch(e->type) { case QWindowSystemInterfacePrivate::Mouse: QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); @@ -2375,6 +2428,7 @@ void QGuiApplicationPrivate::processKeyE { QWindow *window = e->window.data(); modifier_buttons = e->modifiers; + antlarr_log("processKeyEvent0 %d", (int)modifier_buttons); if (e->nullWindow() #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) || e->key == Qt::Key_Back || e->key == Qt::Key_Menu @@ -2391,6 +2445,82 @@ void QGuiApplicationPrivate::processKeyE #if !defined(Q_OS_MACOS) // FIXME: Include OS X in this code path by passing the key event through // QPlatformInputContext::filterEvent(). + if (e->keyType == QEvent::KeyPress) + { + antlarr_log("keypress key: %d, unicode: %s, scancode: %d, vkey: %d, modifiers: %d", e->key, e->unicode.toUtf8().data(), e->nativeScanCode, e->nativeVirtualKey, e->modifiers); + + if (modifier_buttons & Qt::ControlModifier) + antlarr_log("ctrl"); + + if (modifier_buttons & Qt::AltModifier) + antlarr_log("alt"); + if (e->key == Qt::Key_Plus) + antlarr_log("key_plus"); + if (e->key == Qt::Key_Minus) + antlarr_log("key_minus"); + if (QHighDpiScaling::hiDpiShortcutsEnabled()) + antlarr_log("hidpi enabled"); + } + + antlarr_log("processKeyEvent"); + if (QHighDpiScaling::hiDpiShortcutsEnabled() + && e->keyType == QEvent::KeyPress + && (modifier_buttons & Qt::ControlModifier) + && (modifier_buttons & Qt::AltModifier) + /* && (e->key == Qt::Key_Plus || e->key == Qt::Key_Minus)) { */ + && (e->key == 'A' || e->key == 'B')) { + antlarr_log("hidpi Keyevent global change"); + qreal factor = QHighDpiScaling::globalFactor(); + antlarr_log("current global factor is %f", factor); + + // if (e->key == Qt::Key_Plus) { + if (e->key == 'A') { + factor += 0.5; + antlarr_log("setting global factor to %f", factor); + QHighDpiScaling::setGlobalFactor(factor); + } else { + factor -= 0.5; + if (factor < 1) + factor = 1.0; + antlarr_log("setting global factor to %f", factor); + QHighDpiScaling::setGlobalFactor(factor); + } + return; + } + + if (QHighDpiScaling::hiDpiShortcutsEnabled() + && e->keyType == QEvent::KeyPress + && (modifier_buttons & Qt::ControlModifier) + /* && (e->key == Qt::Key_Plus || e->key == Qt::Key_Minus)) { */ + && (e->key == 'A' || e->key == 'B')) { + antlarr_log("hidpi Keyevent change"); + if (QGuiApplication::primaryScreen()) + antlarr_log("primary Screen is set"); + + QPoint pos = QCursor::pos(); + QScreen *screen = QGuiApplication::screenAt(pos); + if (screen) + { + qreal factor = screen->property("_q_scaleFactor").toReal(); + antlarr_log("current screen -- factor is %f", factor); + + // if (e->key == Qt::Key_Plus) { + if (e->key == 'A') { + factor += 0.5; + antlarr_log("setting screen -- factor to %f", factor); + QHighDpiScaling::setScreenFactor(screen, factor); + } else { + factor -= 0.5; + if (factor < 1) + factor = 1.0; + antlarr_log("setting screen -- factor to %f", factor); + QHighDpiScaling::setScreenFactor(screen, factor); + } + } + return; + } + + if (e->keyType == QEvent::KeyPress && window) { if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers, e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount)) { @@ -4374,6 +4504,11 @@ QInputDeviceManager *QGuiApplicationPriv return m_inputDeviceManager; } +void QGuiApplication::setHighDpiScalingShortcuts(bool enable) +{ + QHighDpiScaling::setHiDpiShortcuts(enable); +} + #include "moc_qguiapplication.cpp" QT_END_NAMESPACE Index: qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qhighdpiscaling_p.h =================================================================== --- qtbase-everywhere-src-5.15.2+kde200.orig/src/gui/kernel/qhighdpiscaling_p.h +++ qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qhighdpiscaling_p.h @@ -92,7 +92,9 @@ public: static void initHighDpiScaling(); static void updateHighDpiScaling(); static void setGlobalFactor(qreal factor); + static qreal globalFactor() { return m_factor; }; static void setScreenFactor(QScreen *screen, qreal factor); + static void setHiDpiShortcuts(bool enable); static bool isActive() { return m_active; } @@ -115,6 +117,8 @@ public: static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QDpi logicalDpi(const QScreen *screen); + static bool hiDpiShortcutsEnabled() { return m_hiDpiShortcutsEnabled; }; + private: static qreal rawScaleFactor(const QPlatformScreen *screen); @@ -129,6 +133,7 @@ private: static bool m_pixelDensityScalingActive; static bool m_screenFactorSet; static QDpi m_logicalDpi; + static bool m_hiDpiShortcutsEnabled; }; // Coordinate system conversion functions: Index: qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qhighdpiscaling.cpp =================================================================== --- qtbase-everywhere-src-5.15.2+kde200.orig/src/gui/kernel/qhighdpiscaling.cpp +++ qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qhighdpiscaling.cpp @@ -50,6 +50,45 @@ #include <algorithm> +void antlarr2_log_base(int printtime, int newline, const char * fmt, ...) +{ + va_list arg; + char s[1024]; + int fd = open("/tmp/antlarr.log", O_WRONLY | O_CREAT | O_CLOEXEC | O_APPEND, 0666); + + if (printtime) + { + time_t currentTime = time(0); + strftime(s, 50, "%Y-%m-%d %H:%M:%S", localtime(¤tTime)); + dprintf(fd, "[%s] ", s); + printf("[%s] ", s); + } + + va_start(arg, fmt); + vsprintf(s, fmt, arg); + va_end(arg); + + if (newline) + { + dprintf(fd, "%s\n", s); + printf("%s\n", s); + } + else + { + dprintf(fd, "%s", s); + printf("%s", s); + } + + close(fd); +} + + +void antlarr2_log_base(int printtime, int newline, const char * fmt, ...) __attribute__ ((format (printf, 3, 4))); +#define antlarr2_log(fmt, ...) antlarr2_log_base(1, 1, fmt, ##__VA_ARGS__) +#define antlarr2_log_n(fmt, ...) antlarr2_log_base(1, 0, fmt, ##__VA_ARGS__) +#define antlarr2_log_c(fmt, ...) antlarr2_log_base(0, 1, fmt, ##__VA_ARGS__) +#define antlarr2_log_cn(fmt, ...) antlarr2_log_base(0, 0, fmt, ##__VA_ARGS__) + QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); @@ -253,6 +292,7 @@ bool QHighDpiScaling::m_usePixelDensity bool QHighDpiScaling::m_pixelDensityScalingActive = false; // pixel density scale factor > 1 bool QHighDpiScaling::m_globalScalingActive = false; // global scale factor is active bool QHighDpiScaling::m_screenFactorSet = false; // QHighDpiScaling::setScreenFactor has been used +bool QHighDpiScaling::m_hiDpiShortcutsEnabled = false; // QHighDpiScaling::setScreenFactor has been used /* Initializes the QHighDpiScaling global variables. Called before the @@ -488,6 +528,8 @@ void QHighDpiScaling::initHighDpiScaling m_pixelDensityScalingActive = false; //set in updateHighDpiScaling below m_active = m_globalScalingActive || m_usePixelDensity; + + m_hiDpiShortcutsEnabled = !qgetenv("QT_ENABLE_SCALEFACTOR_SHORTCUTS").isEmpty(); } void QHighDpiScaling::updateHighDpiScaling() @@ -547,10 +589,13 @@ void QHighDpiScaling::updateHighDpiScali */ void QHighDpiScaling::setGlobalFactor(qreal factor) { + antlarr2_log("setGlobalFactor %f", (float)factor); if (qFuzzyCompare(factor, m_factor)) return; + antlarr2_log("setGlobalFactor2 %f", (float)factor); if (!QGuiApplication::allWindows().isEmpty()) qWarning("QHighDpiScaling::setFactor: Should only be called when no windows exist."); + antlarr2_log("setGlobalFactor3 %f", (float)factor); m_globalScalingActive = !qFuzzyCompare(factor, qreal(1)); m_factor = m_globalScalingActive ? factor : qreal(1); @@ -560,6 +605,12 @@ void QHighDpiScaling::setGlobalFactor(qr screen->d_func()->updateHighDpi(); } +void QHighDpiScaling::setHiDpiShortcuts(bool enable) +{ + m_hiDpiShortcutsEnabled = enable; + antlarr2_log("QHighDpiScaling::setHiDpiShortcuts"); +} + static const char scaleFactorProperty[] = "_q_scaleFactor"; /* Index: qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qguiapplication.h =================================================================== --- qtbase-everywhere-src-5.15.2+kde200.orig/src/gui/kernel/qguiapplication.h +++ qtbase-everywhere-src-5.15.2+kde200/src/gui/kernel/qguiapplication.h @@ -159,6 +159,8 @@ public: static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy); static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy(); + static void setHighDpiScalingShortcuts(bool enable); + static int exec(); bool notify(QObject *, QEvent *) override;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor