File indexing completed on 2025-02-16 05:03:12
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <QGuiApplication> 0013 #include <kwin_export.h> 0014 #include <xcb/xcb.h> 0015 0016 namespace KWin 0017 { 0018 0019 inline KWIN_EXPORT xcb_connection_t *connection() 0020 { 0021 return reinterpret_cast<xcb_connection_t *>(qApp->property("x11Connection").value<void *>()); 0022 } 0023 0024 inline KWIN_EXPORT xcb_window_t rootWindow() 0025 { 0026 return qApp->property("x11RootWindow").value<quint32>(); 0027 } 0028 0029 inline KWIN_EXPORT xcb_timestamp_t xTime() 0030 { 0031 return qApp->property("x11Time").value<xcb_timestamp_t>(); 0032 } 0033 0034 void KWIN_EXPORT grabXServer(); 0035 void KWIN_EXPORT ungrabXServer(); 0036 bool KWIN_EXPORT grabXKeyboard(xcb_window_t w = XCB_WINDOW_NONE); 0037 void KWIN_EXPORT ungrabXKeyboard(); 0038 0039 /** 0040 * Small helper class which performs grabXServer in the ctor and 0041 * ungrabXServer in the dtor. Use this class to ensure that grab and 0042 * ungrab are matched. 0043 */ 0044 class XServerGrabber 0045 { 0046 public: 0047 XServerGrabber() 0048 { 0049 grabXServer(); 0050 } 0051 ~XServerGrabber() 0052 { 0053 ungrabXServer(); 0054 } 0055 }; 0056 0057 }