Skip to content

Commit

Permalink
feat: adapt to QXcbAtom's enum changed for qt6.6
Browse files Browse the repository at this point in the history
  QXcbAtom::XXX has changed to QXcbAtom::AtomXXX
  • Loading branch information
18202781743 committed Nov 6, 2023
1 parent 39f39a4 commit 355ee6b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 59 deletions.
26 changes: 13 additions & 13 deletions xcb/dforeignplatformwindow_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ QRect DForeignPlatformWindow::geometry() const
QMargins DForeignPlatformWindow::frameMargins() const
{
if (m_dirtyFrameMargins) {
if (DXcbWMSupport::instance()->isSupportedByWM(atom(QXcbAtom::_NET_FRAME_EXTENTS))) {
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window, atom(QXcbAtom::_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4);
if (DXcbWMSupport::instance()->isSupportedByWM(atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_FRAME_EXTENTS)))) {
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window, atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_FRAME_EXTENTS)), XCB_ATOM_CARDINAL, 0, 4);
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, nullptr);

if (reply) {
Expand Down Expand Up @@ -190,20 +190,20 @@ void DForeignPlatformWindow::handlePropertyNotifyEvent(const xcb_property_notify

const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;

if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
if (event->atom == atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_STATE)) || event->atom == atom(QXcbAtom::D_QXCBATOM_WRAPPER(WM_STATE))) {
if (propertyDeleted)
return;

return updateWindowState();
} else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
} else if (event->atom == atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_FRAME_EXTENTS))) {
m_dirtyFrameMargins = true;
} else if (event->atom == atom(QXcbAtom::_NET_WM_WINDOW_TYPE)) {
} else if (event->atom == atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_WINDOW_TYPE))) {
return updateWindowTypes();
} else if (event->atom == Utility::internAtom("_NET_WM_DESKTOP")) {
return updateWmDesktop();
} else if (event->atom == QXcbAtom::_NET_WM_NAME) {
} else if (event->atom == QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_NAME)) {
return updateTitle();
} else if (event->atom == QXcbAtom::WM_CLASS) {
} else if (event->atom == QXcbAtom::D_QXCBATOM_WRAPPER(WM_CLASS)) {
return updateWmClass();
}
}
Expand Down Expand Up @@ -264,10 +264,10 @@ void DForeignPlatformWindow::updateTitle()
xcb_get_property_reply_t *wm_name =
xcb_get_property_reply(xcb_connection(),
xcb_get_property_unchecked(xcb_connection(), false, m_window,
atom(QXcbAtom::_NET_WM_NAME),
atom(QXcbAtom::UTF8_STRING), 0, 1024), NULL);
atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_NAME)),
atom(QXcbAtom::D_QXCBATOM_WRAPPER(UTF8_STRING)), 0, 1024), NULL);
if (wm_name && wm_name->format == 8
&& wm_name->type == atom(QXcbAtom::UTF8_STRING)) {
&& wm_name->type == atom(QXcbAtom::D_QXCBATOM_WRAPPER(UTF8_STRING))) {
const QString &title = QString::fromUtf8((const char *)xcb_get_property_value(wm_name), xcb_get_property_value_length(wm_name));

if (title != qt_window_private(window())->windowTitle) {
Expand Down Expand Up @@ -306,13 +306,13 @@ void DForeignPlatformWindow::updateWindowState()
{
Qt::WindowState newState = Qt::WindowNoState;
const xcb_get_property_cookie_t get_cookie =
xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE),
xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::D_QXCBATOM_WRAPPER(WM_STATE)),
XCB_ATOM_ANY, 0, 1024);

xcb_get_property_reply_t *reply =
xcb_get_property_reply(xcb_connection(), get_cookie, NULL);

