File indexing completed on 2024-04-21 16:14:43

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 <kwinglobals.h>
0013 // XCB
0014 #include <xcb/xcb.h>
0015 
0016 namespace
0017 {
0018 static void forceXcb()
0019 {
0020     qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb"));
0021 }
0022 }
0023 
0024 namespace KWin
0025 {
0026 
0027 /**
0028  * Wrapper to create an 0,0x10,10 input only window for testing purposes
0029  */
0030 #ifndef NO_NONE_WINDOW
0031 static xcb_window_t createWindow()
0032 {
0033     xcb_window_t w = xcb_generate_id(connection());
0034     const uint32_t values[] = {true};
0035     xcb_create_window(connection(), 0, w, rootWindow(),
0036                       0, 0, 10, 10,
0037                       0, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT,
0038                       XCB_CW_OVERRIDE_REDIRECT, values);
0039     return w;
0040 }
0041 #endif
0042 
0043 /**
0044  * casts XCB_WINDOW_NONE to uint32_t. Needed to make QCOMPARE working.
0045  */
0046 #ifndef NO_NONE_WINDOW
0047 static uint32_t noneWindow()
0048 {
0049     return XCB_WINDOW_NONE;
0050 }
0051 #endif
0052 
0053 } // namespace
0054 
0055 #endif