Fix Qt over VNC with broken VisualInfo
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Tue, 27 Jan 2015 15:36:10 +0000 (16:36 +0100)
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>
Mon, 2 Feb 2015 10:26:37 +0000 (10:26 +0000)
It appears some VNC servers reports incorrect masks in their visuals.
This patch recognizes this unlikely set of masks and interprets it as
RGB16 which VNC expects.

Task-number: QTBUG-44147
Change-Id: Ia374edcd5f0a5ce0188157ac1d328f888cfa260c
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
src/plugins/platforms/xcb/qxcbwindow.cpp

index 4fd71f1635f223fdb11decd7698781b80796ad3a..00942787d923a40c0434204c098ce573e81850f3 100644 (file)
@@ -215,6 +215,18 @@ static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, q
         break;
     }
     qWarning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask);
+
+    switch (depth) {
+    case 24:
+        qWarning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format.");
+        return QImage::Format_RGB32;
+    case 16:
+        qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format.");
+        return QImage::Format_RGB16;
+    default:
+        break;
+    }
+
     return QImage::Format_Invalid;
 }