File indexing completed on 2025-01-12 04:56:42
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #ifndef TESTUTILS_H 0010 #define TESTUTILS_H 0011 // KWin 0012 #include "effect/globals.h" 0013 #include "effect/xcb.h" 0014 0015 namespace 0016 { 0017 static void forceXcb() 0018 { 0019 qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb")); 0020 } 0021 } 0022 0023 namespace KWin 0024 { 0025 0026 /** 0027 * Wrapper to create an 0,0x10,10 input only window for testing purposes 0028 */ 0029 #ifndef NO_NONE_WINDOW 0030 static xcb_window_t createWindow() 0031 { 0032 xcb_window_t w = xcb_generate_id(connection()); 0033 const uint32_t values[] = {true}; 0034 xcb_create_window(connection(), 0, w, rootWindow(), 0035 0, 0, 10, 10, 0036 0, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, 0037 XCB_CW_OVERRIDE_REDIRECT, values); 0038 return w; 0039 } 0040 #endif 0041 0042 /** 0043 * casts XCB_WINDOW_NONE to uint32_t. Needed to make QCOMPARE working. 0044 */ 0045 #ifndef NO_NONE_WINDOW 0046 static uint32_t noneWindow() 0047 { 0048 return XCB_WINDOW_NONE; 0049 } 0050 #endif 0051 0052 } // namespace 0053 0054 #endif