libkwineffects: Stop including xcb/xcb.h everywhere
Provide a kwinxcb.h header file instead that offers the xcb-specific bits from that API. It helps keep kwin effects disconnected from XCB.master
parent
43291d971a
commit
d6b07b313f
@ -0,0 +1,57 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <kwin_export.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
inline KWIN_EXPORT xcb_connection_t *connection()
|
||||
{
|
||||
return reinterpret_cast<xcb_connection_t *>(qApp->property("x11Connection").value<void *>());
|
||||
}
|
||||
|
||||
inline KWIN_EXPORT xcb_window_t rootWindow()
|
||||
{
|
||||
return qApp->property("x11RootWindow").value<quint32>();
|
||||
}
|
||||
|
||||
inline KWIN_EXPORT xcb_timestamp_t xTime()
|
||||
{
|
||||
return qApp->property("x11Time").value<xcb_timestamp_t>();
|
||||
}
|
||||
|
||||
void KWIN_EXPORT grabXServer();
|
||||
void KWIN_EXPORT ungrabXServer();
|
||||
bool KWIN_EXPORT grabXKeyboard(xcb_window_t w = XCB_WINDOW_NONE);
|
||||
void KWIN_EXPORT ungrabXKeyboard();
|
||||
|
||||
/**
|
||||
* Small helper class which performs grabXServer in the ctor and
|
||||
* ungrabXServer in the dtor. Use this class to ensure that grab and
|
||||
* ungrab are matched.
|
||||
*/
|
||||
class XServerGrabber
|
||||
{
|
||||
public:
|
||||
XServerGrabber()
|
||||
{
|
||||
grabXServer();
|
||||
}
|
||||
~XServerGrabber()
|
||||
{
|
||||
ungrabXServer();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue