summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp23
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h2
4 files changed, 23 insertions, 11 deletions
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index 42c7a52bd4..a032085f0b 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -668,7 +668,8 @@ void QXcbCursor::setPos(const QPoint &pos)
{
QXcbVirtualDesktop *virtualDesktop = nullptr;
queryPointer(connection(), &virtualDesktop, nullptr);
- xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y());
+ if (virtualDesktop)
+ xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y());
xcb_flush(xcb_connection());
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index e8286381a2..98045cdab9 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -60,11 +60,11 @@ Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const
ret |= Qt::ShiftModifier;
if (s & XCB_MOD_MASK_CONTROL)
ret |= Qt::ControlModifier;
- if (s & rmod_masks.alt)
+ if ((s & rmod_masks.alt) == rmod_masks.alt)
ret |= Qt::AltModifier;
- if (s & rmod_masks.meta)
+ if ((s & rmod_masks.meta) == rmod_masks.meta)
ret |= Qt::MetaModifier;
- if (s & rmod_masks.altgr)
+ if ((s & rmod_masks.altgr) == rmod_masks.altgr)
ret |= Qt::GroupSwitchModifier;
return ret;
}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 707896b457..464d038671 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -114,17 +114,13 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t
}
auto dpiChangedCallback = [](QXcbVirtualDesktop *desktop, const QByteArray &, const QVariant &property, void *) {
- bool ok;
- int dpiTimes1k = property.toInt(&ok);
- if (!ok)
+ if (!desktop->setDpiFromXSettings(property))
return;
- int dpi = dpiTimes1k / 1024;
- if (desktop->m_forcedDpi == dpi)
- return;
- desktop->m_forcedDpi = dpi;
+ const auto dpi = desktop->forcedDpi();
for (QXcbScreen *screen : desktop->connection()->screens())
QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen->QPlatformScreen::screen(), dpi, dpi);
};
+ setDpiFromXSettings(xSettings()->setting("Xft/DPI"));
xSettings()->registerCallbackForProperty("Xft/DPI", dpiChangedCallback, nullptr);
}
@@ -425,6 +421,19 @@ void QXcbVirtualDesktop::readXResources()
}
}
+bool QXcbVirtualDesktop::setDpiFromXSettings(const QVariant &property)
+{
+ bool ok;
+ int dpiTimes1k = property.toInt(&ok);
+ if (!ok)
+ return false;
+ int dpi = dpiTimes1k / 1024;
+ if (m_forcedDpi == dpi)
+ return false;
+ m_forcedDpi = dpi;
+ return true;
+}
+
QSurfaceFormat QXcbVirtualDesktop::surfaceFormatFor(const QSurfaceFormat &format) const
{
const xcb_visualid_t xcb_visualid = connection()->hasDefaultVisualId() ? connection()->defaultVisualId()
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index bf48dd5d5b..c3a59dc9d1 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -118,6 +118,8 @@ private:
QByteArray &stringValue);
void readXResources();
+ bool setDpiFromXSettings(const QVariant &property);
+
xcb_screen_t *m_screen;
const int m_number;
QList<QPlatformScreen *> m_screens;