mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
Fix X11 xcb integration in Qt6.
This commit is contained in:
parent
f4efa66417
commit
f403472a8c
@ -77,7 +77,9 @@ endif()
|
|||||||
if (UNIX AND NOT APPLE AND NOT NO_X11)
|
if (UNIX AND NOT APPLE AND NOT NO_X11)
|
||||||
add_definitions(-DQZ_WS_X11)
|
add_definitions(-DQZ_WS_X11)
|
||||||
find_package(XCB REQUIRED COMPONENTS XCB UTIL)
|
find_package(XCB REQUIRED COMPONENTS XCB UTIL)
|
||||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras)
|
if (NOT (QT_MAJOR_VERSION STREQUAL "6"))
|
||||||
|
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_definitions(-DW7API)
|
add_definitions(-DW7API)
|
||||||
|
@ -620,7 +620,10 @@ endif()
|
|||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
if (NOT NO_X11)
|
if (NOT NO_X11)
|
||||||
target_link_libraries(FalkonPrivate XCB::XCB Qt::X11Extras)
|
target_link_libraries(FalkonPrivate XCB::XCB)
|
||||||
|
if (NOT (QT_MAJOR_VERSION STREQUAL "6"))
|
||||||
|
target_link_libraries(FalkonPrivate Qt::X11Extras)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(FalkonPrivate PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "3")
|
set_target_properties(FalkonPrivate PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "3")
|
||||||
|
@ -82,7 +82,9 @@
|
|||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <xcb/xcb_atom.h>
|
#include <xcb/xcb_atom.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1569,11 +1571,27 @@ void BrowserWindow::closeTab()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
|
static xcb_connection_t *getXcbConnection()
|
||||||
|
{
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
return QX11Info::connection();
|
||||||
|
#else
|
||||||
|
const QNativeInterface::QX11Application *x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
if (x11App == nullptr)
|
||||||
|
return 0;
|
||||||
|
return x11App->connection();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int BrowserWindow::getCurrentVirtualDesktop() const
|
int BrowserWindow::getCurrentVirtualDesktop() const
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName() != QL1S("xcb"))
|
if (QGuiApplication::platformName() != QL1S("xcb"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
xcb_connection_t *connection = getXcbConnection();
|
||||||
|
if (connection == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
xcb_intern_atom_cookie_t intern_atom;
|
xcb_intern_atom_cookie_t intern_atom;
|
||||||
xcb_intern_atom_reply_t *atom_reply = 0;
|
xcb_intern_atom_reply_t *atom_reply = 0;
|
||||||
xcb_atom_t atom;
|
xcb_atom_t atom;
|
||||||
@ -1581,16 +1599,16 @@ int BrowserWindow::getCurrentVirtualDesktop() const
|
|||||||
xcb_get_property_reply_t *reply = 0;
|
xcb_get_property_reply_t *reply = 0;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
|
||||||
intern_atom = xcb_intern_atom(QX11Info::connection(), false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
intern_atom = xcb_intern_atom(connection, false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
||||||
atom_reply = xcb_intern_atom_reply(QX11Info::connection(), intern_atom, 0);
|
atom_reply = xcb_intern_atom_reply(connection, intern_atom, 0);
|
||||||
|
|
||||||
if (!atom_reply)
|
if (!atom_reply)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
atom = atom_reply->atom;
|
atom = atom_reply->atom;
|
||||||
|
|
||||||
cookie = xcb_get_property(QX11Info::connection(), false, winId(), atom, XCB_ATOM_CARDINAL, 0, 1);
|
cookie = xcb_get_property(connection, false, winId(), atom, XCB_ATOM_CARDINAL, 0, 1);
|
||||||
reply = xcb_get_property_reply(QX11Info::connection(), cookie, 0);
|
reply = xcb_get_property_reply(connection, cookie, 0);
|
||||||
|
|
||||||
if (!reply || reply->type != XCB_ATOM_CARDINAL || reply->value_len != 1 || reply->format != sizeof(uint32_t) * 8)
|
if (!reply || reply->type != XCB_ATOM_CARDINAL || reply->value_len != 1 || reply->format != sizeof(uint32_t) * 8)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1616,19 +1634,23 @@ void BrowserWindow::moveToVirtualDesktop(int desktopId)
|
|||||||
if (desktopId < 0 || isVisible() || m_windowType == Qz::BW_FirstAppWindow)
|
if (desktopId < 0 || isVisible() || m_windowType == Qz::BW_FirstAppWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
xcb_connection_t *connection = getXcbConnection();
|
||||||
|
if (connection == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
xcb_intern_atom_cookie_t intern_atom;
|
xcb_intern_atom_cookie_t intern_atom;
|
||||||
xcb_intern_atom_reply_t *atom_reply = 0;
|
xcb_intern_atom_reply_t *atom_reply = 0;
|
||||||
xcb_atom_t atom;
|
xcb_atom_t atom;
|
||||||
|
|
||||||
intern_atom = xcb_intern_atom(QX11Info::connection(), false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
intern_atom = xcb_intern_atom(connection, false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
||||||
atom_reply = xcb_intern_atom_reply(QX11Info::connection(), intern_atom, 0);
|
atom_reply = xcb_intern_atom_reply(connection, intern_atom, 0);
|
||||||
|
|
||||||
if (!atom_reply)
|
if (!atom_reply)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
atom = atom_reply->atom;
|
atom = atom_reply->atom;
|
||||||
|
|
||||||
xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, winId(), atom,
|
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, winId(), atom,
|
||||||
XCB_ATOM_CARDINAL, 32, 1, (const void*) &desktopId);
|
XCB_ATOM_CARDINAL, 32, 1, (const void*) &desktopId);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -49,7 +49,9 @@
|
|||||||
#include <QtGuiVersion>
|
#include <QtGuiVersion>
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -867,12 +869,30 @@ bool QzTools::startExternalProcess(const QString &executable, const QString &arg
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QZ_WS_X11
|
||||||
|
static xcb_connection_t *getXcbConnection()
|
||||||
|
{
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
return QX11Info::connection();
|
||||||
|
#else
|
||||||
|
const QNativeInterface::QX11Application *x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
if (x11App == nullptr)
|
||||||
|
return 0;
|
||||||
|
return x11App->connection();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
||||||
{
|
{
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
if (QGuiApplication::platformName() != QL1S("xcb"))
|
if (QGuiApplication::platformName() != QL1S("xcb"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
xcb_connection_t *connection = getXcbConnection();
|
||||||
|
if (connection == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
const QByteArray nameData = name.toUtf8();
|
const QByteArray nameData = name.toUtf8();
|
||||||
const QByteArray classData = mApp->wmClass().isEmpty() ? QByteArrayLiteral("Falkon") : mApp->wmClass();
|
const QByteArray classData = mApp->wmClass().isEmpty() ? QByteArrayLiteral("Falkon") : mApp->wmClass();
|
||||||
|
|
||||||
@ -882,7 +902,7 @@ void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
|||||||
qstrcpy(class_hint, nameData.constData());
|
qstrcpy(class_hint, nameData.constData());
|
||||||
qstrcpy(class_hint + nameData.length() + 1, classData.constData());
|
qstrcpy(class_hint + nameData.length() + 1, classData.constData());
|
||||||
|
|
||||||
xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, widget->winId(),
|
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, widget->winId(),
|
||||||
XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 8, class_len, class_hint);
|
XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 8, class_len, class_hint);
|
||||||
|
|
||||||
free(class_hint);
|
free(class_hint);
|
||||||
|
Loading…
Reference in New Issue
Block a user