if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::D_QXCBATOM_WRAPPER(WM_STATE))) {
const quint32 *data = (const quint32 *)xcb_get_property_value(reply);
if (reply->length != 0 && XCB_ICCCM_WM_STATE_ICONIC == data[0])
newState = Qt::WindowMinimized;
Expand Down Expand Up @@ -369,7 +369,7 @@ void DForeignPlatformWindow::updateWindowTypes()
void DForeignPlatformWindow::updateProcessId()
{
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window,
atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 0, 1);
atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_PID)), XCB_ATOM_CARDINAL, 0, 1);
QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply(
xcb_get_property_reply(xcb_connection(), cookie, NULL));
if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 1) {
Expand Down
2 changes: 1 addition & 1 deletion xcb/dplatformbackingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ void DPlatformBackingStore::handlePropertyNotifyEvent(const xcb_property_notify_
}

if (event->window == window->xcb_window()
&& event->atom == window->atom(QXcbAtom::_NET_WM_STATE)) {
&& event->atom == window->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_STATE))) {
QXcbWindow::NetWmStates states = window->netWmStates();

ww->setProperty(netWmStates, (int)states);
Expand Down
14 changes: 7 additions & 7 deletions xcb/dplatformintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,25 +980,25 @@ static void startDrag(QXcbDrag *drag)
const Qt::DropActions actions = drag->currentDrag()->supportedActions();

if (actions.testFlag(Qt::CopyAction))
support_actions << drag->atom(QXcbAtom::XdndActionCopy);
support_actions << drag->atom(QXcbAtom::D_QXCBATOM_WRAPPER(XdndActionCopy));

if (actions.testFlag(Qt::MoveAction))
support_actions << drag->atom(QXcbAtom::XdndActionMove);
support_actions << drag->atom(QXcbAtom::D_QXCBATOM_WRAPPER(XdndActionMove));

if (actions.testFlag(Qt::LinkAction))
support_actions << drag->atom(QXcbAtom::XdndActionLink);
support_actions << drag->atom(QXcbAtom::D_QXCBATOM_WRAPPER(XdndActionLink));

// 此处不能直接 return ,因为一个拖拽包含多种 actions 后再次拖拽单一 action 时需要将 property 更新, 否则单一 actoin 的拖拽会被强行改成
// 上一次的 actions, 导致某些小问题 (比如文管的拖拽行为不一致的问题)
// if (support_actions.size() < 2)
// return;
#if QT_VERSION <= QT_VERSION_CHECK(6, 2, 4)
xcb_change_property(drag->xcb_connection(), XCB_PROP_MODE_REPLACE, drag->connection()->clipboard()->m_owner,
drag->atom(QXcbAtom::XdndActionList), XCB_ATOM_ATOM, sizeof(xcb_atom_t) * 8,
drag->atom(QXcbAtom::D_QXCBATOM_WRAPPER(XdndActionList)), XCB_ATOM_ATOM, sizeof(xcb_atom_t) * 8,
support_actions.size(), support_actions.constData());
#else
xcb_change_property(drag->xcb_connection(), XCB_PROP_MODE_REPLACE, drag->connection()->clipboard()->m_requestor, //TODO: m_ower deleted, replaced by m_requestor ?
drag->atom(QXcbAtom::XdndActionList), XCB_ATOM_ATOM, sizeof(xcb_atom_t) * 8,
drag->atom(QXcbAtom::D_QXCBATOM_WRAPPER(XdndActionList)), XCB_ATOM_ATOM, sizeof(xcb_atom_t) * 8,
support_actions.size(), support_actions.constData());
#endif
xcb_flush(drag->xcb_connection());
Expand Down Expand Up @@ -1233,15 +1233,15 @@ void DPlatformIntegration::sendEndStartupNotifition()
xcb_client_message_event_t ev;
ev.response_type = XCB_CLIENT_MESSAGE;
ev.format = 8;
ev.type = xcbConnection()->atom(QXcbAtom::_NET_STARTUP_INFO_BEGIN);
ev.type = xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_STARTUP_INFO_BEGIN));
ev.sequence = 0;
ev.window = xcbConnection()->rootWindow();
int sent = 0;
int length = message.length() + 1; // include NUL byte
const char *data = message.constData();
do {
if (sent == 20)
ev.type = xcbConnection()->atom(QXcbAtom::_NET_STARTUP_INFO);
ev.type = xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_STARTUP_INFO));

const int start = sent;
const int numBytes = qMin(length - start, 20);
Expand Down
2 changes: 1 addition & 1 deletion xcb/dplatformwindowhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void DPlatformWindowHelper::setVisible(bool visible)
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 1)
window->setNetWmStates(window->netWmStates() | QNativeWindow::NetWmStateModal);
#else
window->setNetWmState(true, window->atom(QXcbAtom::_NET_WM_STATE_MODAL));
window->setNetWmState(true, window->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_STATE_MODAL)));
#endif
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions xcb/dxcbwmsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void DXcbWMSupport::updateWMName(bool emitSignal)
xcb_get_property_reply_t *reply =
xcb_get_property_reply(xcb_connection,
xcb_get_property_unchecked(xcb_connection, false, root,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_SUPPORTING_WM_CHECK)),
XCB_ATOM_WINDOW, 0, 1024), NULL);

if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) {
Expand All @@ -64,10 +64,10 @@ void DXcbWMSupport::updateWMName(bool emitSignal)
xcb_get_property_reply_t *windowManagerReply =
xcb_get_property_reply(xcb_connection,
xcb_get_property_unchecked(xcb_connection, false, windowManager,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_NET_WM_NAME),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::UTF8_STRING), 0, 1024), NULL);
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_NAME)),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(UTF8_STRING)), 0, 1024), NULL);
if (windowManagerReply && windowManagerReply->format == 8
&& windowManagerReply->type == DPlatformIntegration::xcbConnection()->atom(QXcbAtom::UTF8_STRING)) {
&& windowManagerReply->type == DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(UTF8_STRING))) {
m_wmName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply));
}

