You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB
Plaintext

/* Qt 6 compatibility layer for the legacy QX11Info API. */
#ifndef CUTEFISH_QX11INFO_COMPAT
#define CUTEFISH_QX11INFO_COMPAT
#include <QGuiApplication>
#include <QtGui/qguiapplication_platform.h>
#include <xcb/xcb.h>
class QX11Info
{
public:
static bool isPlatformX11()
{
return nativeInterface() != nullptr;
}
static xcb_connection_t *connection()
{
const auto native = nativeInterface();
return native ? native->connection() : nullptr;
}
static Display *display()
{
const auto native = nativeInterface();
return native ? native->display() : nullptr;
}
static xcb_window_t appRootWindow()
{
xcb_connection_t *c = connection();
if (!c)
return XCB_WINDOW_NONE;
const xcb_setup_t *setup = xcb_get_setup(c);
const xcb_screen_iterator_t iterator = xcb_setup_roots_iterator(setup);
return iterator.data ? iterator.data->root : XCB_WINDOW_NONE;
}
private:
static QNativeInterface::QX11Application *nativeInterface()
{
return qGuiApp ? qGuiApp->nativeInterface<QNativeInterface::QX11Application>() : nullptr;
}
};
#endif