diff options
73 files changed, 962 insertions, 808 deletions
diff --git a/.qmake.conf b/.qmake.conf index 0dfd3b9b7..1a16230c8 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ DEFINES += QT_NO_FOREACH DEFINES += QT_NO_JAVA_STYLE_ITERATORS DEFINES += QT_NO_LINKED_LIST -MODULE_VERSION = 5.14.1 +MODULE_VERSION = 5.15.0 diff --git a/config.tests/dmabuf_client_buffer/dmabuf_client_buffer.pro b/config.tests/dmabuf_client_buffer/dmabuf_client_buffer.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/dmabuf_client_buffer/dmabuf_client_buffer.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/dmabuf_client_buffer/main.cpp b/config.tests/dmabuf_client_buffer/main.cpp deleted file mode 100644 index 71447dc8e..000000000 --- a/config.tests/dmabuf_client_buffer/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <EGL/egl.h> -#include <EGL/eglext.h> - -//If libdrm is available, the following files should exist -#include "drm_mode.h" -#include "drm_fourcc.h" - -int main() -{ -// test if DMA BUF is supported -#ifndef EGL_LINUX_DMA_BUF_EXT -#error DMA BUF Extension not available -#endif - -// test if DMA BUF import modifier extension is supported -#ifndef EGL_EXT_image_dma_buf_import_modifiers -#error DMA BUF Import modifier extension not available -#endif - - return 0; -} diff --git a/config.tests/dmabuf_server_buffer/dmabuf_server_buffer.pro b/config.tests/dmabuf_server_buffer/dmabuf_server_buffer.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/dmabuf_server_buffer/dmabuf_server_buffer.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/dmabuf_server_buffer/main.cpp b/config.tests/dmabuf_server_buffer/main.cpp deleted file mode 100644 index aa04d18fd..000000000 --- a/config.tests/dmabuf_server_buffer/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <drm_fourcc.h> - -int main() -{ -#ifdef EGL_LINUX_DMA_BUF_EXT - return 0; -#else -#error Requires EGL_LINUX_DMA_BUF_EXT - return 1; -#endif -} diff --git a/config.tests/drm_egl_server/drm_egl_server.pro b/config.tests/drm_egl_server/drm_egl_server.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/drm_egl_server/drm_egl_server.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/drm_egl_server/main.cpp b/config.tests/drm_egl_server/main.cpp deleted file mode 100644 index 0dbd42f90..000000000 --- a/config.tests/drm_egl_server/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <EGL/egl.h> -#include <EGL/eglext.h> - -int main() -{ -#ifdef EGL_MESA_drm_image - return 0; -#else -#error Requires EGL_MESA_drm_image to be defined - return 1; -#endif -} diff --git a/config.tests/glx/glx.pro b/config.tests/glx/glx.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/glx/glx.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/glx/main.cpp b/config.tests/glx/main.cpp deleted file mode 100644 index c902c55d7..000000000 --- a/config.tests/glx/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <GL/glx.h> - -int main(int argc, char **argv) -{ - Display *dpy = XOpenDisplay(0); - - int items = 0; - GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), 0 , &items); - return 0; -} diff --git a/config.tests/libhybris_egl_server/libhybris_egl_server.pro b/config.tests/libhybris_egl_server/libhybris_egl_server.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/libhybris_egl_server/libhybris_egl_server.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/libhybris_egl_server/main.cpp b/config.tests/libhybris_egl_server/main.cpp deleted file mode 100644 index 368b57a12..000000000 --- a/config.tests/libhybris_egl_server/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <hybris/eglplatformcommon/hybris_nativebufferext.h> - -int main() -{ -#ifdef EGL_HYBRIS_native_buffer - return 0; -#else -#error Requires EGL_HYBRIS_native_buffer to be defined - return 1; -#endif -} diff --git a/config.tests/vulkan_server_buffer/main.cpp b/config.tests/vulkan_server_buffer/main.cpp deleted file mode 100644 index 5bd88d338..000000000 --- a/config.tests/vulkan_server_buffer/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <vulkan/vulkan.h> - -int main() -{ - VkExportMemoryAllocateInfoKHR exportAllocInfo = {}; - exportAllocInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR; - exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; - - return 0; -} diff --git a/config.tests/vulkan_server_buffer/vulkan_server_buffer.pro b/config.tests/vulkan_server_buffer/vulkan_server_buffer.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/vulkan_server_buffer/vulkan_server_buffer.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/wayland/main.cpp b/config.tests/wayland/main.cpp deleted file mode 100644 index 8cab379bf..000000000 --- a/config.tests/wayland/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <wayland-version.h> - -int main() -{ -#if WAYLAND_VERSION_MAJOR < 1 -# error Wayland 1.8.0 or higher required -#endif -#if WAYLAND_VERSION_MAJOR == 1 -# if WAYLAND_VERSION_MINOR < 8 -# error Wayland 1.8.0 or higher required -# endif -# if WAYLAND_VERSION_MINOR == 8 -# if WAYLAND_VERSION_MICRO < 0 -# error Wayland 1.8.0 or higher required -# endif -# endif -#endif - return 0; -} diff --git a/config.tests/wayland/wayland.pro b/config.tests/wayland/wayland.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/wayland/wayland.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/wayland_cursor/main.cpp b/config.tests/wayland_cursor/main.cpp deleted file mode 100644 index c9cf66196..000000000 --- a/config.tests/wayland_cursor/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <wayland-cursor.h> - -int main() -{ - struct wl_cursor_image *image = 0; - - return 0; -} diff --git a/config.tests/wayland_cursor/wayland_cursor.pro b/config.tests/wayland_cursor/wayland_cursor.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/wayland_cursor/wayland_cursor.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/wayland_egl/main.cpp b/config.tests/wayland_egl/main.cpp deleted file mode 100644 index c50056469..000000000 --- a/config.tests/wayland_egl/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <wayland-egl.h> - -int main() -{ - struct wl_egl_window *window = wl_egl_window_create(0,100,100); - - return 0; -} diff --git a/config.tests/wayland_egl/wayland_egl.pro b/config.tests/wayland_egl/wayland_egl.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/wayland_egl/wayland_egl.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/config.tests/xcomposite/main.cpp b/config.tests/xcomposite/main.cpp deleted file mode 100644 index 1867b204e..000000000 --- a/config.tests/xcomposite/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <X11/extensions/Xcomposite.h> - -int main (int argc, char **argv) -{ - XCompositeRedirectWindow((Display *)0,(Window) 0,CompositeRedirectManual); - - return 0; -} diff --git a/config.tests/xcomposite/xcomposite.pro b/config.tests/xcomposite/xcomposite.pro deleted file mode 100644 index 28dcadcbf..000000000 --- a/config.tests/xcomposite/xcomposite.pro +++ /dev/null @@ -1 +0,0 @@ -SOURCES += main.cpp diff --git a/src/client/client.pro b/src/client/client.pro index 32156470c..1b514eeec 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -5,6 +5,10 @@ QT += core-private gui-private QT_FOR_PRIVATE += service_support-private QT_PRIVATE += fontdatabase_support-private eventdispatcher_support-private theme_support-private +qtConfig(vulkan) { + QT_PRIVATE += vulkan_support-private +} + # We have a bunch of C code with casts, so we can't have this option QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual @@ -97,6 +101,16 @@ include(shellintegration/shellintegration.pri) include(inputdeviceintegration/inputdeviceintegration.pri) include(global/global.pri) +qtConfig(vulkan) { + HEADERS += \ + qwaylandvulkaninstance_p.h \ + qwaylandvulkanwindow_p.h + + SOURCES += \ + qwaylandvulkaninstance.cpp \ + qwaylandvulkanwindow.cpp +} + qtConfig(cursor) { QMAKE_USE += wayland-cursor diff --git a/src/client/configure.json b/src/client/configure.json index 062139685..7d4468240 100644 --- a/src/client/configure.json +++ b/src/client/configure.json @@ -9,7 +9,24 @@ "libraries": { "wayland-client": { "label": "Wayland client library", - "test": "wayland", + "headers": "wayland-version.h", + "test": { + "main": [ + "#if WAYLAND_VERSION_MAJOR < 1", + "# error Wayland 1.8.0 or higher required", + "#endif", + "#if WAYLAND_VERSION_MAJOR == 1", + "# if WAYLAND_VERSION_MINOR < 8", + "# error Wayland 1.8.0 or higher required", + "# endif", + "# if WAYLAND_VERSION_MINOR == 8", + "# if WAYLAND_VERSION_MICRO < 0", + "# error Wayland 1.8.0 or higher required", + "# endif", + "# endif", + "#endif" + ] + }, "sources": [ { "type": "pkgConfig", "args": "wayland-client" }, "-lwayland-client" @@ -17,7 +34,10 @@ }, "wayland-cursor": { "label": "Wayland cursor library", - "test": "wayland_cursor", + "headers": "wayland-cursor.h", + "test": { + "main": "struct wl_cursor_image *image = 0;" + }, "use": "wayland-client", "sources": [ { "type": "pkgConfig", "args": "wayland-cursor" }, @@ -26,7 +46,10 @@ }, "wayland-egl": { "label": "Wayland EGL library", - "test": "wayland_egl", + "headers": "wayland-egl.h", + "test": { + "main": "struct wl_egl_window *window = wl_egl_window_create(0, 100, 100);" + }, "sources": [ { "type": "pkgConfig", "args": "wayland-egl" }, "-lwayland-egl", @@ -35,7 +58,11 @@ }, "xcomposite": { "label": "XComposite", - "test": "xcomposite", + "headers": "X11/extensions/Xcomposite.h", + "test": { + "main": "XCompositeRedirectWindow((Display *)0,(Window) 0, CompositeRedirectManual);" + + }, "sources": [ { "type": "pkgConfig", "args": "xcomposite" }, "-lxcomposite" @@ -43,7 +70,14 @@ }, "glx": { "label": "GLX", - "test": "glx", + "headers": "GL/glx.h", + "test": { + "main": [ + "Display *dpy = XOpenDisplay(0);", + "int items = 0;", + "GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), 0 , &items);" + ] + }, "sources": [ { "type": "pkgConfig", "args": "x11 gl" }, "-lX11 -lGl" @@ -61,25 +95,79 @@ "drm-egl-server": { "label": "DRM EGL Server", "type": "compile", - "test": "drm_egl_server", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h" + ], + "main": [ + "#ifdef EGL_MESA_drm_image", + "return 0;", + "#else", + "#error Requires EGL_MESA_drm_image to be defined", + "return 1;", + "#endif" + ] + }, "use": "egl" }, "libhybris-egl-server": { "label": "libhybris EGL Server", "type": "compile", - "test": "libhybris_egl_server", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h", + "hybris/eglplatformcommon/hybris_nativebufferext.h" + ], + "main": [ + "#ifdef EGL_HYBRIS_native_buffer", + "return 0;", + "#else", + "#error Requires EGL_HYBRIS_native_buffer to be defined", + "return 1;", + "#endif" + ] + }, "use": "egl" }, "dmabuf-server-buffer": { "label": "Linux dma-buf Buffer Sharing", "type": "compile", - "test": "dmabuf_server_buffer", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h", + "drm_fourcc.h" + ], + "main": [ + "#ifdef EGL_LINUX_DMA_BUF_EXT", + "return 0;", + "#else", + "#error Requires EGL_LINUX_DMA_BUF_EXT", + "return 1;", + "#endif" + ] + }, "use": "egl drm" }, "vulkan-server-buffer": { "label": "Vulkan Buffer Sharing", "type": "compile", - "test": "vulkan_server_buffer" + "test": { + "head": [ + "#define VK_USE_PLATFORM_WAYLAND_KHR 1" + ], + "include": [ + "vulkan/vulkan.h" + ], + "main": [ + "VkExportMemoryAllocateInfoKHR exportAllocInfo = {};", + "exportAllocInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR;", + "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;", + "return 0;" + ] + } } }, @@ -165,7 +253,7 @@ }, "wayland-vulkan-server-buffer": { "label": "Vulkan-based server buffer integration", - "condition": "features.wayland-client && features.opengl && features.egl && tests.vulkan-server-buffer", + "condition": "features.wayland-client && features.vulkan && features.opengl && features.egl && tests.vulkan-server-buffer", "output": [ "privateFeature" ] }, "wayland-shm-emulation-server-buffer": { diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 0464d3a42..a8d19dc6c 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -188,6 +188,18 @@ QWaylandDisplay::~QWaylandDisplay(void) wl_display_disconnect(mDisplay); } +void QWaylandDisplay::ensureScreen() +{ + if (!mScreens.empty() || mPlaceholderScreen) + return; // There are real screens or we already have a fake one + + qCInfo(lcQpaWayland) << "Creating a fake screen in order for Qt not to crash"; + + mPlaceholderScreen = new QPlatformPlaceholderScreen(); + QWindowSystemInterface::handleScreenAdded(mPlaceholderScreen); + Q_ASSERT(!QGuiApplication::screens().empty()); +} + void QWaylandDisplay::checkError() const { int ecode = wl_display_get_error(mDisplay); @@ -253,8 +265,7 @@ void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bo QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const { - for (int i = 0; i < mScreens.size(); ++i) { - QWaylandScreen *screen = static_cast<QWaylandScreen *>(mScreens.at(i)); + for (auto screen : qAsConst(mScreens)) { if (screen->output() == output) return screen; } @@ -267,6 +278,11 @@ void QWaylandDisplay::handleScreenInitialized(QWaylandScreen *screen) return; mScreens.append(screen); QWindowSystemInterface::handleScreenAdded(screen); + if (mPlaceholderScreen) { + QWindowSystemInterface::handleScreenRemoved(mPlaceholderScreen); + // handleScreenRemoved deletes the platform screen + mPlaceholderScreen = nullptr; + } } void QWaylandDisplay::waitForScreens() @@ -362,6 +378,8 @@ void QWaylandDisplay::registry_global_remove(uint32_t id) for (QWaylandScreen *screen : qAsConst(mScreens)) { if (screen->outputId() == id) { mScreens.removeOne(screen); + // If this is the last screen, we have to add a fake screen, or Qt will break. + ensureScreen(); QWindowSystemInterface::handleScreenRemoved(screen); break; } diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index 14bb77198..cd845b44e 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -76,6 +76,7 @@ QT_BEGIN_NAMESPACE class QAbstractEventDispatcher; class QSocketNotifier; class QPlatformScreen; +class QPlatformPlaceholderScreen; namespace QtWayland { class qt_surface_extension; @@ -124,6 +125,8 @@ public: #endif QList<QWaylandScreen *> screens() const { return mScreens; } + QPlatformPlaceholderScreen *placeholderScreen() const { return mPlaceholderScreen; } + void ensureScreen(); QWaylandScreen *screenForOutput(struct wl_output *output) const; void handleScreenInitialized(QWaylandScreen *screen); @@ -228,6 +231,7 @@ private: QScopedPointer<QWaylandShm> mShm; QList<QWaylandScreen *> mWaitingScreens; QList<QWaylandScreen *> mScreens; + QPlatformPlaceholderScreen *mPlaceholderScreen = nullptr; QList<QWaylandInputDevice *> mInputDevices; QList<Listener> mRegistryListeners; QWaylandIntegration *mWaylandIntegration = nullptr; diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 320e34040..d33b0db8b 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -630,8 +630,8 @@ class EnterEvent : public QWaylandPointerEvent { public: EnterEvent(QWaylandWindow *surface, const QPointF &local, const QPointF &global) - : QWaylandPointerEvent(QWaylandPointerEvent::Enter, Qt::NoScrollPhase, surface, 0, - local, global, nullptr, Qt::NoModifier) + : QWaylandPointerEvent(QEvent::Enter, Qt::NoScrollPhase, surface, 0, + local, global, Qt::NoButton, Qt::NoButton, Qt::NoModifier) {} }; @@ -675,8 +675,8 @@ class LeaveEvent : public QWaylandPointerEvent { public: LeaveEvent(QWaylandWindow *surface, const QPointF &localPos, const QPointF &globalPos) - : QWaylandPointerEvent(QWaylandPointerEvent::Leave, Qt::NoScrollPhase, surface, 0, - localPos, globalPos, nullptr, Qt::NoModifier) + : QWaylandPointerEvent(QEvent::Leave, Qt::NoScrollPhase, surface, 0, + localPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier) {} }; @@ -705,8 +705,8 @@ class MotionEvent : public QWaylandPointerEvent public: MotionEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Motion, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + : QWaylandPointerEvent(QEvent::MouseMove, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, Qt::NoButton, modifiers) { } }; @@ -744,9 +744,10 @@ class PressEvent : public QWaylandPointerEvent { public: PressEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, - const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Press, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) + : QWaylandPointerEvent(QEvent::MouseButtonPress, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, button, modifiers) { } }; @@ -755,9 +756,10 @@ class ReleaseEvent : public QWaylandPointerEvent { public: ReleaseEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, - const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Release, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) + : QWaylandPointerEvent(QEvent::MouseButtonRelease, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, button, modifiers) { } }; @@ -818,9 +820,9 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time } if (state) - setFrameEvent(new PressEvent(window, time, pos, global, mButtons, mParent->modifiers())); + setFrameEvent(new PressEvent(window, time, pos, global, mButtons, qt_button, mParent->modifiers())); else - setFrameEvent(new ReleaseEvent(window, time, pos, global, mButtons, mParent->modifiers())); + setFrameEvent(new ReleaseEvent(window, time, pos, global, mButtons, qt_button, mParent->modifiers())); } void QWaylandInputDevice::Pointer::invalidateFocus() @@ -848,7 +850,7 @@ public: WheelEvent(QWaylandWindow *surface, Qt::ScrollPhase phase, ulong timestamp, const QPointF &local, const QPointF &global, const QPoint &pixelDelta, const QPoint &angleDelta, Qt::MouseEventSource source, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Wheel, phase, surface, timestamp, + : QWaylandPointerEvent(QEvent::Wheel, phase, surface, timestamp, local, global, pixelDelta, angleDelta, source, modifiers) { } @@ -1084,11 +1086,13 @@ void QWaylandInputDevice::Pointer::flushFrameEvent() if (auto *event = mFrameData.event) { if (auto window = event->surface) { window->handleMouse(mParent, *event); - } else if (mFrameData.event->type == QWaylandPointerEvent::Type::Release) { + } else if (mFrameData.event->type == QEvent::MouseButtonRelease) { // If the window has been destroyed, we still need to report an up event, but it can't // be handled by the destroyed window (obviously), so send the event here instead. QWindowSystemInterface::handleMouseEvent(nullptr, event->timestamp, event->local, - event->global, event->buttons, event->modifiers); + event->global, event->buttons, + event->button, event->type, + event->modifiers);// , Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); } delete mFrameData.event; mFrameData.event = nullptr; @@ -1408,8 +1412,7 @@ void QWaylandInputDevice::handleTouchPoint(int id, Qt::TouchPointState state, co return; tp.area = QRectF(0, 0, 8, 8); - QMargins margins = win->frameMargins(); - QPointF localPosition = surfacePosition - QPointF(margins.left(), margins.top()); + QPointF localPosition = win->mapFromWlSurface(surfacePosition); // TODO: This doesn't account for high dpi scaling for the delta, but at least it matches // what we have for mouse input. QPointF delta = localPosition - localPosition.toPoint(); diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index a567c57b4..87f8559c4 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -401,29 +401,21 @@ class QWaylandPointerEvent { Q_GADGET public: - enum Type { - Enter, - Leave, - Motion, - Press, - Release, - Wheel - }; - Q_ENUM(Type) - - inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, + inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, - Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) + Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) : type(type) , phase(phase) , timestamp(timestamp) , local(localPos) , global(globalPos) , buttons(buttons) + , button(button) , modifiers(modifiers) , surface(surface) {} - inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, + inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, ulong timestamp, const QPointF &local, const QPointF &global, const QPoint &pixelDelta, const QPoint &angleDelta, Qt::MouseEventSource source, @@ -440,12 +432,13 @@ public: , surface(surface) {} - Type type; + QEvent::Type type = QEvent::None; Qt::ScrollPhase phase = Qt::NoScrollPhase; ulong timestamp = 0; QPointF local; QPointF global; Qt::MouseButtons buttons; + Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button) Qt::KeyboardModifiers modifiers; QPoint pixelDelta; QPoint angleDelta; diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index f6a80e18f..33e64c6e8 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -86,7 +86,7 @@ #include "qwaylandinputdeviceintegration_p.h" #include "qwaylandinputdeviceintegrationfactory_p.h" -#ifndef QT_NO_ACCESSIBILITY_ATSPI_BRIDGE +#if QT_CONFIG(accessibility_atspi_bridge) #include <QtLinuxAccessibilitySupport/private/bridge_p.h> #endif @@ -94,41 +94,14 @@ #include <QtXkbCommonSupport/private/qxkbcommon_p.h> #endif -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class GenericWaylandTheme: public QGenericUnixTheme -{ -public: - static QStringList themeNames() - { - QStringList result; - - if (QGuiApplication::desktopSettingsAware()) { - const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment(); - - if (desktopEnvironment == QByteArrayLiteral("KDE")) { -#if QT_CONFIG(settings) - result.push_back(QStringLiteral("kde")); +#if QT_CONFIG(vulkan) +#include "qwaylandvulkaninstance_p.h" +#include "qwaylandvulkanwindow_p.h" #endif - } else if (!desktopEnvironment.isEmpty() && - desktopEnvironment != QByteArrayLiteral("UNKNOWN") && - desktopEnvironment != QByteArrayLiteral("GNOME") && - desktopEnvironment != QByteArrayLiteral("UNITY") && - desktopEnvironment != QByteArrayLiteral("MATE") && - desktopEnvironment != QByteArrayLiteral("XFCE") && - desktopEnvironment != QByteArrayLiteral("LXDE")) - // Ignore X11 desktop environments - result.push_back(QString::fromLocal8Bit(desktopEnvironment.toLower())); - } - if (result.isEmpty()) - result.push_back(QLatin1String(QGenericUnixTheme::name)); +QT_BEGIN_NAMESPACE - return result; - } -}; +namespace QtWaylandClient { QWaylandIntegration::QWaylandIntegration() #if defined(Q_OS_MACOS) @@ -190,7 +163,12 @@ QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) cons && mDisplay->clientBufferIntegration()) return mDisplay->clientBufferIntegration()->createEglWindow(window); - return new QWaylandShmWindow(window); +#if QT_CONFIG(vulkan) + if (window->surfaceType() == QSurface::VulkanSurface) + return new QWaylandVulkanWindow(window, mDisplay.data()); +#endif // QT_CONFIG(vulkan) + + return new QWaylandShmWindow(window, mDisplay.data()); } #if QT_CONFIG(opengl) @@ -204,7 +182,7 @@ QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGL QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const { - return new QWaylandShmBackingStore(window); + return new QWaylandShmBackingStore(window, mDisplay.data()); } QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const @@ -222,10 +200,8 @@ void QWaylandIntegration::initialize() QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data()); QObject::connect(sn, SIGNAL(activated(int)), mDisplay.data(), SLOT(flushRequests())); - if (mDisplay->screens().isEmpty()) { - qWarning() << "Running on a compositor with no screens is not supported"; - ::exit(EXIT_FAILURE); - } + // Qt does not support running with no screens + mDisplay->ensureScreen(); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const @@ -271,7 +247,7 @@ QVariant QWaylandIntegration::styleHint(StyleHint hint) const QPlatformAccessibility *QWaylandIntegration::accessibility() const { if (!mAccessibility) { -#ifndef QT_NO_ACCESSIBILITY_ATSPI_BRIDGE +#if QT_CONFIG(accessibility_atspi_bridge) Q_ASSERT_X(QCoreApplication::eventDispatcher(), "QWaylandIntegration", "Initializing accessibility without event-dispatcher!"); mAccessibility.reset(new QSpiAccessibleBridge()); @@ -302,13 +278,20 @@ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const QStringList QWaylandIntegration::themeNames() const { - return GenericWaylandTheme::themeNames(); + return QGenericUnixTheme::themeNames(); } QPlatformTheme *QWaylandIntegration::createPlatformTheme(const QString &name) const { - return GenericWaylandTheme::createUnixTheme(name); + return QGenericUnixTheme::createUnixTheme(name); +} + +#if QT_CONFIG(vulkan) +QPlatformVulkanInstance *QWaylandIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const +{ + return new QWaylandVulkanInstance(instance); } +#endif // QT_CONFIG(vulkan) // May be called from non-GUI threads QWaylandClientBufferIntegration *QWaylandIntegration::clientBufferIntegration() const diff --git a/src/client/qwaylandintegration_p.h b/src/client/qwaylandintegration_p.h index a66999c7f..ff70ae25d 100644 --- a/src/client/qwaylandintegration_p.h +++ b/src/client/qwaylandintegration_p.h @@ -113,6 +113,10 @@ public: QPlatformTheme *createPlatformTheme(const QString &name) const override; +#if QT_CONFIG(vulkan) + QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override; +#endif + QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id); virtual QWaylandClientBufferIntegration *clientBufferIntegration() const; diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp index b4ecc0090..bf54a1a00 100644 --- a/src/client/qwaylandnativeinterface.cpp +++ b/src/client/qwaylandnativeinterface.cpp @@ -51,6 +51,9 @@ #include <QtGui/private/qguiapplication_p.h> #include <QtGui/QScreen> #include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> +#if QT_CONFIG(vulkan) +#include <QtWaylandClient/private/qwaylandvulkanwindow_p.h> +#endif #include <QtPlatformHeaders/qwaylandwindowfunctions.h> @@ -117,6 +120,15 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration()) return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay); +#if QT_CONFIG(vulkan) + if (lowerCaseResource == "vksurface") { + if (window->surfaceType() == QSurface::VulkanSurface && window->handle()) { + // return a pointer to the VkSurfaceKHR value, not the value itself + return static_cast<QWaylandVulkanWindow *>(window->handle())->surface(); + } + } +#endif + if (auto shellIntegration = m_integration->shellIntegration()) return shellIntegration->nativeResourceForWindow(resourceString, window); diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index e70796832..4f0cd9b0a 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -165,11 +165,18 @@ QList<QPlatformScreen *> QWaylandScreen::virtualSiblings() const { QList<QPlatformScreen *> list; const QList<QWaylandScreen*> screens = mWaylandDisplay->screens(); - list.reserve(screens.count()); + auto *placeholder = mWaylandDisplay->placeholderScreen(); + + list.reserve(screens.count() + (placeholder ? 1 : 0)); + for (QWaylandScreen *screen : qAsConst(screens)) { if (screen->screen()) list << screen; } + + if (placeholder) + list << placeholder; + return list; } @@ -210,9 +217,11 @@ QPlatformCursor *QWaylandScreen::cursor() const } #endif // QT_CONFIG(cursor) -QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) +QWaylandScreen *QWaylandScreen::waylandScreenFromWindow(QWindow *window) { QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window); + if (platformScreen->isPlaceholder()) + return nullptr; return static_cast<QWaylandScreen *>(platformScreen); } diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index e9e07d9cd..ae91c6211 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -57,7 +57,6 @@ #include <QtWaylandClient/private/qwayland-wayland.h> #include <QtWaylandClient/private/qwayland-xdg-output-unstable-v1.h> - QT_BEGIN_NAMESPACE namespace QtWaylandClient { diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index 9b5971a21..8d5b977d5 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -151,9 +151,9 @@ QImage *QWaylandShmBuffer::imageInsideMargins(const QMargins &marginsIn) } -QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window) +QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window, QWaylandDisplay *display) : QPlatformBackingStore(window) - , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) + , mDisplay(display) { } diff --git a/src/client/qwaylandshmbackingstore_p.h b/src/client/qwaylandshmbackingstore_p.h index 8a85cd7f3..e01632daf 100644 --- a/src/client/qwaylandshmbackingstore_p.h +++ b/src/client/qwaylandshmbackingstore_p.h @@ -88,7 +88,7 @@ private: class Q_WAYLAND_CLIENT_EXPORT QWaylandShmBackingStore : public QPlatformBackingStore { public: - QWaylandShmBackingStore(QWindow *window); + QWaylandShmBackingStore(QWindow *window, QWaylandDisplay *display); ~QWaylandShmBackingStore() override; QPaintDevice *paintDevice() override; diff --git a/src/client/qwaylandshmwindow.cpp b/src/client/qwaylandshmwindow.cpp index 52833803d..e305d028d 100644 --- a/src/client/qwaylandshmwindow.cpp +++ b/src/client/qwaylandshmwindow.cpp @@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -QWaylandShmWindow::QWaylandShmWindow(QWindow *window) - : QWaylandWindow(window) +QWaylandShmWindow::QWaylandShmWindow(QWindow *window, QWaylandDisplay *display) + : QWaylandWindow(window, display) { } diff --git a/src/client/qwaylandshmwindow_p.h b/src/client/qwaylandshmwindow_p.h index ae1727859..81251b3aa 100644 --- a/src/client/qwaylandshmwindow_p.h +++ b/src/client/qwaylandshmwindow_p.h @@ -61,7 +61,7 @@ namespace QtWaylandClient { class Q_WAYLAND_CLIENT_EXPORT QWaylandShmWindow : public QWaylandWindow { public: - QWaylandShmWindow(QWindow *window); + QWaylandShmWindow(QWindow *window, QWaylandDisplay *display); ~QWaylandShmWindow() override; WindowType windowType() const override; diff --git a/src/client/qwaylandsurface.cpp b/src/client/qwaylandsurface.cpp index c35f01b56..21e70ce4f 100644 --- a/src/client/qwaylandsurface.cpp +++ b/src/client/qwaylandsurface.cpp @@ -72,8 +72,12 @@ QWaylandSurface *QWaylandSurface::fromWlSurface(::wl_surface *surface) void QWaylandSurface::handleScreenRemoved(QScreen *qScreen) { - auto *screen = static_cast<QWaylandScreen *>(qScreen->handle()); - if (m_screens.removeOne(screen)) + auto *platformScreen = qScreen->handle(); + if (platformScreen->isPlaceholder()) + return; + + auto *waylandScreen = static_cast<QWaylandScreen *>(qScreen->handle()); + if (m_screens.removeOne(waylandScreen)) emit screensChanged(); } diff --git a/src/client/qwaylandvulkaninstance.cpp b/src/client/qwaylandvulkaninstance.cpp new file mode 100644 index 000000000..5edbd4757 --- /dev/null +++ b/src/client/qwaylandvulkaninstance.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandvulkaninstance_p.h" +#include "qwaylandwindow_p.h" +#include "qwaylandscreen_p.h" +#include "qwaylanddisplay_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandVulkanInstance::QWaylandVulkanInstance(QVulkanInstance *instance) + : m_instance(instance) +{ + loadVulkanLibrary(QStringLiteral("vulkan")); +} + +QWaylandVulkanInstance::~QWaylandVulkanInstance() = default; + +void QWaylandVulkanInstance::createOrAdoptInstance() +{ + QByteArrayList extraExtensions; + extraExtensions << QByteArrayLiteral("VK_KHR_wayland_surface"); + initInstance(m_instance, extraExtensions); + + if (!m_vkInst) + return; + + m_getPhysDevPresSupport = reinterpret_cast<PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR>( + m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceWaylandPresentationSupportKHR")); + if (!m_getPhysDevPresSupport) + qWarning() << "Failed to find vkGetPhysicalDeviceWaylandPresentationSupportKHR"; +} + +bool QWaylandVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + QWindow *window) +{ + if (!m_getPhysDevPresSupport || !m_getPhysDevSurfaceSupport) + return true; + + auto *w = static_cast<QWaylandWindow *>(window->handle()); + if (!w) { + qWarning() << "Attempted to call supportsPresent() without a valid platform window"; + return false; + } + wl_display *display = w->display()->wl_display(); + bool ok = m_getPhysDevPresSupport(physicalDevice, queueFamilyIndex, display); + + VkSurfaceKHR surface = QVulkanInstance::surfaceForWindow(window); + VkBool32 supported = false; + m_getPhysDevSurfaceSupport(physicalDevice, queueFamilyIndex, surface, &supported); + ok &= bool(supported); + + return ok; +} + +VkSurfaceKHR QWaylandVulkanInstance::createSurface(QWaylandWindow *window) +{ + VkSurfaceKHR surface = VK_NULL_HANDLE; + + if (!m_createSurface) { + m_createSurface = reinterpret_cast<PFN_vkCreateWaylandSurfaceKHR>( + m_vkGetInstanceProcAddr(m_vkInst, "vkCreateWaylandSurfaceKHR")); + } + if (!m_createSurface) { + qWarning() << "Failed to find vkCreateWaylandSurfaceKHR"; + return surface; + } + + VkWaylandSurfaceCreateInfoKHR surfaceInfo; + memset(&surfaceInfo, 0, sizeof(surfaceInfo)); + surfaceInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; + surfaceInfo.display = window->display()->wl_display(); + surfaceInfo.surface = window->wlSurface(); + VkResult err = m_createSurface(m_vkInst, &surfaceInfo, nullptr, &surface); + if (err != VK_SUCCESS) + qWarning("Failed to create Vulkan surface: %d", err); + + return surface; +} + +void QWaylandVulkanInstance::presentAboutToBeQueued(QWindow *window) +{ + auto *w = static_cast<QWaylandWindow *>(window->handle()); + if (!w) { + qWarning() << "Attempted to call presentAboutToBeQueued() without a valid platform window"; + return; + } + w->handleUpdate(); +} + +} // namespace QtWaylandClient + +QT_END_NAMESPACE diff --git a/src/client/qwaylandvulkaninstance_p.h b/src/client/qwaylandvulkaninstance_p.h new file mode 100644 index 000000000..b68293b78 --- /dev/null +++ b/src/client/qwaylandvulkaninstance_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDVULKANINSTANCE_P_H +#define QWAYLANDVULKANINSTANCE_P_H + +#if defined(VULKAN_H_) && !defined(VK_USE_PLATFORM_WAYLAND_KHR) +#error "vulkan.h included without Wayland WSI" +#endif + +#define VK_USE_PLATFORM_WAYLAND_KHR + +#include <QtVulkanSupport/private/qbasicvulkanplatforminstance_p.h> +#include <QLibrary> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandWindow; + +class QWaylandVulkanInstance : public QBasicPlatformVulkanInstance +{ +public: + explicit QWaylandVulkanInstance(QVulkanInstance *instance); + ~QWaylandVulkanInstance() override; + + void createOrAdoptInstance() override; + bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; + void presentAboutToBeQueued(QWindow *window) override; + + VkSurfaceKHR createSurface(QWaylandWindow *window); + +private: + QVulkanInstance *m_instance = nullptr; + PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR m_getPhysDevPresSupport = nullptr; + PFN_vkCreateWaylandSurfaceKHR m_createSurface = nullptr; +}; + +} // namespace QtWaylandClient + +QT_END_NAMESPACE + +#endif // QWAYLANDVULKANINSTANCE_P_H diff --git a/src/client/qwaylandvulkanwindow.cpp b/src/client/qwaylandvulkanwindow.cpp new file mode 100644 index 000000000..eb341529a --- /dev/null +++ b/src/client/qwaylandvulkanwindow.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandvulkanwindow_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandVulkanWindow::QWaylandVulkanWindow(QWindow *window, QWaylandDisplay *display) + : QWaylandWindow(window, display) +{ +} + +QWaylandVulkanWindow::~QWaylandVulkanWindow() +{ + if (m_surface) { + QVulkanInstance *inst = window()->vulkanInstance(); + if (inst) + static_cast<QWaylandVulkanInstance *>(inst->handle())->destroySurface(m_surface); + } +} + +QWaylandWindow::WindowType QWaylandVulkanWindow::windowType() const +{ + return QWaylandWindow::Vulkan; +} + +VkSurfaceKHR *QWaylandVulkanWindow::surface() +{ + if (m_surface) + return &m_surface; + + QVulkanInstance *vulkanInstance = window()->vulkanInstance(); + if (!vulkanInstance) { + qWarning() << "Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?"; + return nullptr; + } + + auto *waylandVulkanInstance = static_cast<QWaylandVulkanInstance *>(vulkanInstance->handle()); + m_surface = waylandVulkanInstance->createSurface(this); + + return &m_surface; +} + +} // namespace QtWaylandClient + +QT_END_NAMESPACE diff --git a/src/client/qwaylandvulkanwindow_p.h b/src/client/qwaylandvulkanwindow_p.h new file mode 100644 index 000000000..3fd394e62 --- /dev/null +++ b/src/client/qwaylandvulkanwindow_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDVULKANWINDOW_P_H +#define QWAYLANDVULKANWINDOW_P_H + +#include "qwaylandwindow_p.h" +#include "qwaylandvulkaninstance_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandVulkanWindow : public QWaylandWindow +{ +public: + explicit QWaylandVulkanWindow(QWindow *window, QWaylandDisplay *display); + ~QWaylandVulkanWindow() override; + + WindowType windowType() const override; + + VkSurfaceKHR *surface(); + +private: + VkSurfaceKHR m_surface = VK_NULL_HANDLE; +}; + +} // namespace QtWaylandClient + +QT_END_NAMESPACE + +#endif // QWAYLANDVULKANWINDOW_P_H diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 0df99d9fe..8cc26d71c 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -73,9 +73,9 @@ Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore") QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr; -QWaylandWindow::QWaylandWindow(QWindow *window) +QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display) : QPlatformWindow(window) - , mDisplay(waylandScreen()->display()) + , mDisplay(display) , mFrameQueue(mDisplay->createEventQueue()) , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) { @@ -177,7 +177,7 @@ void QWaylandWindow::initWindow() } } - mScale = waylandScreen()->scale(); + mScale = waylandScreen() ? waylandScreen()->scale() : 1; // fallback to 1 if we don't have a real screen // Enable high-dpi rendering. Scale() returns the screen scale factor and will // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() @@ -402,14 +402,14 @@ void QWaylandWindow::closePopups(QWaylandWindow *parent) } } -QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const +QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const { if (mSurface) { if (auto *screen = mSurface->oldestEnteredScreen()) return screen; } - return waylandScreen(); + return QPlatformWindow::screen(); } void QWaylandWindow::setVisible(bool visible) @@ -672,6 +672,19 @@ QRect QWaylandWindow::windowContentGeometry() const return QRect(QPoint(), surfaceSize()); } +/*! + * Converts from wl_surface coordinates to Qt window coordinates. Qt window + * coordinates start inside (not including) the window decorations, while + * wl_surface coordinates start at the first pixel of the buffer. Potentially, + * this should be in the window shadow, although we don't have those. So for + * now, it's the first pixel of the decorations. + */ +QPointF QWaylandWindow::mapFromWlSurface(const QPointF &surfacePosition) const +{ + const QMargins margins = frameMargins(); + return QPointF(surfacePosition.x() - margins.left(), surfacePosition.y() - margins.top()); +} + wl_surface *QWaylandWindow::wlSurface() { return mSurface ? mSurface->object() : nullptr; @@ -689,7 +702,11 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const QWaylandScreen *QWaylandWindow::waylandScreen() const { - return static_cast<QWaylandScreen *>(QPlatformWindow::screen()); + auto *platformScreen = QPlatformWindow::screen(); + Q_ASSERT(platformScreen); + if (platformScreen->isPlaceholder()) + return nullptr; + return static_cast<QWaylandScreen *>(platformScreen); } void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) @@ -852,7 +869,7 @@ QWaylandWindow *QWaylandWindow::transientParent() const void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e) { - if (e.type == QWaylandPointerEvent::Leave) { + if (e.type == QEvent::Leave) { if (mWindowDecoration) { if (mMouseEventsInContentArea) QWindowSystemInterface::handleLeaveEvent(window()); @@ -869,24 +886,26 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan handleMouseEventWithDecoration(inputDevice, e); } else { switch (e.type) { - case QWaylandPointerEvent::Enter: + case QEvent::Enter: QWindowSystemInterface::handleEnterEvent(window(), e.local, e.global); break; - case QWaylandPointerEvent::Press: - case QWaylandPointerEvent::Release: - case QWaylandPointerEvent::Motion: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.modifiers); + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.button, e.type, e.modifiers); break; - case QWaylandPointerEvent::Wheel: + case QEvent::Wheel: QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, false); break; + default: + Q_UNREACHABLE(); } } #if QT_CONFIG(cursor) - if (e.type == QWaylandPointerEvent::Enter) { + if (e.type == QEvent::Enter) { QRect contentGeometry = windowContentGeometry().marginsRemoved(frameMargins()); if (contentGeometry.contains(e.local.toPoint())) restoreMouseCursor(inputDevice); @@ -918,10 +937,8 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe geometry().size().width() - marg.right(), geometry().size().height() - marg.bottom()); if (windowRect.contains(e.local.toPoint()) || mMousePressedInContentArea != Qt::NoButton) { - QPointF localTranslated = e.local; + const QPointF localTranslated = mapFromWlSurface(e.local); QPointF globalTranslated = e.global; - localTranslated.setX(localTranslated.x() - marg.left()); - localTranslated.setY(localTranslated.y() - marg.top()); globalTranslated.setX(globalTranslated.x() - marg.left()); globalTranslated.setY(globalTranslated.y() - marg.top()); if (!mMouseEventsInContentArea) { @@ -932,21 +949,23 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe } switch (e.type) { - case QWaylandPointerEvent::Enter: + case QEvent::Enter: QWindowSystemInterface::handleEnterEvent(window(), localTranslated, globalTranslated); break; - case QWaylandPointerEvent::Press: - case QWaylandPointerEvent::Release: - case QWaylandPointerEvent::Motion: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers); + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.button, e.type, e.modifiers); break; - case QWaylandPointerEvent::Wheel: { + case QEvent::Wheel: { QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, false); break; } + default: + Q_UNREACHABLE(); } mMouseEventsInContentArea = true; @@ -961,7 +980,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe void QWaylandWindow::handleScreensChanged() { - QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); + QPlatformScreen *newScreen = calculateScreenFromSurfaceEvents(); if (newScreen == mLastReportedScreen) return; @@ -969,7 +988,7 @@ void QWaylandWindow::handleScreensChanged() QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); mLastReportedScreen = newScreen; - int scale = newScreen->scale(); + int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale(); if (scale != mScale) { mScale = scale; if (mSurface && mDisplay->compositorVersion() >= 3) diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 5f15ca304..35fa1fdfc 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -89,10 +89,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformW public: enum WindowType { Shm, - Egl + Egl, + Vulkan }; - QWaylandWindow(QWindow *window); + QWaylandWindow(QWindow *window, QWaylandDisplay *display); ~QWaylandWindow() override; virtual WindowType windowType() const = 0; @@ -128,6 +129,7 @@ public: QMargins frameMargins() const override; QSize surfaceSize() const; QRect windowContentGeometry() const; + QPointF mapFromWlSurface(const QPointF &surfacePosition) const; QWaylandSurface *waylandSurface() const { return mSurface.data(); } ::wl_surface *wlSurface(); @@ -240,7 +242,7 @@ protected: bool mSentInitialResize = false; QPoint mOffset; int mScale = 1; - QWaylandScreen *mLastReportedScreen = nullptr; + QPlatformScreen *mLastReportedScreen = nullptr; QIcon mWindowIcon; @@ -261,7 +263,7 @@ private: void reset(bool sendDestroyEvent = true); void sendExposeEvent(const QRect &rect); static void closePopups(QWaylandWindow *parent); - QWaylandScreen *calculateScreenFromSurfaceEvents() const; + QPlatformScreen *calculateScreenFromSurfaceEvents() const; void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e); void handleScreensChanged(); diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 5b77a3be1..6c23242bd 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -196,11 +196,11 @@ void QWaylandCompositorPrivate::init() if (!socket_name.isEmpty()) { if (wl_display_add_socket(display, socket_name.constData())) - qFatal("Fatal: Failed to open server socket\n"); + qFatal("Fatal: Failed to open server socket: \"%s\". XDG_RUNTIME_DIR is: \"%s\"\n", socket_name.constData(), getenv("XDG_RUNTIME_DIR")); } else { const char *autoSocketName = wl_display_add_socket_auto(display); if (!autoSocketName) - qFatal("Fatal: Failed to open server socket\n"); + qFatal("Fatal: Failed to open default server socket. XDG_RUNTIME_DIR is: \"%s\"\n", getenv("XDG_RUNTIME_DIR")); socket_name = autoSocketName; emit q->socketNameChanged(socket_name); } diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 6c4ca8b13..44740feff 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -289,8 +289,9 @@ public: } auto texture = buffer.toOpenGLTexture(); + GLuint textureId = texture->textureId(); auto size = surface->bufferSize(); - m_sgTex = surfaceItem->window()->createTextureFromId(texture->textureId(), size, opt); + m_sgTex = surfaceItem->window()->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, &textureId, 0, size, opt); #else qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported"; #endif diff --git a/src/compositor/configure.json b/src/compositor/configure.json index 0dbb33643..42df2ddf0 100644 --- a/src/compositor/configure.json +++ b/src/compositor/configure.json @@ -9,14 +9,34 @@ "libraries": { "wayland-server": { "label": "wayland-server", - "test": "wayland", + "headers": "wayland-version.h", + "test": { + "main": [ + "#if WAYLAND_VERSION_MAJOR < 1", + "# error Wayland 1.8.0 or higher required", + "#endif", + "#if WAYLAND_VERSION_MAJOR == 1", + "# if WAYLAND_VERSION_MINOR < 8", + "# error Wayland 1.8.0 or higher required", + "# endif", + "# if WAYLAND_VERSION_MINOR == 8", + "# if WAYLAND_VERSION_MICRO < 0", + "# error Wayland 1.8.0 or higher required", + "# endif", + "# endif", + "#endif" + ] + }, "sources": [ { "type": "pkgConfig", "args": "wayland-server" }, "-lwayland-server" ] }, "wayland-egl": { - "test": "wayland_egl", + "headers": "wayland-egl.h", + "test": { + "main": "struct wl_egl_window *window = wl_egl_window_create(0, 100, 100);" + }, "sources": [ { "type": "pkgConfig", "args": "wayland-egl" }, "-lwayland-egl", @@ -45,14 +65,24 @@ ] }, "xcomposite": { - "test": "xcomposite", + "headers": "X11/extensions/Xcomposite.h", + "test": { + "main": "XCompositeRedirectWindow((Display *)0,(Window) 0, CompositeRedirectManual);" + }, "sources": [ { "type": "pkgConfig", "args": "xcomposite" }, "-lxcomposite" ] }, "glx": { - "test": "glx", + "headers": "GL/glx.h", + "test": { + "main": [ + "Display *dpy = XOpenDisplay(0);", + "int items = 0;", + "GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), 0 , &items);" + ] + }, "sources": [ { "type": "pkgConfig", "args": "x11 gl" }, "-lX11 -lGl" @@ -68,30 +98,102 @@ }, "drm-egl-server": { "type": "compile", - "test": "drm_egl_server", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h" + ], + "main": [ + "#ifdef EGL_MESA_drm_image", + "return 0;", + "#else", + "#error Requires EGL_MESA_drm_image to be defined", + "return 1;", + "#endif" + ] + }, "use": "egl" }, "libhybris-egl-server": { "type": "compile", - "test": "libhybris_egl_server", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h", + "hybris/eglplatformcommon/hybris_nativebufferext.h" + ], + "main": [ + "#ifdef EGL_HYBRIS_native_buffer", + "return 0;", + "#else", + "#error Requires EGL_HYBRIS_native_buffer to be defined", + "return 1;", + "#endif" + ] + }, "use": "egl" }, "dmabuf-server-buffer": { "label": "Linux dma-buf Buffer Sharing", "type": "compile", - "test": "dmabuf_server_buffer", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h", + "drm_fourcc.h" + ], + "main": [ + "#ifdef EGL_LINUX_DMA_BUF_EXT", + "return 0;", + "#else", + "#error Requires EGL_LINUX_DMA_BUF_EXT", + "return 1;", + "#endif" + ] + }, "use": "egl drm" }, "dmabuf-client-buffer": { "label": "Linux Client dma-buf Buffer Sharing", "type": "compile", - "test": "dmabuf_client_buffer", + "test": { + "include": [ + "EGL/egl.h", + "EGL/eglext.h", + "drm_mode.h", + "drm_fourcc.h" + ], + "main": [ + "// test if DMA BUF is supported", + "#ifndef EGL_LINUX_DMA_BUF_EXT", + "#error DMA BUF Extension not available", + "#endif", + "// test if DMA BUF import modifier extension is supported", + "#ifndef EGL_EXT_image_dma_buf_import_modifiers", + "#error DMA BUF Import modifier extension not available", + "#endif", + "return 0;" + ] + }, "use": "egl drm" }, "vulkan-server-buffer": { "label": "Vulkan Buffer Sharing", "type": "compile", - "test": "vulkan_server_buffer" + "test": { + "head": [ + "#define VK_USE_PLATFORM_WAYLAND_KHR 1" + ], + "include": [ + "vulkan/vulkan.h" + ], + "main": [ + "VkExportMemoryAllocateInfoKHR exportAllocInfo = {};", + "exportAllocInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR;", + "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;", + "return 0;" + ] + } } }, @@ -147,7 +249,7 @@ }, "wayland-vulkan-server-buffer": { "label": "Vulkan-based server buffer integration", - "condition": "features.wayland-server && features.opengl && features.egl && tests.vulkan-server-buffer", + "condition": "features.wayland-server && features.vulkan && features.opengl && features.egl && tests.vulkan-server-buffer", "output": [ "privateFeature" ] }, "wayland-shm-emulation-server-buffer": { diff --git a/src/compositor/extensions/qwltexturesharingextension.cpp b/src/compositor/extensions/qwltexturesharingextension.cpp index 6f801e956..bbd18e1a5 100644 --- a/src/compositor/extensions/qwltexturesharingextension.cpp +++ b/src/compositor/extensions/qwltexturesharingextension.cpp @@ -301,13 +301,13 @@ QString QWaylandTextureSharingExtension::getExistingFilePath(const QString &key) if (key.contains(QLatin1String("../"))) return QString(); - for (auto dir : m_image_dirs) { + for (auto dir : qAsConst(m_image_dirs)) { QString path = dir + key; if (QFileInfo::exists(path)) return path; } - for (auto dir : m_image_dirs) { + for (auto dir : qAsConst(m_image_dirs)) { for (auto ext : m_image_suffixes) { QString fp = dir + key + ext; //qDebug() << "trying" << fp; diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp index 3a34d2561..0dc389bb8 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp @@ -143,7 +143,7 @@ bool QWaylandEglClientBufferIntegration::supportsWindowDecoration() const QWaylandWindow *QWaylandEglClientBufferIntegration::createEglWindow(QWindow *window) { - return new QWaylandEglWindow(window); + return new QWaylandEglWindow(window, m_display); } QPlatformOpenGLContext *QWaylandEglClientBufferIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp index 030422c56..e8d43fad4 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp @@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -QWaylandEglWindow::QWaylandEglWindow(QWindow *window) - : QWaylandWindow(window) +QWaylandEglWindow::QWaylandEglWindow(QWindow *window, QWaylandDisplay *display) + : QWaylandWindow(window, display) , m_clientBufferIntegration(static_cast<QWaylandEglClientBufferIntegration *>(mDisplay->clientBufferIntegration())) { QSurfaceFormat fmt = window->requestedFormat(); diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h index 9e6cb876c..878532afc 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h @@ -56,7 +56,7 @@ class QWaylandEglWindow : public QWaylandWindow { Q_OBJECT public: - QWaylandEglWindow(QWindow *window); + QWaylandEglWindow(QWindow *window, QWaylandDisplay *display); ~QWaylandEglWindow(); WindowType windowType() const override; void ensureSize() override; diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp index 57a7ba7b6..a7377830f 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLClientBufferIntegration *glxIntegration) - : QWaylandWindow(window) + : QWaylandWindow(window, glxIntegration->waylandDisplay()) , m_glxIntegration(glxIntegration) , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT)) { diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp index 2b491e24d..b0c78b631 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) - : QWaylandWindow(window) + : QWaylandWindow(window, glxIntegration->waylandDisplay()) , m_glxIntegration(glxIntegration) , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT)) { diff --git a/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.pro b/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.pro index 53f7af8aa..c89ecec00 100644 --- a/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.pro +++ b/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.pro @@ -5,6 +5,8 @@ OTHER_FILES += brcm-egl.json SOURCES += \ main.cpp +TARGET = qt-wayland-compositor-brcm-egl + include(../../../../hardwareintegration/compositor/brcm-egl/brcm-egl.pri) PLUGIN_TYPE = wayland-graphics-integration-server diff --git a/src/plugins/hardwareintegration/compositor/dmabuf-server/dmabuf-server.pro b/src/plugins/hardwareintegration/compositor/dmabuf-server/dmabuf-server.pro index 1601a384c..d96e58135 100644 --- a/src/plugins/hardwareintegration/compositor/dmabuf-server/dmabuf-server.pro +++ b/src/plugins/hardwareintegration/compositor/dmabuf-server/dmabuf-server.pro @@ -5,7 +5,9 @@ OTHER_FILES += dmabuf-server.json SOURCES += \ main.cpp -include($PWD/../../../../../hardwareintegration/compositor/dmabuf-server/dmabuf-server.pri) +TARGET = qt-wayland-compositor-dmabuf-server-buffer + +include(../../../../hardwareintegration/compositor/dmabuf-server/dmabuf-server.pri) PLUGIN_TYPE = wayland-graphics-integration-server PLUGIN_CLASS_NAME = DmaBufServerBufferIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pro b/src/plugins/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pro index 040031122..2ba17c388 100644 --- a/src/plugins/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pro +++ b/src/plugins/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pro @@ -5,7 +5,9 @@ OTHER_FILES += drm-egl-server.json SOURCES += \ main.cpp -include($PWD/../../../../../hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri) +TARGET = qt-wayland-compositor-drm-egl-server-buffer + +include(../../../../hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri) PLUGIN_TYPE = wayland-graphics-integration-server PLUGIN_CLASS_NAME = DrmEglServerBufferIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pro b/src/plugins/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pro index ff16b20bf..c18884a96 100644 --- a/src/plugins/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pro +++ b/src/plugins/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pro @@ -7,7 +7,9 @@ OTHER_FILES += vsp2.json SOURCES += \ main.cpp -include($PWD/../../../../../../hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pri) +TARGET = qt-wayland-compositor-vsp2 + +include(../../../../../hardwareintegration/compositor/hardwarelayer/vsp2/vsp2.pri) PLUGIN_TYPE = wayland-hardware-layer-integration PLUGIN_CLASS_NAME = Vsp2HardwareLayerIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro index 9e28c7e8c..c9c3a0daf 100644 --- a/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro +++ b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro @@ -5,7 +5,9 @@ OTHER_FILES += libhybris-egl-server.json SOURCES += \ main.cpp -include($PWD/../../../../../hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri) +TARGET = qt-wayland-compositor-libybris-egl-server.json + +include(../../../../hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri) PLUGIN_TYPE = wayland-graphics-integration-server PLUGIN_CLASS_NAME = LibHybrisEglServerBufferIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linux-dmabuf-unstable-v1.pro b/src/plugins/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linux-dmabuf-unstable-v1.pro index bc4311423..1f76f9f00 100644 --- a/src/plugins/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linux-dmabuf-unstable-v1.pro +++ b/src/plugins/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linux-dmabuf-unstable-v1.pro @@ -5,6 +5,8 @@ OTHER_FILES += linux-dmabuf.json SOURCES += \ main.cpp \ +TARGET = qt-wayland-compositor-linux-dmabuf-unstable-v1 + include(../../../../hardwareintegration/compositor/linux-dmabuf-unstable-v1/linux-dmabuf-unstable-v1.pri) PLUGIN_TYPE = wayland-graphics-integration-server diff --git a/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro index 56a1bac21..865af1a7d 100644 --- a/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro +++ b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro @@ -5,7 +5,9 @@ OTHER_FILES += shm-emulation-server.json SOURCES += \ main.cpp -include($PWD/../../../../../hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri) +TARGET = qt-wayland-compositor-shm-emulation-server + +include(../../../../hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri) PLUGIN_TYPE = wayland-graphics-integration-server PLUGIN_CLASS_NAME = ShmServerBufferIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/vulkan-server/vulkan-server.pro b/src/plugins/hardwareintegration/compositor/vulkan-server/vulkan-server.pro index 053654218..dc82c3f26 100644 --- a/src/plugins/hardwareintegration/compositor/vulkan-server/vulkan-server.pro +++ b/src/plugins/hardwareintegration/compositor/vulkan-server/vulkan-server.pro @@ -5,7 +5,9 @@ OTHER_FILES += vulkan-server.json SOURCES += \ main.cpp -include($PWD/../../../../../hardwareintegration/compositor/vulkan-server/vulkan-server.pri) +TARGET = qt-wayland-compositor-vulkan-server + +include(../../../../hardwareintegration/compositor/vulkan-server/vulkan-server.pri) PLUGIN_TYPE = wayland-graphics-integration-server PLUGIN_CLASS_NAME = VulkanServerBufferIntegrationPlugin diff --git a/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro b/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro index 6aecefffd..d452220c5 100644 --- a/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro +++ b/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro @@ -5,7 +5,7 @@ OTHER_FILES += wayland-egl.json SOURCES += \ main.cpp -TARGET = qt-plugin-wayland-egl +TARGET = qt-wayland-compositor-wayland-egl include(../../../../hardwareintegration/compositor/wayland-egl/wayland-egl.pri) diff --git a/src/plugins/hardwareintegration/compositor/wayland-eglstream-controller/wayland-eglstream-controller.pro b/src/plugins/hardwareintegration/compositor/wayland-eglstream-controller/wayland-eglstream-controller.pro index f1ca7183a..6d259a687 100644 --- a/src/plugins/hardwareintegration/compositor/wayland-eglstream-controller/wayland-eglstream-controller.pro +++ b/src/plugins/hardwareintegration/compositor/wayland-eglstream-controller/wayland-eglstream-controller.pro @@ -5,6 +5,8 @@ OTHER_FILES += wayland-eglstream-controller.json SOURCES += \ main.cpp \ +TARGET = qt-wayland-compositor-wayland-eglstream-controller + include(../../../../hardwareintegration/compositor/wayland-eglstream-controller/wayland-eglstream-controller.pri) PLUGIN_TYPE = wayland-graphics-integration-server diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pro b/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pro index 7c391bd1c..298ed2fc6 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pro +++ b/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pro @@ -5,6 +5,8 @@ OTHER_FILES += xcomposite-egl.json SOURCES += \ main.cpp +TARGET = qt-wayland-compositor-xcomposite-egl + include(../../../../hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri) PLUGIN_TYPE = wayland-graphics-integration-server diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pro b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pro index 0f49471da..41e5c2ec5 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pro +++ b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pro @@ -5,6 +5,8 @@ OTHER_FILES += xcomposite-glx.json SOURCES += \ main.cpp +TARGET = qt-wayland-compositor-xcomposite-glx + include(../../../../hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri) PLUGIN_TYPE = wayland-graphics-integration-server diff --git a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp index 26f598895..636ef0807 100644 --- a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp +++ b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp @@ -50,10 +50,11 @@ QWaylandFullScreenShellV1Surface::QWaylandFullScreenShellV1Surface(QtWayland::zw , m_shell(shell) , m_window(window) { - auto screen = static_cast<QWaylandScreen *>(m_window->screen()); + auto *screen = m_window->waylandScreen(); + auto *output = screen ? screen->output() : nullptr; m_shell->present_surface(m_window->wlSurface(), QtWayland::zwp_fullscreen_shell_v1::present_method_default, - screen->output()); + output); } } // namespace QtWaylandClient diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 9691b857f..24977a2f2 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -92,7 +92,7 @@ private: }; bool isServerSide(); - bool parseOption(const char *str); + bool parseOption(const QByteArray &str); QByteArray byteArrayValue(const QXmlStreamReader &xml, const char *name); int intValue(const QXmlStreamReader &xml, const char *name, int defaultValue = 0); @@ -123,29 +123,55 @@ private: QByteArray m_scannerName; QByteArray m_headerPath; QByteArray m_prefix; + QVector <QByteArray> m_includes; QXmlStreamReader *m_xml = nullptr; }; bool Scanner::parseArguments(int argc, char **argv) { - m_scannerName = argv[0]; + QVector<QByteArray> args; + args.reserve(argc); + for (int i = 0; i < argc; ++i) + args << QByteArray(argv[i]); - if (argc <= 2 || !parseOption(argv[1])) + m_scannerName = args[0]; + + if (argc <= 2 || !parseOption(args[1])) return false; - m_protocolFilePath = QByteArray(argv[2]); + m_protocolFilePath = args[2]; - if (argc >= 4) - m_headerPath = QByteArray(argv[3]); - if (argc == 5) - m_prefix = QByteArray(argv[4]); + if (argc > 3 && !args[3].startsWith('-')) { + // legacy positional arguments + m_headerPath = args[3]; + if (argc == 5) + m_prefix = args[4]; + } else { + // --header-path=<path> (14 characters) + // --prefix=<prefix> (9 characters) + // --add-include=<include> (14 characters) + for (int pos = 3; pos < argc; pos++) { + const QByteArray &option = args[pos]; + if (option.startsWith("--header-path=")) { + m_headerPath = option.mid(14); + } else if (option.startsWith("--prefix=")) { + m_prefix = option.mid(10); + } else if (option.startsWith("--add-include=")) { + auto include = option.mid(14); + if (!include.isEmpty()) + m_includes << include; + } else { + return false; + } + } + } return true; } void Scanner::printUsage() { - fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", m_scannerName.constData()); + fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [--header-path=<path>] [--prefix=<prefix>] [--add-include=<include>]\n", m_scannerName.constData()); } bool Scanner::isServerSide() @@ -153,15 +179,15 @@ bool Scanner::isServerSide() return m_option == ServerHeader || m_option == ServerCode; } -bool Scanner::parseOption(const char *str) +bool Scanner::parseOption(const QByteArray &str) { - if (str == QLatin1String("client-header")) + if (str == "client-header") m_option = ClientHeader; - else if (str == QLatin1String("server-header")) + else if (str == "server-header") m_option = ServerHeader; - else if (str == QLatin1String("client-code")) + else if (str == "client-code") m_option = ClientCode; - else if (str == QLatin1String("server-code")) + else if (str == "server-code") m_option = ServerCode; else return false; @@ -441,6 +467,9 @@ bool Scanner::process() if (m_xml->hasError()) return false; + for (auto b : qAsConst(m_includes)) + printf("#include %s\n", b.constData()); + if (m_option == ServerHeader) { QByteArray inclusionGuard = QByteArray("QT_WAYLAND_SERVER_") + preProcessorProtocolName.constData(); printf("#ifndef %s\n", inclusionGuard.constData()); diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index 4b1eb2458..cda1765e3 100644 --- a/tests/auto/client/client.pro +++ b/tests/auto/client/client.pro @@ -5,6 +5,7 @@ SUBDIRS += \ datadevicev1 \ fullscreenshellv1 \ iviapplication \ + nooutput \ output \ primaryselectionv1 \ seatv4 \ diff --git a/tests/auto/client/inputcontext/tst_inputcontext.cpp b/tests/auto/client/inputcontext/tst_inputcontext.cpp index 3e6de4a08..1f07eb520 100644 --- a/tests/auto/client/inputcontext/tst_inputcontext.cpp +++ b/tests/auto/client/inputcontext/tst_inputcontext.cpp @@ -58,8 +58,6 @@ private: QByteArray mComposeModule = QByteArray("QComposeInputContext"); // default input context QByteArray mIbusModule = QByteArray("QIBusPlatformInputContext"); QByteArray mWaylandModule = QByteArray("QtWaylandClient::QWaylandInputContext"); - - TextInputManager *mTextInputManager = nullptr; }; void tst_inputcontext::initTestCase() diff --git a/tests/auto/client/nooutput/nooutput.pro b/tests/auto/client/nooutput/nooutput.pro new file mode 100644 index 000000000..1d8dc5626 --- /dev/null +++ b/tests/auto/client/nooutput/nooutput.pro @@ -0,0 +1,5 @@ +include (../shared/shared.pri) + +TARGET = tst_nooutput +SOURCES += tst_nooutput.cpp + diff --git a/tests/auto/client/nooutput/tst_nooutput.cpp b/tests/auto/client/nooutput/tst_nooutput.cpp new file mode 100644 index 000000000..098d88d99 --- /dev/null +++ b/tests/auto/client/nooutput/tst_nooutput.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mockcompositor.h" +#include <QtGui/QScreen> +#include <QtGui/QRasterWindow> + +using namespace MockCompositor; + +class NoOutputCompositor : public DefaultCompositor { +public: + NoOutputCompositor() + { + exec([this] { removeAll<Output>(); }); + m_config.autoConfigure = true; + } +}; + +class tst_nooutput : public QObject, private NoOutputCompositor +{ + Q_OBJECT +private slots: + void cleanup() + { + // There should be no wl_outputs in this test + QCOMPOSITOR_COMPARE(getAll<Output>().size(), 0); + QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); + } + void noScreens(); +}; + +void tst_nooutput::noScreens() +{ + QRasterWindow window; + window.resize(16, 16); + window.show(); + + // We have to handle showing a window when there are no real outputs + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); +} + +QCOMPOSITOR_TEST_MAIN(tst_nooutput) +#include "tst_nooutput.moc" diff --git a/tests/auto/client/output/tst_output.cpp b/tests/auto/client/output/tst_output.cpp index 29c773cf6..e9944f815 100644 --- a/tests/auto/client/output/tst_output.cpp +++ b/tests/auto/client/output/tst_output.cpp @@ -53,6 +53,7 @@ private slots: void windowScreens(); void removePrimaryScreen(); void screenOrder(); + void removeAllScreens(); }; void tst_output::primaryScreen() @@ -227,5 +228,47 @@ void tst_output::screenOrder() }); } +// This is different from tst_nooutput::noScreens because here we have a screen at platform +// integration initialization, which we then remove. +void tst_output::removeAllScreens() +{ + QRasterWindow window1; + window1.resize(400, 320); + window1.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface(0) && xdgSurface(0)->m_committedConfigureSerial); + + const QString wlOutputPrimaryScreenModel = QGuiApplication::primaryScreen()->model(); + + // Get screen info so we can restore it after + auto screenInfo = exec([=] { return output()->m_data; }); + exec([=] { remove(output()); }); + + // Make sure the wl_output is actually removed before we continue + QTRY_VERIFY(!QGuiApplication::primaryScreen() || QGuiApplication::primaryScreen()->model() != wlOutputPrimaryScreenModel); + + // Adding a window while there are no screens should also work + QRasterWindow window2; + window2.resize(400, 320); + window2.show(); + + exec([=] { add<Output>(screenInfo); }); + + // Things should be back to normal + QTRY_VERIFY(QGuiApplication::primaryScreen()); + QTRY_COMPARE(QGuiApplication::primaryScreen()->model(), wlOutputPrimaryScreenModel); + + // Test that we don't leave any fake screens around after we get a wl_output back. + QTRY_COMPARE(QGuiApplication::screens().size(), 1); + + // Qt may choose to recreate/hide windows in response to changing screens, so give the client + // some time to potentially mess up before we verify that the windows are visible. + xdgPingAndWaitForPong(); + + // Windows should be visible after we've reconnected the screen + QCOMPOSITOR_TRY_VERIFY(xdgToplevel(0) && xdgToplevel(0)->m_xdgSurface->m_committedConfigureSerial); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel(1) && xdgToplevel(1)->m_xdgSurface->m_committedConfigureSerial); + +} + QCOMPOSITOR_TEST_MAIN(tst_output) #include "tst_output.moc" diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp index e44cea63c..dca9dac49 100644 --- a/tests/auto/client/shared/mockcompositor.cpp +++ b/tests/auto/client/shared/mockcompositor.cpp @@ -52,7 +52,7 @@ DefaultCompositor::DefaultCompositor() // Pretend we made a copy of the buffer and just release it immediately surface->m_committed.buffer->send_release(); } - if (m_config.autoEnter && surface->m_outputs.empty()) + if (m_config.autoEnter && get<Output>() && surface->m_outputs.empty()) surface->sendEnter(get<Output>()); wl_display_flush_clients(m_display); }); diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp index e44475de7..76df6eb58 100644 --- a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp +++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp @@ -403,7 +403,7 @@ void tst_WaylandClientXdgShellV6::flushUnconfiguredXdgSurface() m_compositor->sendShellSurfaceConfigure(surface); QTRY_COMPARE(surface->image.size(), window.frameGeometry().size()); QTRY_COMPARE(surface->image.pixel(window.frameMargins().left(), window.frameMargins().top()), color.rgba()); - QVERIFY(window.isExposed()); + QTRY_VERIFY(window.isExposed()); } void tst_WaylandClientXdgShellV6::dontSpamExposeEvents() |