Expand Down Expand Up @@ -98,7 +98,7 @@ void DXcbWMSupport::updateNetWMAtoms()

do {
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection, false, root,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_NET_SUPPORTED),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_SUPPORTED)),
XCB_ATOM_ATOM, offset, 1024);
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection, cookie, NULL);
if (!reply)
Expand Down Expand Up @@ -191,7 +191,7 @@ void DXcbWMSupport::updateHasComposite()
DPlatformIntegration::xcbConnection()->primaryVirtualDesktop()->m_compositingActive = hasComposite;
} else {
//stage2: fallback to check selection owner
xcb_get_selection_owner_cookie_t cookit = xcb_get_selection_owner(xcb_connection, DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_NET_WM_CM_S0));
xcb_get_selection_owner_cookie_t cookit = xcb_get_selection_owner(xcb_connection, DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_CM_S0)));
xcb_get_selection_owner_reply_t *reply = xcb_get_selection_owner_reply(xcb_connection, cookit, NULL);
if (!reply)
return;
Expand Down
6 changes: 6 additions & 0 deletions xcb/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ QT_END_NAMESPACE
typedef uint32_t xcb_atom_t;
typedef struct xcb_connection_t xcb_connection_t;

#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
#define D_QXCBATOM_WRAPPER(AtomEnum) Atom##AtomEnum
#else
#define D_QXCBATOM_WRAPPER(AtomEnum) AtomEnum
#endif

DPP_BEGIN_NAMESPACE

class Utility
Expand Down
26 changes: 13 additions & 13 deletions xcb/utility_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,13 @@ Utility::QtMotifWmHints Utility::getMotifWmHints(quint32 WId)
QtMotifWmHints hints;

xcb_get_property_cookie_t get_cookie =
xcb_get_property_unchecked(xcb_connect, 0, WId, DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20);
xcb_get_property_unchecked(xcb_connect, 0, WId, DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)), 0, 20);

xcb_get_property_reply_t *reply =
xcb_get_property_reply(xcb_connect, get_cookie, NULL);

if (reply && reply->format == 32 && reply->type == DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS)) {
if (reply && reply->format == 32 && reply->type == DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS))) {
hints = *((QtMotifWmHints *)xcb_get_property_value(reply));
} else {
hints.flags = 0L;
Expand Down Expand Up @@ -733,29 +733,29 @@ void Utility::setMotifWmHints(quint32 WId, Utility::QtMotifWmHints hints)
Q_XCB_CALL2(xcb_change_property(DPlatformIntegration::xcbConnection()->xcb_connection(),
XCB_PROP_MODE_REPLACE,
WId,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)),
32,
5,
&hints), c);
#else
xcb_change_property(DPlatformIntegration::xcbConnection()->xcb_connection(),
XCB_PROP_MODE_REPLACE,
WId,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)),
32,
5,
&hints);
#endif
} else {
#ifdef Q_XCB_CALL2
Q_XCB_CALL2(xcb_delete_property(DPlatformIntegration::xcbConnection()->xcb_connection(), WId,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS)),
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS))),
DPlatformIntegration::xcbConnection()->xcb_connection());
#else
xcb_delete_property(DPlatformIntegration::xcbConnection()->xcb_connection(), WId,
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::_MOTIF_WM_HINTS));
DPlatformIntegration::xcbConnection()->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_MOTIF_WM_HINTS)));
#endif
}
}
Expand Down Expand Up @@ -860,16 +860,16 @@ quint32 Utility::createGroupWindow()
xcb_change_property(connection->xcb_connection(),
XCB_PROP_MODE_REPLACE,
group_leader,
connection->atom(QXcbAtom::_NET_WM_NAME),
connection->atom(QXcbAtom::UTF8_STRING),
connection->atom(QXcbAtom::D_QXCBATOM_WRAPPER(_NET_WM_NAME)),
connection->atom(QXcbAtom::D_QXCBATOM_WRAPPER(UTF8_STRING)),
8,
ba.length(),
ba.constData());
//#endif
xcb_change_property(connection->xcb_connection(),
XCB_PROP_MODE_REPLACE,
group_leader,
connection->atom(QXcbAtom::WM_CLIENT_LEADER),
connection->atom(QXcbAtom::D_QXCBATOM_WRAPPER(WM_CLIENT_LEADER)),
XCB_ATOM_WINDOW,
32,
1,
Expand All @@ -882,7 +882,7 @@ quint32 Utility::createGroupWindow()
xcb_change_property(connection->xcb_connection(),
XCB_PROP_MODE_REPLACE,
group_leader,
connection->atom(QXcbAtom::SM_CLIENT_ID),
connection->atom(QXcbAtom::D_QXCBATOM_WRAPPER(SM_CLIENT_ID)),
XCB_ATOM_STRING,
8,
session.length(),
Expand Down
Loading

0 comments on commit 355ee6b

Please sign in to comment.