[plasma/kwin] src/backends/drm: backends/drm: filter out unusably small modes

Xaver Hugl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit a64249da3c9ae470439ba09766e38a47d84ecb91 by Xaver Hugl.
Committed on 17/08/2026 at 15:53.
Pushed by zamundaaa into branch 'master'.

backends/drm: filter out unusably small modes

If a user accidentally selects a mode like 320x240, they will have a
very hard time using system settings to get back to a usable mode.
To avoid that, this simply filters out all modes smaller than 480p,
unless all modes are that small.

M  +13   -2    src/backends/drm/drm_connector.cpp

https://invent.kde.org/plasma/kwin/-/commit/a64249da3c9ae470439ba09766e38a47d84ecb91

diff --git a/src/backends/drm/drm_connector.cpp b/src/backends/drm/drm_connector.cpp
index 5c7122e135b..12b484d9e68 100644
--- a/src/backends/drm/drm_connector.cpp
+++ b/src/backends/drm/drm_connector.cpp
@@ -327,8 +327,19 @@ bool DrmConnector::updateProperties()
     if (!equal && m_conn->count_modes > 0) {
         // reload modes
         m_driverModes.clear();
-        for (int i = 0; i < m_conn->count_modes; i++) {
-            m_driverModes.append(std::make_shared<DrmConnectorMode>(this, m_conn->modes[i]));
+        const auto modes = std::span(m_conn->modes, m_conn->count_modes);
+        auto usableModes = modes | std::views::filter([](drmModeModeInfo mode) {
+            return mode.hdisplay >= 640 && mode.vdisplay >= 480;
+        });
+        if (usableModes.empty()) {
+            // allow unusable modes, we don't have much of a choice
+            for (const auto &mode : modes) {
+                m_driverModes.append(std::make_shared<DrmConnectorMode>(this, mode));
+            }
+        } else {
+            for (const auto &mode : usableModes) {
+                m_driverModes.append(std::make_shared<DrmConnectorMode>(this, mode));
+            }
         }
         m_modes.clear();
         m_modes.append(m_driverModes);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.