Fix XCreateWindow BadMatch with depth 32 visuals
authorRobert Morell <rmorell@nvidia.com>
Wed, 10 Jan 2018 21:31:33 +0000 (13:31 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 1 Feb 2018 11:59:32 +0000 (06:59 -0500)
For the common case of a depth 24 root window, when creating a window
with a visual of depth 32, attempting to use a depth of CopyFromParent
will result in a BadMatch error.

Fix this by passing the visual's depth to XCreateWindow explicitly --
fortunately the VisualInfo structure was already queried.

Components: Framework

VK-GL-CTS issue: 938

Change-Id: I54b142b6105c7f328e76d7ea0f9b01e635380e4e

framework/platform/lnx/X11/tcuLnxX11.cpp

index 3f72b2b..8656d5c 100644 (file)
@@ -140,6 +140,8 @@ XlibWindow::XlibWindow (XlibDisplay& display, int width, int height, ::Visual* v
        // other issues, so this is disabled by default.
        const bool                              overrideRedirect        = false;
 
+       int depth = CopyFromParent;
+
        if (overrideRedirect)
        {
                mask |= CWOverrideRedirect;
@@ -159,6 +161,8 @@ XlibWindow::XlibWindow (XlibDisplay& display, int width, int height, ::Visual* v
                m_colormap                      = XCreateColormap(dpy, root, visual, AllocNone);
                swa.colormap            = m_colormap;
                mask |= CWColormap;
+
+               depth = info.depth;
        }
 
        swa.border_pixel        = 0;
@@ -170,7 +174,7 @@ XlibWindow::XlibWindow (XlibDisplay& display, int width, int height, ::Visual* v
                height = DEFAULT_WINDOW_HEIGHT;
 
        m_window = XCreateWindow(dpy, root, 0, 0, width, height, 0,
-                                                        CopyFromParent, InputOutput, visual, mask, &swa);
+                                                        depth, InputOutput, visual, mask, &swa);
        TCU_CHECK(m_window);
 
        Atom deleteAtom = m_display.getDeleteAtom();