diff options
Diffstat (limited to 'src/plugins/platforms/xcb')
23 files changed, 631 insertions, 546 deletions
diff --git a/src/plugins/platforms/xcb/CMakeLists.txt b/src/plugins/platforms/xcb/CMakeLists.txt index c73b2de73f..9ac281c407 100644 --- a/src/plugins/platforms/xcb/CMakeLists.txt +++ b/src/plugins/platforms/xcb/CMakeLists.txt @@ -83,6 +83,8 @@ qt_internal_extend_target(XcbQpaPrivate CONDITION QT_FEATURE_draganddrop ) qt_internal_extend_target(XcbQpaPrivate CONDITION QT_FEATURE_xcb_xlib + SOURCES + qt_xlib_wrapper.c qt_xlib_wrapper.h PUBLIC_LIBRARIES X11::XCB # special case begin @@ -97,7 +99,8 @@ qt_internal_extend_target(XcbQpaPrivate CONDITION QT_FEATURE_xcb_sm SOURCES qxcbsessionmanager.cpp qxcbsessionmanager.h PUBLIC_LIBRARIES - ${X11_SM_LIB} ${X11_ICE_LIB} + X11::SM + X11::ICE ) qt_internal_extend_target(XcbQpaPrivate CONDITION QT_FEATURE_vulkan diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 5992ebd74e..04eac027cd 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -242,9 +242,9 @@ QGLXContext::QGLXContext(Display *display, QXcbScreen *screen, const QSurfaceFor // Robustness must match that of the shared context. if (share && share->format().testOption(QSurfaceFormat::ResetNotification)) m_format.setOption(QSurfaceFormat::ResetNotification); - Q_ASSERT(glVersions.count() > 0); + Q_ASSERT(glVersions.size() > 0); - for (int i = 0; !m_context && i < glVersions.count(); i++) { + for (int i = 0; !m_context && i < glVersions.size(); i++) { const int version = glVersions[i]; if (version > requestedVersion) continue; @@ -395,14 +395,19 @@ QGLXContext::QGLXContext(Display *display, GLXContext context, void *visualInfo, int numConfigs = 0; static const int attribs[] = { GLX_FBCONFIG_ID, configId, None }; configs = glXChooseFBConfig(m_display, screenNumber, attribs, &numConfigs); - if (!configs || numConfigs < 1) { + if (!configs) { + qWarning("QGLXContext: Failed to find config(invalid arguments for glXChooseFBConfig)"); + return; + } else if (numConfigs < 1) { qWarning("QGLXContext: Failed to find config"); + XFree(configs); return; } if (configs && numConfigs > 1) // this is suspicious so warn but let it continue qWarning("QGLXContext: Multiple configs for FBConfig ID %d", configId); m_config = configs[0]; + XFree(configs); } Q_ASSERT(vinfo || m_config); diff --git a/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp index ecc21eb1f5..7b0094044b 100644 --- a/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp @@ -5,6 +5,7 @@ #include <QRect> #include <QList> +#include <QMap> #include <QDebug> #include <qmath.h> diff --git a/src/plugins/platforms/xcb/qt_xlib_wrapper.c b/src/plugins/platforms/xcb/qt_xlib_wrapper.c new file mode 100644 index 0000000000..f4614e5504 --- /dev/null +++ b/src/plugins/platforms/xcb/qt_xlib_wrapper.c @@ -0,0 +1,7 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#include "qt_xlib_wrapper.h" + +#include <X11/Xlib.h> + +void qt_XFlush(Display *dpy) { XFlush(dpy); } diff --git a/src/plugins/platforms/xcb/qt_xlib_wrapper.h b/src/plugins/platforms/xcb/qt_xlib_wrapper.h new file mode 100644 index 0000000000..642dbdeadd --- /dev/null +++ b/src/plugins/platforms/xcb/qt_xlib_wrapper.h @@ -0,0 +1,17 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QT_XLIB_WRAPPER_H +#define QT_XLIB_WRAPPER_H + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _XDisplay Display; + void qt_XFlush(Display *dpy); + +#ifdef __cplusplus +} +#endif + +#endif // QT_XLIB_WRAPPER_H diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp index 8f984c7280..6cb6d29de2 100644 --- a/src/plugins/platforms/xcb/qxcbatom.cpp +++ b/src/plugins/platforms/xcb/qxcbatom.cpp @@ -54,6 +54,8 @@ static const char *xcb_atomnames = { "_QT_CLOSE_CONNECTION\0" + "_QT_GET_TIMESTAMP\0" + "_MOTIF_WM_HINTS\0" "DTWM_IS_RUNNING\0" @@ -114,6 +116,7 @@ static const char *xcb_atomnames = { "_NET_STARTUP_INFO\0" "_NET_STARTUP_INFO_BEGIN\0" + "_NET_STARTUP_ID\0" "_NET_SUPPORTING_WM_CHECK\0" diff --git a/src/plugins/platforms/xcb/qxcbatom.h b/src/plugins/platforms/xcb/qxcbatom.h index 48924dd626..07dad31d45 100644 --- a/src/plugins/platforms/xcb/qxcbatom.h +++ b/src/plugins/platforms/xcb/qxcbatom.h @@ -10,201 +10,204 @@ class QXcbAtom public: enum Atom { // window-manager <-> client protocols - WM_PROTOCOLS, - WM_DELETE_WINDOW, - WM_TAKE_FOCUS, - _NET_WM_PING, - _NET_WM_CONTEXT_HELP, - _NET_WM_SYNC_REQUEST, - _NET_WM_SYNC_REQUEST_COUNTER, - MANAGER, // System tray notification - _NET_SYSTEM_TRAY_OPCODE, // System tray operation + AtomWM_PROTOCOLS, + AtomWM_DELETE_WINDOW, + AtomWM_TAKE_FOCUS, + Atom_NET_WM_PING, + Atom_NET_WM_CONTEXT_HELP, + Atom_NET_WM_SYNC_REQUEST, + Atom_NET_WM_SYNC_REQUEST_COUNTER, + AtomMANAGER, // System tray notification + Atom_NET_SYSTEM_TRAY_OPCODE, // System tray operation // ICCCM window state - WM_STATE, - WM_CHANGE_STATE, - WM_CLASS, - WM_NAME, + AtomWM_STATE, + AtomWM_CHANGE_STATE, + AtomWM_CLASS, + AtomWM_NAME, // Session management - WM_CLIENT_LEADER, - WM_WINDOW_ROLE, - SM_CLIENT_ID, - WM_CLIENT_MACHINE, + AtomWM_CLIENT_LEADER, + AtomWM_WINDOW_ROLE, + AtomSM_CLIENT_ID, + AtomWM_CLIENT_MACHINE, // Clipboard - CLIPBOARD, - INCR, - TARGETS, - MULTIPLE, - TIMESTAMP, - SAVE_TARGETS, - CLIP_TEMPORARY, - _QT_SELECTION, - _QT_CLIPBOARD_SENTINEL, - _QT_SELECTION_SENTINEL, - CLIPBOARD_MANAGER, + AtomCLIPBOARD, + AtomINCR, + AtomTARGETS, + AtomMULTIPLE, + AtomTIMESTAMP, + AtomSAVE_TARGETS, + AtomCLIP_TEMPORARY, + Atom_QT_SELECTION, + Atom_QT_CLIPBOARD_SENTINEL, + Atom_QT_SELECTION_SENTINEL, + AtomCLIPBOARD_MANAGER, - RESOURCE_MANAGER, + AtomRESOURCE_MANAGER, - _XSETROOT_ID, + Atom_XSETROOT_ID, - _QT_SCROLL_DONE, - _QT_INPUT_ENCODING, + Atom_QT_SCROLL_DONE, + Atom_QT_INPUT_ENCODING, // Qt/XCB specific - _QT_CLOSE_CONNECTION, + Atom_QT_CLOSE_CONNECTION, - _MOTIF_WM_HINTS, + Atom_QT_GET_TIMESTAMP, - DTWM_IS_RUNNING, - ENLIGHTENMENT_DESKTOP, - _DT_SAVE_MODE, - _SGI_DESKS_MANAGER, + Atom_MOTIF_WM_HINTS, + + AtomDTWM_IS_RUNNING, + AtomENLIGHTENMENT_DESKTOP, + Atom_DT_SAVE_MODE, + Atom_SGI_DESKS_MANAGER, // EWMH (aka NETWM) - _NET_SUPPORTED, - _NET_VIRTUAL_ROOTS, - _NET_WORKAREA, - - _NET_MOVERESIZE_WINDOW, - _NET_WM_MOVERESIZE, - - _NET_WM_NAME, - _NET_WM_ICON_NAME, - _NET_WM_ICON, - - _NET_WM_PID, - - _NET_WM_WINDOW_OPACITY, - - _NET_WM_STATE, - _NET_WM_STATE_ABOVE, - _NET_WM_STATE_BELOW, - _NET_WM_STATE_FULLSCREEN, - _NET_WM_STATE_MAXIMIZED_HORZ, - _NET_WM_STATE_MAXIMIZED_VERT, - _NET_WM_STATE_MODAL, - _NET_WM_STATE_STAYS_ON_TOP, - _NET_WM_STATE_DEMANDS_ATTENTION, - _NET_WM_STATE_HIDDEN, - - _NET_WM_USER_TIME, - _NET_WM_USER_TIME_WINDOW, - _NET_WM_FULL_PLACEMENT, - - _NET_WM_WINDOW_TYPE, - _NET_WM_WINDOW_TYPE_DESKTOP, - _NET_WM_WINDOW_TYPE_DOCK, - _NET_WM_WINDOW_TYPE_TOOLBAR, - _NET_WM_WINDOW_TYPE_MENU, - _NET_WM_WINDOW_TYPE_UTILITY, - _NET_WM_WINDOW_TYPE_SPLASH, - _NET_WM_WINDOW_TYPE_DIALOG, - _NET_WM_WINDOW_TYPE_DROPDOWN_MENU, - _NET_WM_WINDOW_TYPE_POPUP_MENU, - _NET_WM_WINDOW_TYPE_TOOLTIP, - _NET_WM_WINDOW_TYPE_NOTIFICATION, - _NET_WM_WINDOW_TYPE_COMBO, - _NET_WM_WINDOW_TYPE_DND, - _NET_WM_WINDOW_TYPE_NORMAL, - _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, - - _KDE_NET_WM_FRAME_STRUT, - _NET_FRAME_EXTENTS, - - _NET_STARTUP_INFO, - _NET_STARTUP_INFO_BEGIN, - - _NET_SUPPORTING_WM_CHECK, - - _NET_WM_CM_S0, - - _NET_SYSTEM_TRAY_VISUAL, - - _NET_ACTIVE_WINDOW, + Atom_NET_SUPPORTED, + Atom_NET_VIRTUAL_ROOTS, + Atom_NET_WORKAREA, + + Atom_NET_MOVERESIZE_WINDOW, + Atom_NET_WM_MOVERESIZE, + + Atom_NET_WM_NAME, + Atom_NET_WM_ICON_NAME, + Atom_NET_WM_ICON, + + Atom_NET_WM_PID, + + Atom_NET_WM_WINDOW_OPACITY, + + Atom_NET_WM_STATE, + Atom_NET_WM_STATE_ABOVE, + Atom_NET_WM_STATE_BELOW, + Atom_NET_WM_STATE_FULLSCREEN, + Atom_NET_WM_STATE_MAXIMIZED_HORZ, + Atom_NET_WM_STATE_MAXIMIZED_VERT, + Atom_NET_WM_STATE_MODAL, + Atom_NET_WM_STATE_STAYS_ON_TOP, + Atom_NET_WM_STATE_DEMANDS_ATTENTION, + Atom_NET_WM_STATE_HIDDEN, + + Atom_NET_WM_USER_TIME, + Atom_NET_WM_USER_TIME_WINDOW, + Atom_NET_WM_FULL_PLACEMENT, + + Atom_NET_WM_WINDOW_TYPE, + Atom_NET_WM_WINDOW_TYPE_DESKTOP, + Atom_NET_WM_WINDOW_TYPE_DOCK, + Atom_NET_WM_WINDOW_TYPE_TOOLBAR, + Atom_NET_WM_WINDOW_TYPE_MENU, + Atom_NET_WM_WINDOW_TYPE_UTILITY, + Atom_NET_WM_WINDOW_TYPE_SPLASH, + Atom_NET_WM_WINDOW_TYPE_DIALOG, + Atom_NET_WM_WINDOW_TYPE_DROPDOWN_MENU, + Atom_NET_WM_WINDOW_TYPE_POPUP_MENU, + Atom_NET_WM_WINDOW_TYPE_TOOLTIP, + Atom_NET_WM_WINDOW_TYPE_NOTIFICATION, + Atom_NET_WM_WINDOW_TYPE_COMBO, + Atom_NET_WM_WINDOW_TYPE_DND, + Atom_NET_WM_WINDOW_TYPE_NORMAL, + Atom_KDE_NET_WM_WINDOW_TYPE_OVERRIDE, + + Atom_KDE_NET_WM_FRAME_STRUT, + Atom_NET_FRAME_EXTENTS, + + Atom_NET_STARTUP_INFO, + Atom_NET_STARTUP_INFO_BEGIN, + Atom_NET_STARTUP_ID, + + Atom_NET_SUPPORTING_WM_CHECK, + + Atom_NET_WM_CM_S0, + + Atom_NET_SYSTEM_TRAY_VISUAL, + + Atom_NET_ACTIVE_WINDOW, // Property formats - TEXT, - UTF8_STRING, - CARDINAL, + AtomTEXT, + AtomUTF8_STRING, + AtomCARDINAL, // Xdnd - XdndEnter, - XdndPosition, - XdndStatus, - XdndLeave, - XdndDrop, - XdndFinished, - XdndTypelist, - XdndActionList, - - XdndSelection, - - XdndAware, - XdndProxy, - - XdndActionCopy, - XdndActionLink, - XdndActionMove, - XdndActionAsk, - XdndActionPrivate, + AtomXdndEnter, + AtomXdndPosition, + AtomXdndStatus, + AtomXdndLeave, + AtomXdndDrop, + AtomXdndFinished, + AtomXdndTypelist, + AtomXdndActionList, + + AtomXdndSelection, + + AtomXdndAware, + AtomXdndProxy, + + AtomXdndActionCopy, + AtomXdndActionLink, + AtomXdndActionMove, + AtomXdndActionAsk, + AtomXdndActionPrivate, // Xkb - _XKB_RULES_NAMES, + Atom_XKB_RULES_NAMES, // XEMBED - _XEMBED, - _XEMBED_INFO, + Atom_XEMBED, + Atom_XEMBED_INFO, // XInput2 - ButtonLeft, - ButtonMiddle, - ButtonRight, - ButtonWheelUp, - ButtonWheelDown, - ButtonHorizWheelLeft, - ButtonHorizWheelRight, - AbsMTPositionX, - AbsMTPositionY, - AbsMTTouchMajor, - AbsMTTouchMinor, - AbsMTOrientation, - AbsMTPressure, - AbsMTTrackingID, - MaxContacts, - RelX, - RelY, + AtomButtonLeft, + AtomButtonMiddle, + AtomButtonRight, + AtomButtonWheelUp, + AtomButtonWheelDown, + AtomButtonHorizWheelLeft, + AtomButtonHorizWheelRight, + AtomAbsMTPositionX, + AtomAbsMTPositionY, + AtomAbsMTTouchMajor, + AtomAbsMTTouchMinor, + AtomAbsMTOrientation, + AtomAbsMTPressure, + AtomAbsMTTrackingID, + AtomMaxContacts, + AtomRelX, + AtomRelY, // XInput2 tablet - AbsX, - AbsY, - AbsPressure, - AbsTiltX, - AbsTiltY, - AbsWheel, - AbsDistance, - WacomSerialIDs, - INTEGER, - RelHorizWheel, - RelVertWheel, - RelHorizScroll, - RelVertScroll, - - _XSETTINGS_SETTINGS, - - _COMPIZ_DECOR_PENDING, - _COMPIZ_DECOR_REQUEST, - _COMPIZ_DECOR_DELETE_PIXMAP, - _COMPIZ_TOOLKIT_ACTION, - _GTK_LOAD_ICONTHEMES, - - AT_SPI_BUS, - - EDID, - EDID_DATA, - XFree86_DDC_EDID1_RAWDATA, - - _ICC_PROFILE, + AtomAbsX, + AtomAbsY, + AtomAbsPressure, + AtomAbsTiltX, + AtomAbsTiltY, + AtomAbsWheel, + AtomAbsDistance, + AtomWacomSerialIDs, + AtomINTEGER, + AtomRelHorizWheel, + AtomRelVertWheel, + AtomRelHorizScroll, + AtomRelVertScroll, + + Atom_XSETTINGS_SETTINGS, + + Atom_COMPIZ_DECOR_PENDING, + Atom_COMPIZ_DECOR_REQUEST, + Atom_COMPIZ_DECOR_DELETE_PIXMAP, + Atom_COMPIZ_TOOLKIT_ACTION, + Atom_GTK_LOAD_ICONTHEMES, + + AtomAT_SPI_BUS, + + AtomEDID, + AtomEDID_DATA, + AtomXFree86_DDC_EDID1_RAWDATA, + + Atom_ICC_PROFILE, NAtoms }; diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 6c15d7c142..0de0db2a58 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -31,7 +31,7 @@ public: break; case QClipboard::Clipboard: - modeAtom = m_clipboard->atom(QXcbAtom::CLIPBOARD); + modeAtom = m_clipboard->atom(QXcbAtom::AtomCLIPBOARD); break; default: @@ -56,12 +56,12 @@ protected: if (isEmpty()) return QStringList(); - if (!formatList.count()) { + if (!formatList.size()) { QXcbClipboardMime *that = const_cast<QXcbClipboardMime *>(this); // get the list of targets from the current clipboard owner - we do this // once so that multiple calls to this function don't require multiple // server round trips... - that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::TARGETS)); + that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::AtomTARGETS)); if (format_atoms.size() > 0) { const xcb_atom_t *targets = (const xcb_atom_t *) format_atoms.data(); @@ -203,7 +203,7 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) xcb_xfixes_select_selection_input_checked(xcb_connection(), connection()->qtSelectionOwner(), XCB_ATOM_PRIMARY, mask); xcb_xfixes_select_selection_input_checked(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::CLIPBOARD), mask); + atom(QXcbAtom::AtomCLIPBOARD), mask); } // xcb_change_property_request_t and xcb_get_property_request_t are the same size @@ -218,13 +218,13 @@ QXcbClipboard::~QXcbClipboard() m_timestamp[QClipboard::Selection] != XCB_CURRENT_TIME) { // First we check if there is a clipboard manager. - if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) != XCB_NONE) { + if (connection()->selectionOwner(atom(QXcbAtom::AtomCLIPBOARD_MANAGER)) != XCB_NONE) { // we delete the property so the manager saves all TARGETS. xcb_delete_property(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::_QT_SELECTION)); + atom(QXcbAtom::Atom_QT_SELECTION)); xcb_convert_selection(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::CLIPBOARD_MANAGER), atom(QXcbAtom::SAVE_TARGETS), - atom(QXcbAtom::_QT_SELECTION), connection()->time()); + atom(QXcbAtom::AtomCLIPBOARD_MANAGER), atom(QXcbAtom::AtomSAVE_TARGETS), + atom(QXcbAtom::Atom_QT_SELECTION), connection()->time()); connection()->sync(); // waiting until the clipboard manager fetches the content. @@ -259,7 +259,7 @@ bool QXcbClipboard::handlePropertyNotify(const xcb_generic_event_t *event) xcb_atom_t QXcbClipboard::atomForMode(QClipboard::Mode mode) const { if (mode == QClipboard::Clipboard) - return atom(QXcbAtom::CLIPBOARD); + return atom(QXcbAtom::AtomCLIPBOARD); if (mode == QClipboard::Selection) return XCB_ATOM_PRIMARY; return XCB_NONE; @@ -269,7 +269,7 @@ QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const { if (a == XCB_ATOM_PRIMARY) return QClipboard::Selection; - if (a == atom(QXcbAtom::CLIPBOARD)) + if (a == atom(QXcbAtom::AtomCLIPBOARD)) return QClipboard::Clipboard; // not supported enum value, used to detect errors return QClipboard::FindBuffer; @@ -412,10 +412,10 @@ xcb_atom_t QXcbClipboard::sendTargetsSelection(QMimeData *d, xcb_window_t window types.append(atoms.at(j)); } } - types.append(atom(QXcbAtom::TARGETS)); - types.append(atom(QXcbAtom::MULTIPLE)); - types.append(atom(QXcbAtom::TIMESTAMP)); - types.append(atom(QXcbAtom::SAVE_TARGETS)); + types.append(atom(QXcbAtom::AtomTARGETS)); + types.append(atom(QXcbAtom::AtomMULTIPLE)); + types.append(atom(QXcbAtom::AtomTIMESTAMP)); + types.append(atom(QXcbAtom::AtomSAVE_TARGETS)); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, XCB_ATOM_ATOM, 32, types.size(), (const void *)types.constData()); @@ -439,7 +439,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win // don't allow INCR transfers when using MULTIPLE or to // Motif clients (since Motif doesn't support INCR) - static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::CLIP_TEMPORARY); + static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::AtomCLIP_TEMPORARY); bool allow_incr = property != motif_clip_temporary; // This 'bool' can be removed once there is a proper fix for QTBUG-32853 if (m_clipboard_closing) @@ -448,7 +448,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win if (data.size() > m_maxPropertyRequestDataBytes && allow_incr) { long bytes = data.size(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, - atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes); + atom(QXcbAtom::AtomINCR), 32, 1, (const void *)&bytes); auto transaction = new QXcbClipboardTransaction(this, window, property, data, atomFormat, dataFormat); m_transactions.insert(window, transaction); return property; @@ -532,9 +532,9 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) return; } - xcb_atom_t targetsAtom = atom(QXcbAtom::TARGETS); - xcb_atom_t multipleAtom = atom(QXcbAtom::MULTIPLE); - xcb_atom_t timestampAtom = atom(QXcbAtom::TIMESTAMP); + xcb_atom_t targetsAtom = atom(QXcbAtom::AtomTARGETS); + xcb_atom_t multipleAtom = atom(QXcbAtom::AtomMULTIPLE); + xcb_atom_t timestampAtom = atom(QXcbAtom::AtomTIMESTAMP); struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = nullptr; xcb_atom_t multi_type = XCB_NONE; @@ -708,7 +708,7 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, // correct size, not 0-term. if (size) *size = buffer_offset; - if (*type == atom(QXcbAtom::INCR)) + if (*type == atom(QXcbAtom::AtomINCR)) m_incr_receive_time = connection()->getTimestamp(); if (deleteProperty) xcb_delete_property(xcb_connection(), win, property); @@ -747,12 +747,12 @@ xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t window, i const QXcbEventNode *flushedTailNode = queue->flushedTail(); if (checkManager) { - if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) == XCB_NONE) + if (connection()->selectionOwner(atom(QXcbAtom::AtomCLIPBOARD_MANAGER)) == XCB_NONE) return nullptr; } // process other clipboard events, since someone is probably requesting data from us - auto clipboardAtom = atom(QXcbAtom::CLIPBOARD); + auto clipboardAtom = atom(QXcbAtom::AtomCLIPBOARD); e = queue->peek([clipboardAtom](xcb_generic_event_t *event, int type) { xcb_atom_t selection = XCB_ATOM_NONE; if (type == XCB_SELECTION_REQUEST) @@ -846,7 +846,7 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAtom) { - return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::_QT_SELECTION)); + return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::Atom_QT_SELECTION)); } QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t time) @@ -870,7 +870,7 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t type; if (clipboardReadProperty(win, property, true, &buf, nullptr, &type, nullptr)) { - if (type == atom(QXcbAtom::INCR)) { + if (type == atom(QXcbAtom::AtomINCR)) { int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; buf = clipboardReadIncrementalProperty(win, property, nbytes, false); } diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 51530e0055..6f2cf087e0 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -35,6 +35,10 @@ #undef explicit #include <xcb/xinput.h> +#if QT_CONFIG(xcb_xlib) +#include "qt_xlib_wrapper.h" +#endif + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -81,8 +85,8 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_drag = new QXcbDrag(this); #endif - m_startupId = qgetenv("DESKTOP_STARTUP_ID"); - if (!m_startupId.isNull()) + setStartupId(qgetenv("DESKTOP_STARTUP_ID")); + if (!startupId().isNull()) qunsetenv("DESKTOP_STARTUP_ID"); const int focusInDelay = 100; @@ -598,12 +602,12 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) if (clientMessage->format != 32) return; #if QT_CONFIG(draganddrop) - if (clientMessage->type == atom(QXcbAtom::XdndStatus)) + if (clientMessage->type == atom(QXcbAtom::AtomXdndStatus)) drag()->handleStatus(clientMessage); - else if (clientMessage->type == atom(QXcbAtom::XdndFinished)) + else if (clientMessage->type == atom(QXcbAtom::AtomXdndFinished)) drag()->handleFinished(clientMessage); #endif - if (m_systemTrayTracker && clientMessage->type == atom(QXcbAtom::MANAGER)) + if (m_systemTrayTracker && clientMessage->type == atom(QXcbAtom::AtomMANAGER)) m_systemTrayTracker->notifyManagerClientMessageEvent(clientMessage); HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent); } @@ -654,7 +658,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) setTime(selectionRequest->time); #endif #if QT_CONFIG(draganddrop) - if (selectionRequest->selection == atom(QXcbAtom::XdndSelection)) + if (selectionRequest->selection == atom(QXcbAtom::AtomXdndSelection)) m_drag->handleSelectionRequest(selectionRequest); else #endif @@ -682,11 +686,11 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) if (m_clipboard->handlePropertyNotify(event)) break; #endif - if (propertyNotify->atom == atom(QXcbAtom::_NET_WORKAREA)) { + if (propertyNotify->atom == atom(QXcbAtom::Atom_NET_WORKAREA)) { QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window); if (virtualDesktop) virtualDesktop->updateWorkArea(); - } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) { + } else if (propertyNotify->atom == atom(QXcbAtom::Atom_NET_SUPPORTED)) { m_wmSupport->updateNetWMAtoms(); } else { HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent); @@ -713,7 +717,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) #ifndef QT_NO_CLIPBOARD m_clipboard->handleXFixesSelectionRequest(notify_event); #endif - for (QXcbVirtualDesktop *virtualDesktop : qAsConst(m_virtualDesktops)) + for (QXcbVirtualDesktop *virtualDesktop : std::as_const(m_virtualDesktops)) virtualDesktop->handleXFixesSelectionNotify(notify_event); } else if (isXRandrType(response_type, XCB_RANDR_NOTIFY)) { if (!isAtLeastXRandR15()) @@ -771,6 +775,28 @@ void QXcbConnection::setMousePressWindow(QXcbWindow *w) m_mousePressWindow = w; } +QByteArray QXcbConnection::startupId() const +{ + return m_startupId; +} +void QXcbConnection::setStartupId(const QByteArray &nextId) +{ + m_startupId = nextId; + if (m_clientLeader) { + if (!nextId.isEmpty()) + xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + clientLeader(), + atom(QXcbAtom::Atom_NET_STARTUP_ID), + atom(QXcbAtom::AtomUTF8_STRING), + 8, + nextId.size(), + nextId.constData()); + else + xcb_delete_property(xcb_connection(), clientLeader(), atom(QXcbAtom::Atom_NET_STARTUP_ID)); + } +} + void QXcbConnection::grabServer() { if (m_canGrabServer) @@ -796,8 +822,8 @@ xcb_timestamp_t QXcbConnection::getTimestamp() { // send a dummy event to myself to get the timestamp from X server. xcb_window_t window = rootWindow(); - xcb_atom_t dummyAtom = atom(QXcbAtom::CLIP_TEMPORARY); - xcb_change_property(xcb_connection(), XCB_PROP_MODE_APPEND, window, dummyAtom, + xcb_atom_t dummyAtom = atom(QXcbAtom::Atom_QT_GET_TIMESTAMP); + xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, dummyAtom, XCB_ATOM_INTEGER, 32, 0, nullptr); connection()->flush(); @@ -829,8 +855,6 @@ xcb_timestamp_t QXcbConnection::getTimestamp() xcb_timestamp_t timestamp = pn->time; free(event); - xcb_delete_property(xcb_connection(), window, dummyAtom); - return timestamp; } @@ -897,7 +921,7 @@ xcb_window_t QXcbConnection::clientLeader() xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_clientLeader, - atom(QXcbAtom::WM_CLIENT_LEADER), + atom(QXcbAtom::AtomWM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, 1, @@ -910,13 +934,15 @@ xcb_window_t QXcbConnection::clientLeader() xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_clientLeader, - atom(QXcbAtom::SM_CLIENT_ID), + atom(QXcbAtom::AtomSM_CLIENT_ID), XCB_ATOM_STRING, 8, - session.length(), + session.size(), session.constData()); } #endif + + setStartupId(startupId()); } return m_clientLeader; } @@ -1029,8 +1055,8 @@ bool QXcbConnection::isUserInputEvent(xcb_generic_event_t *event) const if (eventType == XCB_CLIENT_MESSAGE) { auto clientMessage = reinterpret_cast<const xcb_client_message_event_t *>(event); - if (clientMessage->format == 32 && clientMessage->type == atom(QXcbAtom::WM_PROTOCOLS)) - if (clientMessage->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) + if (clientMessage->format == 32 && clientMessage->type == atom(QXcbAtom::AtomWM_PROTOCOLS)) + if (clientMessage->data.data32[0] == atom(QXcbAtom::AtomWM_DELETE_WINDOW)) isInputEvent = true; } @@ -1066,6 +1092,10 @@ void QXcbConnection::processXcbEvents(QEventLoop::ProcessEventsFlags flags) m_eventQueue->flushBufferedEvents(); } +#if QT_CONFIG(xcb_xlib) + qt_XFlush(static_cast<Display *>(xlib_display())); +#endif + xcb_flush(xcb_connection()); } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 2d55524f6f..24e684866d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -170,9 +170,8 @@ public: QXcbWindow *mousePressWindow() const { return m_mousePressWindow; } void setMousePressWindow(QXcbWindow *); - QByteArray startupId() const { return m_startupId; } - void setStartupId(const QByteArray &nextId) { m_startupId = nextId; } - void clearStartupId() { m_startupId.clear(); } + QByteArray startupId() const; + void setStartupId(const QByteArray &nextId); void grabServer(); void ungrabServer(); diff --git a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp index aa0f2fef65..9e8117153c 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp @@ -155,7 +155,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) } } - qCDebug(lcQpaScreen) << "updateScreens: primary output is" << qAsConst(m_screens).first()->name(); + qCDebug(lcQpaScreen) << "updateScreens: primary output is" << std::as_const(m_screens).first()->name(); } } @@ -184,7 +184,7 @@ void QXcbConnection::updateScreen(QXcbScreen *screen, const xcb_randr_output_cha // If the screen became primary, reshuffle the order in QGuiApplicationPrivate const int idx = m_screens.indexOf(screen); if (idx > 0) { - qAsConst(m_screens).first()->setPrimary(false); + std::as_const(m_screens).first()->setPrimary(false); m_screens.swapItemsAt(0, idx); } screen->virtualDesktop()->setPrimaryScreen(screen); @@ -204,7 +204,7 @@ QXcbScreen *QXcbConnection::createScreen(QXcbVirtualDesktop *virtualDesktop, if (screen->isPrimary()) { if (!m_screens.isEmpty()) - qAsConst(m_screens).first()->setPrimary(false); + std::as_const(m_screens).first()->setPrimary(false); m_screens.prepend(screen); } else { @@ -219,7 +219,7 @@ QXcbScreen *QXcbConnection::createScreen(QXcbVirtualDesktop *virtualDesktop, void QXcbConnection::destroyScreen(QXcbScreen *screen) { QXcbVirtualDesktop *virtualDesktop = screen->virtualDesktop(); - if (virtualDesktop->screens().count() == 1) { + if (virtualDesktop->screens().size() == 1) { // If there are no other screens on the same virtual desktop, // then transform the physical screen into a fake screen. const QString nameWas = screen->name(); @@ -253,7 +253,7 @@ void QXcbConnection::updateScreen_monitor(QXcbScreen *screen, xcb_randr_monitor_ if (screen->isPrimary()) { const int idx = m_screens.indexOf(screen); if (idx > 0) { - qAsConst(m_screens).first()->setPrimary(false); + std::as_const(m_screens).first()->setPrimary(false); m_screens.swapItemsAt(0, idx); } screen->virtualDesktop()->setPrimaryScreen(screen); @@ -268,7 +268,7 @@ QXcbScreen *QXcbConnection::createScreen_monitor(QXcbVirtualDesktop *virtualDesk if (screen->isPrimary()) { if (!m_screens.isEmpty()) - qAsConst(m_screens).first()->setPrimary(false); + std::as_const(m_screens).first()->setPrimary(false); m_screens.prepend(screen); } else { @@ -326,7 +326,7 @@ void QXcbConnection::initializeScreens(bool initialized) ++xcbScreenNumber; } - for (QXcbVirtualDesktop *virtualDesktop : qAsConst(m_virtualDesktops)) + for (QXcbVirtualDesktop *virtualDesktop : std::as_const(m_virtualDesktops)) virtualDesktop->subscribeToXFixesSelectionNotify(); if (m_virtualDesktops.isEmpty()) { @@ -334,7 +334,7 @@ void QXcbConnection::initializeScreens(bool initialized) } else { // Ensure the primary screen is first on the list if (primaryScreen) { - if (qAsConst(m_screens).first() != primaryScreen) { + if (std::as_const(m_screens).first() != primaryScreen) { m_screens.removeOne(primaryScreen); m_screens.prepend(primaryScreen); } @@ -342,14 +342,14 @@ void QXcbConnection::initializeScreens(bool initialized) // Push the screens to QGuiApplication if (!initialized) { - for (QXcbScreen *screen : qAsConst(m_screens)) { + for (QXcbScreen *screen : std::as_const(m_screens)) { qCDebug(lcQpaScreen) << "adding" << screen << "(Primary:" << screen->isPrimary() << ")"; QWindowSystemInterface::handleScreenAdded(screen, screen->isPrimary()); } } if (!m_screens.isEmpty()) - qCDebug(lcQpaScreen) << "initializeScreens: primary output is" << qAsConst(m_screens).first()->name(); + qCDebug(lcQpaScreen) << "initializeScreens: primary output is" << std::as_const(m_screens).first()->name(); } } @@ -489,6 +489,10 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int virtualDesktop = new QXcbVirtualDesktop(this, xcbScreen, xcbScreenNumber); m_virtualDesktops.append(virtualDesktop); } + + if (xcbScreenNumber != primaryScreenNumber()) + return; + QList<QPlatformScreen*> old = virtualDesktop->m_screens; QList<QPlatformScreen *> siblings; @@ -517,18 +521,17 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int old.removeAll(screen); } } - m_screens << screen; + if (!m_screens.contains(screen)) + m_screens << screen; siblings << screen; // similar logic with QXcbConnection::initializeScreensFromOutput() - if (primaryScreenNumber() == xcbScreenNumber) { - if (!(*primaryScreen) || monitor_info->primary) { - if (*primaryScreen) - (*primaryScreen)->setPrimary(false); - *primaryScreen = screen; - (*primaryScreen)->setPrimary(true); - siblings.prepend(siblings.takeLast()); - } + if (!(*primaryScreen) || monitor_info->primary) { + if (*primaryScreen) + (*primaryScreen)->setPrimary(false); + *primaryScreen = screen; + (*primaryScreen)->setPrimary(true); + siblings.prepend(siblings.takeLast()); } xcb_randr_monitor_info_next(&monitor_iter); @@ -551,10 +554,8 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int qCDebug(lcQpaScreen) << "create a fake screen: " << screen; } - if (primaryScreenNumber() == xcbScreenNumber) { - *primaryScreen = screen; - (*primaryScreen)->setPrimary(true); - } + *primaryScreen = screen; + (*primaryScreen)->setPrimary(true); siblings << screen; m_screens << screen; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f528e8b593..c995a27d33 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -226,7 +226,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, auto *deviceInfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info); if (removeExisting) { #if QT_CONFIG(tabletevent) - for (int i = 0; i < m_tabletData.count(); ++i) { + for (int i = 0; i < m_tabletData.size(); ++i) { if (m_tabletData.at(i).deviceId == deviceInfo->deviceid) { m_tabletData.remove(i); break; @@ -270,9 +270,9 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, tabletData.valuatorInfo[valuatorAtom] = info; } #endif // QT_CONFIG(tabletevent) - if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) + if (valuatorAtom == QXcbAtom::AtomRelHorizScroll || valuatorAtom == QXcbAtom::AtomRelHorizWheel) scrollingDevice()->lastScrollPosition.setX(fixed3232ToReal(vci->value)); - else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) + else if (valuatorAtom == QXcbAtom::AtomRelVertScroll || valuatorAtom == QXcbAtom::AtomRelVertWheel) scrollingDevice()->lastScrollPosition.setY(fixed3232ToReal(vci->value)); break; } @@ -300,14 +300,14 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, xcb_atom_t label5 = labels[4]; // Some drivers have no labels on the wheel buttons, some have no label on just one and some have no label on // button 4 and the wrong one on button 5. So we just check that they are not labelled with unrelated buttons. - if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp || qatom(label4) == QXcbAtom::ButtonWheelDown) && - (!label5 || qatom(label5) == QXcbAtom::ButtonWheelUp || qatom(label5) == QXcbAtom::ButtonWheelDown)) + if ((!label4 || qatom(label4) == QXcbAtom::AtomButtonWheelUp || qatom(label4) == QXcbAtom::AtomButtonWheelDown) && + (!label5 || qatom(label5) == QXcbAtom::AtomButtonWheelUp || qatom(label5) == QXcbAtom::AtomButtonWheelDown)) scrollingDevice()->legacyOrientations |= Qt::Vertical; } if (bci->num_buttons >= 7) { xcb_atom_t label6 = labels[5]; xcb_atom_t label7 = labels[6]; - if ((!label6 || qatom(label6) == QXcbAtom::ButtonHorizWheelLeft) && (!label7 || qatom(label7) == QXcbAtom::ButtonHorizWheelRight)) + if ((!label6 || qatom(label6) == QXcbAtom::AtomButtonHorizWheelLeft) && (!label7 || qatom(label7) == QXcbAtom::AtomButtonHorizWheelRight)) scrollingDevice()->legacyOrientations |= Qt::Horizontal; } buttonCount = bci->num_buttons; @@ -331,9 +331,9 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, bool isTablet = false; #if QT_CONFIG(tabletevent) // If we have found the valuators which we expect a tablet to have, it might be a tablet. - if (tabletData.valuatorInfo.contains(QXcbAtom::AbsX) && - tabletData.valuatorInfo.contains(QXcbAtom::AbsY) && - tabletData.valuatorInfo.contains(QXcbAtom::AbsPressure)) + if (tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsX) && + tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsY) && + tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsPressure)) isTablet = true; // But we need to be careful not to take the touch and tablet-button devices as tablets. @@ -356,7 +356,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, // combined device (evdev) rather than separate pen/eraser (wacom driver) tabletData.pointerType = QPointingDevice::PointerType::Pen; dbgType = "pen"_L1; - } else if (nameLower.contains("aiptek") /* && device == QXcbAtom::KEYBOARD */) { + } else if (nameLower.contains("aiptek") /* && device == QXcbAtom::AtomKEYBOARD */) { // some "Genius" tablets isTablet = true; tabletData.pointerType = QPointingDevice::PointerType::Pen; @@ -384,9 +384,9 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, m_tabletData.append(tabletData); qCDebug(lcQpaXInputDevices) << " it's a tablet with pointer type" << dbgType; QPointingDevice::Capabilities capsOverride = QInputDevice::Capability::None; - if (tabletData.valuatorInfo.contains(QXcbAtom::AbsTiltX)) + if (tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsTiltX)) capsOverride.setFlag(QInputDevice::Capability::XTilt); - if (tabletData.valuatorInfo.contains(QXcbAtom::AbsTiltY)) + if (tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsTiltY)) capsOverride.setFlag(QInputDevice::Capability::YTilt); // TODO can we get USB ID? Q_ASSERT(deviceInfo->deviceid == tabletData.deviceId); @@ -573,27 +573,27 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info // Some devices (mice) report a resolution of 0; they will be excluded later, // for now just prevent a division by zero const int vciResolution = vci->resolution ? vci->resolution : 1; - if (valuatorAtom == QXcbAtom::AbsMTPositionX) + if (valuatorAtom == QXcbAtom::AtomAbsMTPositionX) caps |= QInputDevice::Capability::Position | QInputDevice::Capability::NormalizedPosition; - else if (valuatorAtom == QXcbAtom::AbsMTTouchMajor) + else if (valuatorAtom == QXcbAtom::AtomAbsMTTouchMajor) caps |= QInputDevice::Capability::Area; - else if (valuatorAtom == QXcbAtom::AbsMTOrientation) + else if (valuatorAtom == QXcbAtom::AtomAbsMTOrientation) dev.providesTouchOrientation = true; - else if (valuatorAtom == QXcbAtom::AbsMTPressure || valuatorAtom == QXcbAtom::AbsPressure) + else if (valuatorAtom == QXcbAtom::AtomAbsMTPressure || valuatorAtom == QXcbAtom::AtomAbsPressure) caps |= QInputDevice::Capability::Pressure; - else if (valuatorAtom == QXcbAtom::RelX) { + else if (valuatorAtom == QXcbAtom::AtomRelX) { hasRelativeCoords = true; dev.size.setWidth((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution); - } else if (valuatorAtom == QXcbAtom::RelY) { + } else if (valuatorAtom == QXcbAtom::AtomRelY) { hasRelativeCoords = true; dev.size.setHeight((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution); - } else if (valuatorAtom == QXcbAtom::AbsX) { + } else if (valuatorAtom == QXcbAtom::AtomAbsX) { caps |= QInputDevice::Capability::Position; dev.size.setWidth((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution); - } else if (valuatorAtom == QXcbAtom::AbsY) { + } else if (valuatorAtom == QXcbAtom::AtomAbsY) { caps |= QInputDevice::Capability::Position; dev.size.setHeight((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution); - } else if (valuatorAtom == QXcbAtom::RelVertWheel || valuatorAtom == QXcbAtom::RelHorizWheel) { + } else if (valuatorAtom == QXcbAtom::AtomRelVertWheel || valuatorAtom == QXcbAtom::AtomRelHorizWheel) { caps |= QInputDevice::Capability::Scroll; } break; @@ -792,7 +792,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo qreal nx = -1.0, ny = -1.0; qreal w = 0.0, h = 0.0; bool majorAxisIsY = touchPoint.area.height() > touchPoint.area.width(); - for (const TouchDeviceData::ValuatorClassInfo &vci : qAsConst(dev->valuatorInfo)) { + for (const TouchDeviceData::ValuatorClassInfo &vci : std::as_const(dev->valuatorInfo)) { double value; if (!xi2GetValuatorValueIfSet(xiDeviceEvent, vci.number, &value)) continue; @@ -804,27 +804,27 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo if (value < vci.min) value = vci.min; qreal valuatorNormalized = (value - vci.min) / (vci.max - vci.min); - if (vci.label == QXcbAtom::RelX) { + if (vci.label == QXcbAtom::AtomRelX) { nx = valuatorNormalized; - } else if (vci.label == QXcbAtom::RelY) { + } else if (vci.label == QXcbAtom::AtomRelY) { ny = valuatorNormalized; - } else if (vci.label == QXcbAtom::AbsX) { + } else if (vci.label == QXcbAtom::AtomAbsX) { nx = valuatorNormalized; - } else if (vci.label == QXcbAtom::AbsY) { + } else if (vci.label == QXcbAtom::AtomAbsY) { ny = valuatorNormalized; - } else if (vci.label == QXcbAtom::AbsMTPositionX) { + } else if (vci.label == QXcbAtom::AtomAbsMTPositionX) { nx = valuatorNormalized; - } else if (vci.label == QXcbAtom::AbsMTPositionY) { + } else if (vci.label == QXcbAtom::AtomAbsMTPositionY) { ny = valuatorNormalized; - } else if (vci.label == QXcbAtom::AbsMTTouchMajor) { + } else if (vci.label == QXcbAtom::AtomAbsMTTouchMajor) { const qreal sw = screen->geometry().width(); const qreal sh = screen->geometry().height(); w = valuatorNormalized * qHypot(sw, sh); - } else if (vci.label == QXcbAtom::AbsMTTouchMinor) { + } else if (vci.label == QXcbAtom::AtomAbsMTTouchMinor) { const qreal sw = screen->geometry().width(); const qreal sh = screen->geometry().height(); h = valuatorNormalized * qHypot(sw, sh); - } else if (vci.label == QXcbAtom::AbsMTOrientation) { + } else if (vci.label == QXcbAtom::AtomAbsMTOrientation) { // Find the closest axis. // 0 corresponds to the Y axis, vci.max to the X axis. // Flipping over the Y axis and rotating by 180 degrees @@ -835,7 +835,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo value -= 2 * vci.max; value = qAbs(value); majorAxisIsY = value < vci.max - value; - } else if (vci.label == QXcbAtom::AbsMTPressure || vci.label == QXcbAtom::AbsPressure) { + } else if (vci.label == QXcbAtom::AtomAbsMTPressure || vci.label == QXcbAtom::AtomAbsPressure) { touchPoint.pressure = valuatorNormalized; } @@ -967,7 +967,7 @@ void QXcbConnection::abortSystemMoveResize(xcb_window_t window) qCDebug(lcQpaXInputDevices) << "sending client message NET_WM_MOVERESIZE_CANCEL to window: " << window; m_startSystemMoveResizeInfo.window = XCB_NONE; - const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); + const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE); xcb_client_message_event_t xev; xev.response_type = XCB_CLIENT_MESSAGE; xev.type = moveResize; @@ -1023,7 +1023,7 @@ bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab) } #endif // QT_CONFIG(gestures) && QT_XCB_HAS_TOUCHPAD_GESTURES - for (int id : qAsConst(m_xiMasterPointerIds)) { + for (int id : std::as_const(m_xiMasterPointerIds)) { xcb_generic_error_t *error = nullptr; auto cookie = xcb_input_xi_grab_device(xcb_connection(), w, XCB_CURRENT_TIME, XCB_CURSOR_NONE, id, XCB_INPUT_GRAB_MODE_22_ASYNC, XCB_INPUT_GRAB_MODE_22_ASYNC, @@ -1041,7 +1041,7 @@ bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab) free(reply); } } else { // ungrab - for (int id : qAsConst(m_xiMasterPointerIds)) { + for (int id : std::as_const(m_xiMasterPointerIds)) { auto cookie = xcb_input_xi_ungrab_device_checked(xcb_connection(), XCB_CURRENT_TIME, id); xcb_generic_error_t *error = xcb_request_check(xcb_connection(), cookie); if (error) { @@ -1275,9 +1275,9 @@ void QXcbConnection::xi2UpdateScrollingDevice(QInputDevice *dev) if (classInfo->type == XCB_INPUT_DEVICE_CLASS_TYPE_VALUATOR) { auto *vci = reinterpret_cast<xcb_input_valuator_class_t *>(classInfo); const int valuatorAtom = qatom(vci->label); - if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) + if (valuatorAtom == QXcbAtom::AtomRelHorizScroll || valuatorAtom == QXcbAtom::AtomRelHorizWheel) scrollingDevice->lastScrollPosition.setX(fixed3232ToReal(vci->value)); - else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) + else if (valuatorAtom == QXcbAtom::AtomRelVertScroll || valuatorAtom == QXcbAtom::AtomRelVertWheel) scrollingDevice->lastScrollPosition.setY(fixed3232ToReal(vci->value)); } } @@ -1464,7 +1464,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD // The evdev driver doesn't do it this way. const auto *ev = reinterpret_cast<const xcb_input_property_event_t *>(event); if (ev->what == XCB_INPUT_PROPERTY_FLAG_MODIFIED) { - if (ev->property == atom(QXcbAtom::WacomSerialIDs)) { + if (ev->property == atom(QXcbAtom::AtomWacomSerialIDs)) { enum WacomSerialIndex { _WACSER_USB_ID = 0, _WACSER_LAST_TOOL_SERIAL, @@ -1477,7 +1477,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD auto reply = Q_XCB_REPLY(xcb_input_xi_get_property, xcb_connection(), tabletData->deviceId, 0, ev->property, XCB_GET_PROPERTY_TYPE_ANY, 0, 100); if (reply) { - if (reply->type == atom(QXcbAtom::INTEGER) && reply->format == 32 && reply->num_items == _WACSER_COUNT) { + if (reply->type == atom(QXcbAtom::AtomINTEGER) && reply->format == 32 && reply->num_items == _WACSER_COUNT) { quint32 *ptr = reinterpret_cast<quint32 *>(xcb_input_xi_get_property_items(reply.get())); quint32 tool = ptr[_WACSER_TOOL_ID]; // Workaround for http://sourceforge.net/p/linuxwacom/bugs/246/ @@ -1570,30 +1570,30 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD xi2GetValuatorValueIfSet(event, classInfo.number, &classInfo.curVal); double normalizedValue = (classInfo.curVal - classInfo.minVal) / (classInfo.maxVal - classInfo.minVal); switch (valuator) { - case QXcbAtom::AbsX: + case QXcbAtom::AtomAbsX: if (Q_LIKELY(useValuators)) { const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width()); global.setX(value); local.setX(xcbWindow->mapFromGlobalF(global).x()); } break; - case QXcbAtom::AbsY: + case QXcbAtom::AtomAbsY: if (Q_LIKELY(useValuators)) { qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height()); global.setY(value); local.setY(xcbWindow->mapFromGlobalF(global).y()); } break; - case QXcbAtom::AbsPressure: + case QXcbAtom::AtomAbsPressure: pressure = normalizedValue; break; - case QXcbAtom::AbsTiltX: + case QXcbAtom::AtomAbsTiltX: xTilt = classInfo.curVal; break; - case QXcbAtom::AbsTiltY: + case QXcbAtom::AtomAbsTiltY: yTilt = classInfo.curVal; break; - case QXcbAtom::AbsWheel: + case QXcbAtom::AtomAbsWheel: switch (tabletData->tool) { case QInputDevice::DeviceType::Airbrush: tangentialPressure = normalizedValue * 2.0 - 1.0; // Convert 0..1 range to -1..+1 range @@ -1627,7 +1627,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id) { - for (int i = 0; i < m_tabletData.count(); ++i) { + for (int i = 0; i < m_tabletData.size(); ++i) { if (m_tabletData.at(i).deviceId == id) return &m_tabletData[i]; } diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 2cc39f1e85..a6a41982ff 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -317,7 +317,7 @@ QXcbCursor::~QXcbCursor() xcb_close_font(conn, cursorFont); #ifndef QT_NO_CURSOR - for (xcb_cursor_t cursor : qAsConst(m_cursorHash)) + for (xcb_cursor_t cursor : std::as_const(m_cursorHash)) xcb_free_cursor(conn, cursor); #endif } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index f5cb50d9c6..e209277144 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -44,7 +44,7 @@ static xcb_window_t xdndProxy(QXcbConnection *c, xcb_window_t w) xcb_window_t proxy = XCB_NONE; auto reply = Q_XCB_REPLY(xcb_get_property, c->xcb_connection(), - false, w, c->atom(QXcbAtom::XdndProxy), XCB_ATOM_WINDOW, 0, 1); + false, w, c->atom(QXcbAtom::AtomXdndProxy), XCB_ATOM_WINDOW, 0, 1); if (reply && reply->type == XCB_ATOM_WINDOW) proxy = *((xcb_window_t *)xcb_get_property_value(reply.get())); @@ -54,7 +54,7 @@ static xcb_window_t xdndProxy(QXcbConnection *c, xcb_window_t w) // exists and is real? reply = Q_XCB_REPLY(xcb_get_property, c->xcb_connection(), - false, proxy, c->atom(QXcbAtom::XdndProxy), XCB_ATOM_WINDOW, 0, 1); + false, proxy, c->atom(QXcbAtom::AtomXdndProxy), XCB_ATOM_WINDOW, 0, 1); if (reply && reply->type == XCB_ATOM_WINDOW) { xcb_window_t p = *((xcb_window_t *)xcb_get_property_value(reply.get())); @@ -140,7 +140,7 @@ void QXcbDrag::startDrag() qCDebug(lcQpaXDnd) << "starting drag where source:" << connection()->qtSelectionOwner(); xcb_set_selection_owner(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::XdndSelection), connection()->time()); + atom(QXcbAtom::AtomXdndSelection), connection()->time()); QStringList fmts = QXcbMime::formatsHelper(drag()->mimeData()); for (int i = 0; i < fmts.size(); ++i) { @@ -153,7 +153,7 @@ void QXcbDrag::startDrag() if (drag_types.size() > 3) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->qtSelectionOwner(), - atom(QXcbAtom::XdndTypelist), + atom(QXcbAtom::AtomXdndTypelist), XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData()); setUseCompositing(current_virtual_desktop->compositingActive()); @@ -187,7 +187,7 @@ Qt::DropAction QXcbDrag::defaultAction(Qt::DropActions possibleActions, Qt::Keyb void QXcbDrag::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) { - if (event->window != xdnd_dragsource || event->atom != atom(QXcbAtom::XdndActionList)) + if (event->window != xdnd_dragsource || event->atom != atom(QXcbAtom::AtomXdndActionList)) return; readActionList(); @@ -233,7 +233,7 @@ xcb_window_t QXcbDrag::findRealWindow(const QPoint & pos, xcb_window_t w, int md bool windowContainsMouse = !ignoreNonXdndAwareWindows; { auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), - false, w, connection()->atom(QXcbAtom::XdndAware), + false, w, connection()->atom(QXcbAtom::AtomXdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0); bool isAware = reply && reply->type != XCB_NONE; if (isAware) { @@ -306,7 +306,7 @@ bool QXcbDrag::findXdndAwareTarget(const QPoint &globalPos, xcb_window_t *target xcb_window_t child = translate->child; auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, target, - atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0); + atom(QXcbAtom::AtomXdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0); bool aware = reply && reply->type != XCB_NONE; if (aware) { qCDebug(lcQpaXDnd) << "found XdndAware on" << target; @@ -379,7 +379,7 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod if (proxy_target) { auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, proxy_target, - atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 1); + atom(QXcbAtom::AtomXdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 1); if (!reply || reply->type == XCB_NONE) { target = 0; } else { @@ -404,7 +404,7 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod enter.sequence = 0; enter.window = target; enter.format = 32; - enter.type = atom(QXcbAtom::XdndEnter); + enter.type = atom(QXcbAtom::AtomXdndEnter); enter.data.data32[0] = connection()->qtSelectionOwner(); enter.data.data32[1] = flags; enter.data.data32[2] = drag_types.size() > 0 ? drag_types.at(0) : 0; @@ -435,7 +435,7 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod move.sequence = 0; move.window = target; move.format = 32; - move.type = atom(QXcbAtom::XdndPosition); + move.type = atom(QXcbAtom::AtomXdndPosition); move.data.data32[0] = connection()->qtSelectionOwner(); move.data.data32[1] = 0; // flags move.data.data32[2] = (globalPos.x() << 16) + globalPos.y(); @@ -481,7 +481,7 @@ void QXcbDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod drop.sequence = 0; drop.window = current_target; drop.format = 32; - drop.type = atom(QXcbAtom::XdndDrop); + drop.type = atom(QXcbAtom::AtomXdndDrop); drop.data.data32[0] = connection()->qtSelectionOwner(); drop.data.data32[1] = 0; // flags drop.data.data32[2] = connection()->time(); @@ -521,11 +521,11 @@ void QXcbDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t a) const { - if (a == atom(QXcbAtom::XdndActionCopy) || a == 0) + if (a == atom(QXcbAtom::AtomXdndActionCopy) || a == 0) return Qt::CopyAction; - if (a == atom(QXcbAtom::XdndActionLink)) + if (a == atom(QXcbAtom::AtomXdndActionLink)) return Qt::LinkAction; - if (a == atom(QXcbAtom::XdndActionMove)) + if (a == atom(QXcbAtom::AtomXdndActionMove)) return Qt::MoveAction; return Qt::CopyAction; } @@ -534,7 +534,7 @@ Qt::DropActions QXcbDrag::toDropActions(const QList<xcb_atom_t> &atoms) const { Qt::DropActions actions; for (const auto actionAtom : atoms) { - if (actionAtom != atom(QXcbAtom::XdndActionAsk)) + if (actionAtom != atom(QXcbAtom::AtomXdndActionAsk)) actions |= toDropAction(actionAtom); } return actions; @@ -544,16 +544,16 @@ xcb_atom_t QXcbDrag::toXdndAction(Qt::DropAction a) const { switch (a) { case Qt::CopyAction: - return atom(QXcbAtom::XdndActionCopy); + return atom(QXcbAtom::AtomXdndActionCopy); case Qt::LinkAction: - return atom(QXcbAtom::XdndActionLink); + return atom(QXcbAtom::AtomXdndActionLink); case Qt::MoveAction: case Qt::TargetMoveAction: - return atom(QXcbAtom::XdndActionMove); + return atom(QXcbAtom::AtomXdndActionMove); case Qt::IgnoreAction: return XCB_NONE; default: - return atom(QXcbAtom::XdndActionCopy); + return atom(QXcbAtom::AtomXdndActionCopy); } } @@ -561,7 +561,7 @@ void QXcbDrag::readActionList() { drop_actions.clear(); auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, xdnd_dragsource, - atom(QXcbAtom::XdndActionList), XCB_ATOM_ATOM, + atom(QXcbAtom::AtomXdndActionList), XCB_ATOM_ATOM, 0, 1024); if (reply && reply->type != XCB_NONE && reply->format == 32) { int length = xcb_get_property_value_length(reply.get()) / 4; @@ -590,7 +590,7 @@ void QXcbDrag::setActionList(Qt::DropAction requestedAction, Qt::DropActions sup if (current_actions != actions) { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->qtSelectionOwner(), - atom(QXcbAtom::XdndActionList), + atom(QXcbAtom::AtomXdndActionList), XCB_ATOM_ATOM, 32, actions.size(), actions.constData()); current_actions = actions; } @@ -614,7 +614,7 @@ void QXcbDrag::stopListeningForActionListChanges() int QXcbDrag::findTransactionByWindow(xcb_window_t window) { int at = -1; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.target == window || t.proxy_target == window) { at = i; @@ -627,7 +627,7 @@ int QXcbDrag::findTransactionByWindow(xcb_window_t window) int QXcbDrag::findTransactionByTime(xcb_timestamp_t timestamp) { int at = -1; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.timestamp == timestamp) { at = i; @@ -701,7 +701,7 @@ void QXcbDrag::handleEnter(QPlatformWindow *, const xcb_client_message_event_t * if (event->data.data32[1] & 1) { // get the types from XdndTypeList auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, xdnd_dragsource, - atom(QXcbAtom::XdndTypelist), XCB_ATOM_ATOM, + atom(QXcbAtom::AtomXdndTypelist), XCB_ATOM_ATOM, 0, xdnd_max_type); if (reply && reply->type != XCB_NONE && reply->format == 32) { int length = xcb_get_property_value_length(reply.get()) / 4; @@ -720,7 +720,7 @@ void QXcbDrag::handleEnter(QPlatformWindow *, const xcb_client_message_event_t * xdnd_types.append(event->data.data32[i]); } } - for(int i = 0; i < xdnd_types.length(); ++i) + for(int i = 0; i < xdnd_types.size(); ++i) qCDebug(lcQpaXDnd) << " " << connection()->atomName(xdnd_types.at(i)); } @@ -734,7 +734,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message QPoint p((e->data.data32[2] & 0xffff0000) >> 16, e->data.data32[2] & 0x0000ffff); Q_ASSERT(w); QRect geometry = w->geometry(); - p -= geometry.topLeft(); + p -= w->isEmbedded() ? w->mapToGlobal(geometry.topLeft()) : geometry.topLeft(); if (!w || !w->window() || (w->window()->type() == Qt::Desktop)) return; @@ -761,7 +761,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message } else { dropData = m_dropData; supported_actions = toDropActions(drop_actions); - if (e->data.data32[4] != atom(QXcbAtom::XdndActionAsk)) + if (e->data.data32[4] != atom(QXcbAtom::AtomXdndActionAsk)) supported_actions |= Qt::DropActions(toDropAction(e->data.data32[4])); } @@ -783,7 +783,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message response.sequence = 0; response.window = xdnd_dragsource; response.format = 32; - response.type = atom(QXcbAtom::XdndStatus); + response.type = atom(QXcbAtom::AtomXdndStatus); response.data.data32[0] = xcb_window(w); response.data.data32[1] = qt_response.isAccepted(); // flags response.data.data32[2] = 0; // x, y @@ -835,7 +835,7 @@ namespace void QXcbDrag::handlePosition(QPlatformWindow * w, const xcb_client_message_event_t *event) { xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event); - ClientMessageScanner scanner(atom(QXcbAtom::XdndPosition)); + ClientMessageScanner scanner(atom(QXcbAtom::AtomXdndPosition)); while (auto nextEvent = connection()->eventQueue()->peek(scanner)) { if (lastEvent != event) free(lastEvent); @@ -883,7 +883,7 @@ void QXcbDrag::handleStatus(const xcb_client_message_event_t *event) xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event); xcb_generic_event_t *nextEvent; - ClientMessageScanner scanner(atom(QXcbAtom::XdndStatus)); + ClientMessageScanner scanner(atom(QXcbAtom::AtomXdndStatus)); while ((nextEvent = connection()->eventQueue()->peek(scanner))) { if (lastEvent != event) free(lastEvent); @@ -934,7 +934,7 @@ void QXcbDrag::send_leave() leave.sequence = 0; leave.window = current_target; leave.format = 32; - leave.type = atom(QXcbAtom::XdndLeave); + leave.type = atom(QXcbAtom::AtomXdndLeave); leave.data.data32[0] = connection()->qtSelectionOwner(); leave.data.data32[1] = 0; // flags leave.data.data32[2] = 0; // x, y @@ -980,21 +980,30 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e Qt::DropActions supported_drop_actions; QMimeData *dropData = nullptr; + // this could be a same-application drop, just proxied due to + // some XEMBEDding, so try to find the real QMimeData used + // based on the timestamp for this drop. + int at = findTransactionByTime(target_time); + if (at != -1) { + qCDebug(lcQpaXDnd) << "found one transaction via findTransactionByTime()"; + dropData = transactions.at(at).drag->mimeData(); + // Can't use the source QMimeData if we need the image conversion code from xdndObtainData + if (dropData && dropData->hasImage()) + dropData = 0; + } + // if we can't find it, then use the data in the drag manager if (currentDrag()) { - dropData = currentDrag()->mimeData(); + if (!dropData) + dropData = currentDrag()->mimeData(); supported_drop_actions = Qt::DropActions(l[4]); } else { - dropData = m_dropData; + if (!dropData) + dropData = m_dropData; supported_drop_actions = accepted_drop_action | toDropActions(drop_actions); } if (!dropData) return; - // ### - // int at = findXdndDropTransactionByTime(target_time); - // if (at != -1) - // dropData = QDragManager::dragPrivate(X11->dndDropTransactions.at(at).object)->data; - // if we can't find it, then use the data in the drag manager auto buttons = currentDrag() ? b : connection()->queryMouseButtons(); auto modifiers = currentDrag() ? mods : connection()->queryKeyboardModifiers(); @@ -1003,17 +1012,22 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e currentWindow.data(), dropData, currentPosition, supported_drop_actions, buttons, modifiers); - setExecutedDropAction(response.acceptedAction()); + Qt::DropAction acceptedAaction = response.acceptedAction(); + if (!response.isAccepted()) { + // Ignore a failed drag + acceptedAaction = Qt::IgnoreAction; + } + setExecutedDropAction(acceptedAaction); xcb_client_message_event_t finished = {}; finished.response_type = XCB_CLIENT_MESSAGE; finished.sequence = 0; finished.window = xdnd_dragsource; finished.format = 32; - finished.type = atom(QXcbAtom::XdndFinished); + finished.type = atom(QXcbAtom::AtomXdndFinished); finished.data.data32[0] = currentWindow ? xcb_window(currentWindow.data()) : XCB_NONE; finished.data.data32[1] = response.isAccepted(); // flags - finished.data.data32[2] = toXdndAction(response.acceptedAction()); + finished.data.data32[2] = toXdndAction(acceptedAaction); qCDebug(lcQpaXDnd) << "sending XdndFinished to source:" << xdnd_dragsource; @@ -1075,7 +1089,7 @@ void QXcbDrag::timerEvent(QTimerEvent* e) { if (e->timerId() == cleanup_timer) { bool stopTimer = true; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.targetWindow) { // dnd within the same process, don't delete, these are taken care of @@ -1127,7 +1141,7 @@ static xcb_window_t findXdndAwareParent(QXcbConnection *c, xcb_window_t window) forever { // check if window has XdndAware auto gpReply = Q_XCB_REPLY(xcb_get_property, c->xcb_connection(), false, window, - c->atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0); + c->atom(QXcbAtom::AtomXdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0); bool aware = gpReply && gpReply->type != XCB_NONE; if (aware) { target = window; @@ -1217,6 +1231,7 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) { + qCDebug(lcQpaXDnd) << "dndEnable" << w << on; // Windows announce that they support the XDND protocol by creating a window property XdndAware. if (on) { QXcbWindow *window = nullptr; @@ -1233,7 +1248,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) desktop_proxy = new QWindow; window = static_cast<QXcbWindow *>(desktop_proxy->handle()); proxy_id = window->xcb_window(); - xcb_atom_t xdnd_proxy = atom(QXcbAtom::XdndProxy); + xcb_atom_t xdnd_proxy = atom(QXcbAtom::AtomXdndProxy); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, w->xcb_window(), xdnd_proxy, XCB_ATOM_WINDOW, 32, 1, &proxy_id); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, proxy_id, xdnd_proxy, @@ -1247,14 +1262,14 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) qCDebug(lcQpaXDnd) << "setting XdndAware for" << window->xcb_window(); xcb_atom_t atm = xdnd_version; xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window->xcb_window(), - atom(QXcbAtom::XdndAware), XCB_ATOM_ATOM, 32, 1, &atm); + atom(QXcbAtom::AtomXdndAware), XCB_ATOM_ATOM, 32, 1, &atm); return true; } else { return false; } } else { if (w->window()->type() == Qt::Desktop) { - xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy)); + xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::AtomXdndProxy)); delete desktop_proxy; desktop_proxy = nullptr; } else { @@ -1306,10 +1321,10 @@ QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QMetaType reques return result; #ifndef QT_NO_CLIPBOARD - if (c->selectionOwner(c->atom(QXcbAtom::XdndSelection)) == XCB_NONE) + if (c->selectionOwner(c->atom(QXcbAtom::AtomXdndSelection)) == XCB_NONE) return result; // should never happen? - xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection); + xcb_atom_t xdnd_selection = c->atom(QXcbAtom::AtomXdndSelection); result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection, drag->targetTime()); #endif diff --git a/src/plugins/platforms/xcb/qxcbeventqueue.cpp b/src/plugins/platforms/xcb/qxcbeventqueue.cpp index 5c87cba80d..33795d63cf 100644 --- a/src/plugins/platforms/xcb/qxcbeventqueue.cpp +++ b/src/plugins/platforms/xcb/qxcbeventqueue.cpp @@ -345,7 +345,7 @@ void QXcbEventQueue::sendCloseConnectionEvent() const event.format = 32; event.sequence = 0; event.window = window; - event.type = m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION); + event.type = m_connection->atom(QXcbAtom::Atom_QT_CLOSE_CONNECTION); event.data.data32[0] = 0; xcb_send_event(c, false, window, XCB_EVENT_MASK_NO_EVENT, reinterpret_cast<const char *>(&event)); @@ -357,7 +357,7 @@ bool QXcbEventQueue::isCloseConnectionEvent(const xcb_generic_event_t *event) { if (event && (event->response_type & ~0x80) == XCB_CLIENT_MESSAGE) { auto clientMessage = reinterpret_cast<const xcb_client_message_event_t *>(event); - if (clientMessage->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION)) + if (clientMessage->type == m_connection->atom(QXcbAtom::Atom_QT_CLOSE_CONNECTION)) m_closeConnectionDetected = true; } return m_closeConnectionDetected; diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7161af279c..9d62423071 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -27,8 +27,8 @@ QString QXcbMime::mimeAtomToString(QXcbConnection *connection, xcb_atom_t a) // special cases for string type if (a == XCB_ATOM_STRING - || a == connection->atom(QXcbAtom::UTF8_STRING) - || a == connection->atom(QXcbAtom::TEXT)) + || a == connection->atom(QXcbAtom::AtomUTF8_STRING) + || a == connection->atom(QXcbAtom::AtomTEXT)) return "text/plain"_L1; // special case for images @@ -54,15 +54,15 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa *atomFormat = a; *dataFormat = 8; - if ((a == connection->atom(QXcbAtom::UTF8_STRING) + if ((a == connection->atom(QXcbAtom::AtomUTF8_STRING) || a == XCB_ATOM_STRING - || a == connection->atom(QXcbAtom::TEXT)) + || a == connection->atom(QXcbAtom::AtomTEXT)) && QInternalMimeData::hasFormatHelper("text/plain"_L1, mimeData)) { - if (a == connection->atom(QXcbAtom::UTF8_STRING)) { + if (a == connection->atom(QXcbAtom::AtomUTF8_STRING)) { *data = QInternalMimeData::renderDataHelper("text/plain"_L1, mimeData); ret = true; } else if (a == XCB_ATOM_STRING || - a == connection->atom(QXcbAtom::TEXT)) { + a == connection->atom(QXcbAtom::AtomTEXT)) { // ICCCM says STRING is latin1 *data = QString::fromUtf8(QInternalMimeData::renderDataHelper( "text/plain"_L1, mimeData)).toLatin1(); @@ -80,7 +80,7 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa && connection->atomName(a) == "text/x-moz-url") { const QString mozUri = QLatin1StringView(data->split('\n').constFirst()) + u'\n'; *data = QByteArray(reinterpret_cast<const char *>(mozUri.data()), - mozUri.length() * 2); + mozUri.size() * 2); } else if (atomName == "application/x-color"_L1) *dataFormat = 16; ret = true; @@ -102,9 +102,9 @@ QList<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, const // special cases for strings if (format == "text/plain"_L1) { - atoms.append(connection->atom(QXcbAtom::UTF8_STRING)); + atoms.append(connection->atom(QXcbAtom::AtomUTF8_STRING)); atoms.append(XCB_ATOM_STRING); - atoms.append(connection->atom(QXcbAtom::TEXT)); + atoms.append(connection->atom(QXcbAtom::AtomTEXT)); } // special cases for uris @@ -139,11 +139,11 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, if (format == "text/plain"_L1) { if (data.endsWith('\0')) data.chop(1); - if (a == connection->atom(QXcbAtom::UTF8_STRING)) { + if (a == connection->atom(QXcbAtom::AtomUTF8_STRING)) { return QString::fromUtf8(data); } if (a == XCB_ATOM_STRING || - a == connection->atom(QXcbAtom::TEXT)) + a == connection->atom(QXcbAtom::AtomTEXT)) return QString::fromLatin1(data); } // If data contains UTF16 text, convert it to a string. @@ -227,12 +227,12 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString // find matches for string types if (format == "text/plain"_L1) { - if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING))) - return connection->atom(QXcbAtom::UTF8_STRING); + if (atoms.contains(connection->atom(QXcbAtom::AtomUTF8_STRING))) + return connection->atom(QXcbAtom::AtomUTF8_STRING); if (atoms.contains(XCB_ATOM_STRING)) return XCB_ATOM_STRING; - if (atoms.contains(connection->atom(QXcbAtom::TEXT))) - return connection->atom(QXcbAtom::TEXT); + if (atoms.contains(connection->atom(QXcbAtom::AtomTEXT))) + return connection->atom(QXcbAtom::AtomTEXT); } // find matches for uri types diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index cd6ff40df9..06f5241d8c 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -350,7 +350,7 @@ void *QXcbNativeInterface::atspiBus() QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); QXcbConnection *connection = integration->connection(); if (connection) { - auto atspiBusAtom = connection->atom(QXcbAtom::AT_SPI_BUS); + auto atspiBusAtom = connection->atom(QXcbAtom::AtomAT_SPI_BUS); auto reply = Q_XCB_REPLY(xcb_get_property, connection->xcb_connection(), false, connection->rootWindow(), atspiBusAtom, XCB_ATOM_STRING, 0, 128); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 2a538c9b6e..06f4b66edb 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -50,7 +50,7 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), false, screen->root, - atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK), + atom(QXcbAtom::Atom_NET_SUPPORTING_WM_CHECK), XCB_ATOM_WINDOW, 0, 1024); if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) { xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply.get())); @@ -92,7 +92,7 @@ QXcbVirtualDesktop::~QXcbVirtualDesktop() { delete m_xSettings; - for (auto cmap : qAsConst(m_visualColormaps)) + for (auto cmap : std::as_const(m_visualColormaps)) xcb_free_colormap(xcb_connection(), cmap); } @@ -222,7 +222,7 @@ void QXcbVirtualDesktop::handleScreenChange(xcb_randr_screen_change_notify_event case XCB_RANDR_ROTATION_REFLECT_Y: break; } - for (QPlatformScreen *platformScreen : qAsConst(m_screens)) { + for (QPlatformScreen *platformScreen : std::as_const(m_screens)) { QDpi ldpi = platformScreen->logicalDpi(); QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(platformScreen->screen(), ldpi.first, ldpi.second); } @@ -249,7 +249,7 @@ QRect QXcbVirtualDesktop::getWorkArea() const { QRect r; auto workArea = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), false, screen()->root, - atom(QXcbAtom::_NET_WORKAREA), + atom(QXcbAtom::Atom_NET_WORKAREA), XCB_ATOM_CARDINAL, 0, 1024); if (workArea && workArea->type == XCB_ATOM_CARDINAL && workArea->format == 32 && workArea->value_len >= 4) { // If workArea->value_len > 4, the remaining ones seem to be for WM's virtual desktops @@ -271,7 +271,7 @@ void QXcbVirtualDesktop::updateWorkArea() QRect workArea = getWorkArea(); if (m_workArea != workArea) { m_workArea = workArea; - for (QPlatformScreen *screen : qAsConst(m_screens)) + for (QPlatformScreen *screen : std::as_const(m_screens)) ((QXcbScreen *)screen)->updateAvailableGeometry(); } } @@ -529,7 +529,7 @@ void QXcbScreen::updateColorSpaceAndEdid() // Read colord ICC data (from GNOME settings) auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), false, screen()->root, - connection()->atom(QXcbAtom::_ICC_PROFILE), + connection()->atom(QXcbAtom::Atom_ICC_PROFILE), XCB_ATOM_CARDINAL, 0, 8192); if (reply->format == 8 && reply->type == XCB_ATOM_CARDINAL) { QByteArray data(reinterpret_cast<const char *>(xcb_get_property_value(reply.get())), reply->value_len); @@ -556,11 +556,11 @@ void QXcbScreen::updateColorSpaceAndEdid() m_edid.greenChromaticity, m_edid.blueChromaticity, QColorSpace::TransferFunction::Gamma, m_edid.gamma); } else { - if (m_edid.tables.length() == 1) { + if (m_edid.tables.size() == 1) { m_colorSpace = QColorSpace(m_edid.whiteChromaticity, m_edid.redChromaticity, m_edid.greenChromaticity, m_edid.blueChromaticity, m_edid.tables[0]); - } else if (m_edid.tables.length() == 3) { + } else if (m_edid.tables.size() == 3) { m_colorSpace = QColorSpace(m_edid.whiteChromaticity, m_edid.redChromaticity, m_edid.greenChromaticity, m_edid.blueChromaticity, m_edid.tables[0], m_edid.tables[1], m_edid.tables[2]); @@ -796,7 +796,7 @@ void QXcbScreen::windowShown(QXcbWindow *window) // Freedesktop.org Startup Notification if (!connection()->startupId().isEmpty() && window->window()->isTopLevel()) { sendStartupMessage(QByteArrayLiteral("remove: ID=") + connection()->startupId()); - connection()->clearStartupId(); + connection()->setStartupId({}); } } @@ -817,15 +817,15 @@ void QXcbScreen::sendStartupMessage(const QByteArray &message) const xcb_client_message_event_t ev; ev.response_type = XCB_CLIENT_MESSAGE; ev.format = 8; - ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO_BEGIN); + ev.type = connection()->atom(QXcbAtom::Atom_NET_STARTUP_INFO_BEGIN); ev.sequence = 0; ev.window = rootWindow; int sent = 0; - int length = message.length() + 1; // include NUL byte + int length = message.size() + 1; // include NUL byte const char *data = message.constData(); do { if (sent == 20) - ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO); + ev.type = connection()->atom(QXcbAtom::Atom_NET_STARTUP_INFO); const int start = sent; const int numBytes = qMin(length - start, 20); @@ -839,7 +839,7 @@ void QXcbScreen::sendStartupMessage(const QByteArray &message) const QRect QXcbScreen::availableGeometry() const { static bool enforceNetWorkarea = !qEnvironmentVariableIsEmpty("QT_RELY_ON_NET_WORKAREA_ATOM"); - bool isMultiHeadSystem = virtualSiblings().length() > 1; + bool isMultiHeadSystem = virtualSiblings().size() > 1; bool useScreenGeometry = isMultiHeadSystem && !enforceNetWorkarea; return useScreenGeometry ? m_geometry : m_availableGeometry; } @@ -1095,11 +1095,11 @@ QByteArray QXcbScreen::getEdid() const return result; // Try a bunch of atoms - result = getOutputProperty(atom(QXcbAtom::EDID)); + result = getOutputProperty(atom(QXcbAtom::AtomEDID)); if (result.isEmpty()) - result = getOutputProperty(atom(QXcbAtom::EDID_DATA)); + result = getOutputProperty(atom(QXcbAtom::AtomEDID_DATA)); if (result.isEmpty()) - result = getOutputProperty(atom(QXcbAtom::XFree86_DDC_EDID1_RAWDATA)); + result = getOutputProperty(atom(QXcbAtom::AtomXFree86_DDC_EDID1_RAWDATA)); return result; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index ec305d5030..b4e28ab831 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -101,19 +101,19 @@ static void sm_setProperty(const QString &name, const QString &value) { QByteArray v = value.toUtf8(); SmPropValue prop; - prop.length = v.length(); + prop.length = v.size(); prop.value = (SmPointer) const_cast<char *>(v.constData()); sm_setProperty(name.toLatin1().data(), SmARRAY8, 1, &prop); } static void sm_setProperty(const QString &name, const QStringList &value) { - SmPropValue *prop = new SmPropValue[value.count()]; + SmPropValue *prop = new SmPropValue[value.size()]; int count = 0; QList<QByteArray> vl; vl.reserve(value.size()); for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) { - prop[count].length = (*it).length(); + prop[count].length = (*it).size(); vl.append((*it).toUtf8()); prop[count].value = (char*)vl.constLast().data(); ++count; diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index e184c07128..84d2d73f91 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -26,7 +26,7 @@ enum { QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection) { // Selection, tray atoms for GNOME, NET WM Specification - const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE); + const xcb_atom_t trayAtom = connection->atom(QXcbAtom::Atom_NET_SYSTEM_TRAY_OPCODE); if (!trayAtom) return nullptr; const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreenNumber()); @@ -113,7 +113,7 @@ xcb_visualid_t QXcbSystemTrayTracker::netSystemTrayVisual() if (m_trayWindow == XCB_WINDOW_NONE) return XCB_NONE; - xcb_atom_t tray_atom = m_connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_VISUAL); + xcb_atom_t tray_atom = m_connection->atom(QXcbAtom::Atom_NET_SYSTEM_TRAY_VISUAL); // Get the xcb property for the _NET_SYSTEM_TRAY_VISUAL atom auto systray_atom_reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, m_connection->xcb_connection(), diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index a37c03cc60..247178603a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -166,7 +166,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) tp.value = (uchar*)qcs.data(); tp.encoding = XA_STRING; tp.format = 8; - tp.nitems = qcs.length(); + tp.nitems = qcs.size(); free_prop = false; } return &tp; @@ -253,11 +253,6 @@ void QXcbWindow::create() return; } - QPlatformWindow::setGeometry(rect); - - if (platformScreen != currentScreen) - QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); - const QSize minimumSize = windowMinimumSize(); if (rect.width() > 0 || rect.height() > 0) { rect.setWidth(qBound(1, rect.width(), XCOORD_MAX)); @@ -269,6 +264,11 @@ void QXcbWindow::create() rect.setHeight(QHighDpi::toNativePixels(int(defaultWindowHeight), platformScreen->QPlatformScreen::screen())); } + QPlatformWindow::setGeometry(rect); + + if (platformScreen != currentScreen) + QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); + xcb_window_t xcb_parent_id = platformScreen->root(); if (parent()) { xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window(); @@ -358,20 +358,20 @@ void QXcbWindow::create() xcb_atom_t properties[5]; int propertyCount = 0; - properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW); - properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); - properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); + properties[propertyCount++] = atom(QXcbAtom::AtomWM_DELETE_WINDOW); + properties[propertyCount++] = atom(QXcbAtom::AtomWM_TAKE_FOCUS); + properties[propertyCount++] = atom(QXcbAtom::Atom_NET_WM_PING); if (connection()->hasXSync()) - properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); + properties[propertyCount++] = atom(QXcbAtom::Atom_NET_WM_SYNC_REQUEST); if (window()->flags() & Qt::WindowContextHelpButtonHint) - properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); + properties[propertyCount++] = atom(QXcbAtom::Atom_NET_WM_CONTEXT_HELP); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::WM_PROTOCOLS), + atom(QXcbAtom::AtomWM_PROTOCOLS), XCB_ATOM_ATOM, 32, propertyCount, @@ -382,7 +382,7 @@ void QXcbWindow::create() const QByteArray wmClass = QXcbIntegration::instance()->wmClass(); if (!wmClass.isEmpty()) { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, - m_window, atom(QXcbAtom::WM_CLASS), + m_window, atom(QXcbAtom::AtomWM_CLASS), XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData()); } @@ -393,7 +393,7 @@ void QXcbWindow::create() xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_SYNC_REQUEST_COUNTER), + atom(QXcbAtom::Atom_NET_WM_SYNC_REQUEST_COUNTER), XCB_ATOM_CARDINAL, 32, 1, @@ -403,13 +403,13 @@ void QXcbWindow::create() // set the PID to let the WM kill the application if unresponsive quint32 pid = getpid(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, + atom(QXcbAtom::Atom_NET_WM_PID), XCB_ATOM_CARDINAL, 32, 1, &pid); const QByteArray clientMachine = QSysInfo::machineHostName().toLocal8Bit(); if (!clientMachine.isEmpty()) { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::WM_CLIENT_MACHINE), XCB_ATOM_STRING, 8, + atom(QXcbAtom::AtomWM_CLIENT_MACHINE), XCB_ATOM_STRING, 8, clientMachine.size(), clientMachine.constData()); } @@ -423,14 +423,14 @@ void QXcbWindow::create() xcb_window_t leader = connection()->clientLeader(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, + atom(QXcbAtom::AtomWM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, 1, &leader); /* Add XEMBED info; this operation doesn't initiate the embedding. */ quint32 data[] = { XEMBED_VERSION, XEMBED_MAPPED }; xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_XEMBED_INFO), - atom(QXcbAtom::_XEMBED_INFO), + atom(QXcbAtom::Atom_XEMBED_INFO), + atom(QXcbAtom::Atom_XEMBED_INFO), 32, 2, (void *)data); if (connection()->hasXInput2()) @@ -492,7 +492,7 @@ void QXcbWindow::destroy() xcb_sync_destroy_counter(xcb_connection(), m_syncCounter); if (m_window) { if (m_netWmUserTimeWindow) { - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_USER_TIME_WINDOW)); // Some window managers, like metacity, do XSelectInput on the _NET_WM_USER_TIME_WINDOW window, // without trapping BadWindow (which crashes when the user time window is destroyed). connection()->sync(); @@ -561,9 +561,9 @@ void QXcbWindow::setGeometry(const QRect &rect) QMargins QXcbWindow::frameMargins() const { if (m_dirtyFrameMargins) { - if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_FRAME_EXTENTS))) { + if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::Atom_NET_FRAME_EXTENTS))) { auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, m_window, - atom(QXcbAtom::_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4); + atom(QXcbAtom::Atom_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4); if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 4) { quint32 *data = (quint32 *)xcb_get_property_value(reply.get()); // _NET_FRAME_EXTENTS format is left, right, top, bottom @@ -822,29 +822,29 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates() NetWmStates result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), - 0, m_window, atom(QXcbAtom::_NET_WM_STATE), + 0, m_window, atom(QXcbAtom::Atom_NET_WM_STATE), XCB_ATOM_ATOM, 0, 1024); if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { const xcb_atom_t *states = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get())); const xcb_atom_t *statesEnd = states + reply->length; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_ABOVE))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_ABOVE))) result |= NetWmStateAbove; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_BELOW))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_BELOW))) result |= NetWmStateBelow; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN))) result |= NetWmStateFullScreen; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ))) result |= NetWmStateMaximizedHorz; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT))) result |= NetWmStateMaximizedVert; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MODAL))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MODAL))) result |= NetWmStateModal; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_STAYS_ON_TOP))) result |= NetWmStateStaysOnTop; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_DEMANDS_ATTENTION))) result |= NetWmStateDemandsAttention; - if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_HIDDEN))) + if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_HIDDEN))) result |= NetWmStateHidden; } else { qCDebug(lcQpaXcb, "getting net wm state (%x), empty\n", m_window); @@ -959,13 +959,13 @@ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_MOTIF_WM_HINTS), - atom(QXcbAtom::_MOTIF_WM_HINTS), + atom(QXcbAtom::Atom_MOTIF_WM_HINTS), + atom(QXcbAtom::Atom_MOTIF_WM_HINTS), 32, 5, &mwmhints); } else { - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_MOTIF_WM_HINTS)); } } @@ -977,7 +977,7 @@ void QXcbWindow::setNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) event.format = 32; event.sequence = 0; event.window = m_window; - event.type = atom(QXcbAtom::_NET_WM_STATE); + event.type = atom(QXcbAtom::Atom_NET_WM_STATE); event.data.data32[0] = set ? 1 : 0; event.data.data32[1] = one; event.data.data32[2] = two; @@ -993,20 +993,20 @@ void QXcbWindow::setNetWmState(Qt::WindowStates state) { if ((m_windowState ^ state) & Qt::WindowMaximized) { setNetWmState(state & Qt::WindowMaximized, - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); } if ((m_windowState ^ state) & Qt::WindowFullScreen) - setNetWmState(state & Qt::WindowFullScreen, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + setNetWmState(state & Qt::WindowFullScreen, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); } void QXcbWindow::setNetWmState(Qt::WindowFlags flags) { setNetWmState(flags & Qt::WindowStaysOnTopHint, - atom(QXcbAtom::_NET_WM_STATE_ABOVE), - atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); - setNetWmState(flags & Qt::WindowStaysOnBottomHint, atom(QXcbAtom::_NET_WM_STATE_BELOW)); + atom(QXcbAtom::Atom_NET_WM_STATE_ABOVE), + atom(QXcbAtom::Atom_NET_WM_STATE_STAYS_ON_TOP)); + setNetWmState(flags & Qt::WindowStaysOnBottomHint, atom(QXcbAtom::Atom_NET_WM_STATE_BELOW)); } void QXcbWindow::setNetWmStateOnUnmappedWindow() @@ -1047,7 +1047,7 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow() QList<xcb_atom_t> atoms; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), - 0, m_window, atom(QXcbAtom::_NET_WM_STATE), + 0, m_window, atom(QXcbAtom::Atom_NET_WM_STATE), XCB_ATOM_ATOM, 0, 1024); if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM && reply->value_len > 0) { const xcb_atom_t *data = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get())); @@ -1055,31 +1055,31 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow() memcpy((void *)&atoms.first(), (void *)data, reply->value_len * sizeof(xcb_atom_t)); } - if (states & NetWmStateAbove && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_ABOVE))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_ABOVE)); - if (states & NetWmStateBelow && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_BELOW))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_BELOW)); - if (states & NetWmStateHidden && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_HIDDEN))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_HIDDEN)); - if (states & NetWmStateFullScreen && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); - if (states & NetWmStateMaximizedHorz && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)); - if (states & NetWmStateMaximizedVert && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); - if (states & NetWmStateModal && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MODAL))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MODAL)); - if (states & NetWmStateStaysOnTop && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); - if (states & NetWmStateDemandsAttention && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) - atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); + if (states & NetWmStateAbove && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_ABOVE))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_ABOVE)); + if (states & NetWmStateBelow && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_BELOW))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_BELOW)); + if (states & NetWmStateHidden && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_HIDDEN))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_HIDDEN)); + if (states & NetWmStateFullScreen && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); + if (states & NetWmStateMaximizedHorz && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ)); + if (states & NetWmStateMaximizedVert && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); + if (states & NetWmStateModal && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_MODAL))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_MODAL)); + if (states & NetWmStateStaysOnTop && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_STAYS_ON_TOP))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_STAYS_ON_TOP)); + if (states & NetWmStateDemandsAttention && !atoms.contains(atom(QXcbAtom::Atom_NET_WM_STATE_DEMANDS_ATTENTION))) + atoms.push_back(atom(QXcbAtom::Atom_NET_WM_STATE_DEMANDS_ATTENTION)); if (atoms.isEmpty()) { - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_STATE)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_STATE)); } else { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32, - atoms.count(), atoms.constData()); + atom(QXcbAtom::Atom_NET_WM_STATE), XCB_ATOM_ATOM, 32, + atoms.size(), atoms.constData()); } xcb_flush(xcb_connection()); } @@ -1094,10 +1094,10 @@ void QXcbWindow::setWindowState(Qt::WindowStates state) xcb_map_window(xcb_connection(), m_window); if (m_windowState & Qt::WindowMaximized) setNetWmState(false, - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); if (m_windowState & Qt::WindowFullScreen) - setNetWmState(false, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + setNetWmState(false, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); // set new state if (state & Qt::WindowMinimized) { @@ -1108,7 +1108,7 @@ void QXcbWindow::setWindowState(Qt::WindowStates state) event.format = 32; event.sequence = 0; event.window = m_window; - event.type = atom(QXcbAtom::WM_CHANGE_STATE); + event.type = atom(QXcbAtom::AtomWM_CHANGE_STATE); event.data.data32[0] = XCB_ICCCM_WM_STATE_ICONIC; event.data.data32[1] = 0; event.data.data32[2] = 0; @@ -1123,10 +1123,10 @@ void QXcbWindow::setWindowState(Qt::WindowStates state) } if (state & Qt::WindowMaximized) setNetWmState(true, - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), - atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), + atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); if (state & Qt::WindowFullScreen) - setNetWmState(true, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + setNetWmState(true, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); setNetWmState(state); @@ -1153,7 +1153,7 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) if (timestamp != 0) connection()->setNetWmUserTime(timestamp); - const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); + const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::Atom_NET_WM_USER_TIME_WINDOW)); if (m_netWmUserTimeWindow || isSupportedByWM) { if (!m_netWmUserTimeWindow) { m_netWmUserTimeWindow = xcb_generate_id(xcb_connection()); @@ -1168,9 +1168,9 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) 0, // value mask nullptr); // value list wid = m_netWmUserTimeWindow; - xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), + xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::Atom_NET_WM_USER_TIME_WINDOW), XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_USER_TIME)); QXcbWindow::setWindowTitle(connection(), m_netWmUserTimeWindow, QStringLiteral("Qt NET_WM User Time Window")); @@ -1178,14 +1178,14 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) } else if (!isSupportedByWM) { // WM no longer supports it, then we should remove the // _NET_WM_USER_TIME_WINDOW atom. - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_USER_TIME_WINDOW)); xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow); m_netWmUserTimeWindow = XCB_NONE; } else { wid = m_netWmUserTimeWindow; } } - xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::_NET_WM_USER_TIME), + xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::Atom_NET_WM_USER_TIME), XCB_ATOM_CARDINAL, 32, 1, ×tamp); } @@ -1260,10 +1260,10 @@ void QXcbWindow::setWindowIconText(const QString &title) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_ICON_NAME), - atom(QXcbAtom::UTF8_STRING), + atom(QXcbAtom::Atom_NET_WM_ICON_NAME), + atom(QXcbAtom::AtomUTF8_STRING), 8, - ba.length(), + ba.size(), ba.constData()); } @@ -1295,23 +1295,24 @@ void QXcbWindow::setWindowIcon(const QIcon &icon) if (!icon_data.isEmpty()) { // Ignore icon exceeding maximum xcb request length - if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) { - qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.", - icon_data.size(), xcb_get_maximum_request_length(xcb_connection())); + if (quint64(icon_data.size()) > quint64(xcb_get_maximum_request_length(xcb_connection()))) { + qWarning() << "Ignoring window icon" << icon_data.size() + << "exceeds maximum xcb request length" + << xcb_get_maximum_request_length(xcb_connection()); return; } xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_ICON), - atom(QXcbAtom::CARDINAL), + atom(QXcbAtom::Atom_NET_WM_ICON), + atom(QXcbAtom::AtomCARDINAL), 32, icon_data.size(), (unsigned char *) icon_data.data()); } else { xcb_delete_property(xcb_connection(), m_window, - atom(QXcbAtom::_NET_WM_ICON)); + atom(QXcbAtom::Atom_NET_WM_ICON)); } } @@ -1398,14 +1399,14 @@ void QXcbWindow::requestActivateWindow() if (window()->isTopLevel() && !(window()->flags() & Qt::X11BypassWindowManagerHint) && (!focusWindow || !window()->isAncestorOf(focusWindow)) - && connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_ACTIVE_WINDOW))) { + && connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW))) { xcb_client_message_event_t event; event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; event.sequence = 0; event.window = m_window; - event.type = atom(QXcbAtom::_NET_ACTIVE_WINDOW); + event.type = atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW); event.data.data32[0] = 1; event.data.data32[1] = connection()->time(); event.data.data32[2] = focusWindow ? focusWindow->winId() : XCB_NONE; @@ -1432,7 +1433,7 @@ QXcbWindow::WindowTypes QXcbWindow::wmWindowTypes() const WindowTypes result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), - 0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), + 0, m_window, atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 0, 1024); if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { const xcb_atom_t *types = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get())); @@ -1440,49 +1441,49 @@ QXcbWindow::WindowTypes QXcbWindow::wmWindowTypes() const for (; types != types_end; types++) { QXcbAtom::Atom type = connection()->qatom(*types); switch (type) { - case QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NORMAL: result |= WindowType::Normal; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DESKTOP: result |= WindowType::Desktop; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DOCK: result |= WindowType::Dock; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_TOOLBAR: result |= WindowType::Toolbar; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_MENU: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_MENU: result |= WindowType::Menu; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_UTILITY: result |= WindowType::Utility; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_SPLASH: result |= WindowType::Splash; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DIALOG: result |= WindowType::Dialog; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DROPDOWN_MENU: result |= WindowType::DropDownMenu; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_POPUP_MENU: result |= WindowType::PopupMenu; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_TOOLTIP: result |= WindowType::Tooltip; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NOTIFICATION: result |= WindowType::Notification; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_COMBO: result |= WindowType::Combo; break; - case QXcbAtom::_NET_WM_WINDOW_TYPE_DND: + case QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DND: result |= WindowType::Dnd; break; - case QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE: + case QXcbAtom::Atom_KDE_NET_WM_WINDOW_TYPE_OVERRIDE: result |= WindowType::KdeOverride; break; default: @@ -1499,41 +1500,41 @@ void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags) // manual selection 1 (these are never set by Qt and take precedence) if (types & WindowType::Normal) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NORMAL)); if (types & WindowType::Desktop) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DESKTOP)); if (types & WindowType::Dock) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DOCK)); if (types & WindowType::Notification) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NOTIFICATION)); // manual selection 2 (Qt uses these during auto selection); if (types & WindowType::Utility) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_UTILITY)); if (types & WindowType::Splash) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_SPLASH)); if (types & WindowType::Dialog) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DIALOG)); if (types & WindowType::Tooltip) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_TOOLTIP)); if (types & WindowType::KdeOverride) - atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); + atoms.append(atom(QXcbAtom::Atom_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); // manual selection 3 (these can be set by Qt, but don't have a // corresponding Qt::WindowType). note that order of the *MENU // atoms is important if (types & WindowType::Menu) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_MENU)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_MENU)); if (types & WindowType::DropDownMenu) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)); if (types & WindowType::PopupMenu) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_POPUP_MENU)); if (types & WindowType::Toolbar) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_TOOLBAR)); if (types & WindowType::Combo) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_COMBO)); if (types & WindowType::Dnd) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DND)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DND)); // automatic selection Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); @@ -1541,20 +1542,20 @@ void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags) case Qt::Dialog: case Qt::Sheet: if (!(types & WindowType::Dialog)) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_DIALOG)); break; case Qt::Tool: case Qt::Drawer: if (!(types & WindowType::Utility)) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_UTILITY)); break; case Qt::ToolTip: if (!(types & WindowType::Tooltip)) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_TOOLTIP)); break; case Qt::SplashScreen: if (!(types & WindowType::Splash)) - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_SPLASH)); break; default: break; @@ -1562,20 +1563,20 @@ void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags) if ((flags & Qt::FramelessWindowHint) && !(types & WindowType::KdeOverride)) { // override netwm type - quick and easy for KDE noborder - atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); + atoms.append(atom(QXcbAtom::Atom_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); } - if (atoms.size() == 1 && atoms.first() == atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)) + if (atoms.size() == 1 && atoms.first() == atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NORMAL)) atoms.clear(); else - atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); + atoms.append(atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NORMAL)); if (atoms.isEmpty()) { - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE)); + xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE)); } else { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, - atoms.count(), atoms.constData()); + atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, + atoms.size(), atoms.constData()); } xcb_flush(xcb_connection()); } @@ -1584,7 +1585,7 @@ void QXcbWindow::setWindowRole(const QString &role) { QByteArray roleData = role.toLatin1(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8, + atom(QXcbAtom::AtomWM_WINDOW_ROLE), XCB_ATOM_STRING, 8, roleData.size(), roleData.constData()); } @@ -1643,15 +1644,15 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even if (event->format != 32) return; - if (event->type == atom(QXcbAtom::WM_PROTOCOLS)) { + if (event->type == atom(QXcbAtom::AtomWM_PROTOCOLS)) { xcb_atom_t protocolAtom = event->data.data32[0]; - if (protocolAtom == atom(QXcbAtom::WM_DELETE_WINDOW)) { + if (protocolAtom == atom(QXcbAtom::AtomWM_DELETE_WINDOW)) { QWindowSystemInterface::handleCloseEvent(window()); - } else if (protocolAtom == atom(QXcbAtom::WM_TAKE_FOCUS)) { + } else if (protocolAtom == atom(QXcbAtom::AtomWM_TAKE_FOCUS)) { connection()->setTime(event->data.data32[1]); relayFocusToModalWindow(); return; - } else if (protocolAtom == atom(QXcbAtom::_NET_WM_PING)) { + } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_PING)) { if (event->window == xcbScreen()->root()) return; @@ -1664,14 +1665,14 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); xcb_flush(xcb_connection()); - } else if (protocolAtom == atom(QXcbAtom::_NET_WM_SYNC_REQUEST)) { + } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_SYNC_REQUEST)) { connection()->setTime(event->data.data32[1]); m_syncValue.lo = event->data.data32[2]; m_syncValue.hi = event->data.data32[3]; if (connection()->hasXSync()) m_syncState = SyncReceived; #ifndef QT_NO_WHATSTHIS - } else if (protocolAtom == atom(QXcbAtom::_NET_WM_CONTEXT_HELP)) { + } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_CONTEXT_HELP)) { QWindowSystemInterface::handleEnterWhatsThisEvent(); #endif } else { @@ -1679,29 +1680,29 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even connection()->atomName(protocolAtom).constData()); } #if QT_CONFIG(draganddrop) - } else if (event->type == atom(QXcbAtom::XdndEnter)) { + } else if (event->type == atom(QXcbAtom::AtomXdndEnter)) { connection()->drag()->handleEnter(this, event); - } else if (event->type == atom(QXcbAtom::XdndPosition)) { + } else if (event->type == atom(QXcbAtom::AtomXdndPosition)) { connection()->drag()->handlePosition(this, event); - } else if (event->type == atom(QXcbAtom::XdndLeave)) { + } else if (event->type == atom(QXcbAtom::AtomXdndLeave)) { connection()->drag()->handleLeave(this, event); - } else if (event->type == atom(QXcbAtom::XdndDrop)) { + } else if (event->type == atom(QXcbAtom::AtomXdndDrop)) { connection()->drag()->handleDrop(this, event); #endif - } else if (event->type == atom(QXcbAtom::_XEMBED)) { + } else if (event->type == atom(QXcbAtom::Atom_XEMBED)) { handleXEmbedMessage(event); - } else if (event->type == atom(QXcbAtom::_NET_ACTIVE_WINDOW)) { + } else if (event->type == atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW)) { doFocusIn(); - } else if (event->type == atom(QXcbAtom::MANAGER) - || event->type == atom(QXcbAtom::_NET_WM_STATE) - || event->type == atom(QXcbAtom::WM_CHANGE_STATE)) { + } else if (event->type == atom(QXcbAtom::AtomMANAGER) + || event->type == atom(QXcbAtom::Atom_NET_WM_STATE) + || event->type == atom(QXcbAtom::AtomWM_CHANGE_STATE)) { // Ignore _NET_WM_STATE, MANAGER which are relate to tray icons // and other messages. - } else if (event->type == atom(QXcbAtom::_COMPIZ_DECOR_PENDING) - || event->type == atom(QXcbAtom::_COMPIZ_DECOR_REQUEST) - || event->type == atom(QXcbAtom::_COMPIZ_DECOR_DELETE_PIXMAP) - || event->type == atom(QXcbAtom::_COMPIZ_TOOLKIT_ACTION) - || event->type == atom(QXcbAtom::_GTK_LOAD_ICONTHEMES)) { + } else if (event->type == atom(QXcbAtom::Atom_COMPIZ_DECOR_PENDING) + || event->type == atom(QXcbAtom::Atom_COMPIZ_DECOR_REQUEST) + || event->type == atom(QXcbAtom::Atom_COMPIZ_DECOR_DELETE_PIXMAP) + || event->type == atom(QXcbAtom::Atom_COMPIZ_TOOLKIT_ACTION) + || event->type == atom(QXcbAtom::Atom_GTK_LOAD_ICONTHEMES)) { //silence the _COMPIZ and _GTK messages for now } else { qCWarning(lcQpaXcb) << "Unhandled client message: " << connection()->atomName(event->type); @@ -2133,17 +2134,17 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev 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::Atom_NET_WM_STATE) || event->atom == atom(QXcbAtom::AtomWM_STATE)) { if (propertyDeleted) return; Qt::WindowStates newState = Qt::WindowNoState; - if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'. + if (event->atom == atom(QXcbAtom::AtomWM_STATE)) { // WM_STATE: Quick check for 'Minimize'. auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), - 0, m_window, atom(QXcbAtom::WM_STATE), + 0, m_window, atom(QXcbAtom::AtomWM_STATE), XCB_ATOM_ANY, 0, 1024); - if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { + if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::AtomWM_STATE)) { const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get()); if (reply->length != 0) m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC @@ -2173,7 +2174,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev connection()->setMouseGrabber(nullptr); } return; - } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { + } else if (event->atom == atom(QXcbAtom::Atom_NET_FRAME_EXTENTS)) { m_dirtyFrameMargins = true; } } @@ -2312,7 +2313,7 @@ bool QXcbWindow::startSystemMove() bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int edges) { - const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); + const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE); if (!connection()->wmSupport()->isSupportedByWM(moveResize)) return false; @@ -2360,7 +2361,7 @@ static uint qtEdgesToXcbMoveResizeDirection(Qt::Edges edges) void QXcbWindow::doStartSystemMoveResize(const QPoint &globalPos, int edges) { qCDebug(lcQpaXInputDevices) << "triggered system move or resize via sending _NET_WM_MOVERESIZE client message"; - const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); + const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE); xcb_client_message_event_t xev; xev.response_type = XCB_CLIENT_MESSAGE; xev.type = moveResize; @@ -2393,7 +2394,7 @@ void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message, event.format = 32; event.sequence = 0; event.window = window; - event.type = atom(QXcbAtom::_XEMBED); + event.type = atom(QXcbAtom::Atom_XEMBED); event.data.data32[0] = connection()->time(); event.data.data32[1] = message; event.data.data32[2] = detail; @@ -2472,7 +2473,7 @@ void QXcbWindow::setOpacity(qreal level) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - atom(QXcbAtom::_NET_WM_WINDOW_OPACITY), + atom(QXcbAtom::Atom_NET_WM_WINDOW_OPACITY), XCB_ATOM_CARDINAL, 32, 1, @@ -2510,7 +2511,7 @@ void QXcbWindow::setAlertState(bool enabled) m_alertState = enabled; - setNetWmState(enabled, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); + setNetWmState(enabled, atom(QXcbAtom::Atom_NET_WM_STATE_DEMANDS_ATTENTION)); } uint QXcbWindow::visualId() const @@ -2544,10 +2545,10 @@ void QXcbWindow::setWindowTitle(const QXcbConnection *conn, xcb_window_t window, xcb_change_property(conn->xcb_connection(), XCB_PROP_MODE_REPLACE, window, - conn->atom(QXcbAtom::_NET_WM_NAME), - conn->atom(QXcbAtom::UTF8_STRING), + conn->atom(QXcbAtom::Atom_NET_WM_NAME), + conn->atom(QXcbAtom::AtomUTF8_STRING), 8, - ba.length(), + ba.size(), ba.constData()); #if QT_CONFIG(xcb_xlib) @@ -2561,9 +2562,9 @@ void QXcbWindow::setWindowTitle(const QXcbConnection *conn, xcb_window_t window, QString QXcbWindow::windowTitle(const QXcbConnection *conn, xcb_window_t window) { - const xcb_atom_t utf8Atom = conn->atom(QXcbAtom::UTF8_STRING); + const xcb_atom_t utf8Atom = conn->atom(QXcbAtom::AtomUTF8_STRING); auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, conn->xcb_connection(), - false, window, conn->atom(QXcbAtom::_NET_WM_NAME), + false, window, conn->atom(QXcbAtom::Atom_NET_WM_NAME), utf8Atom, 0, 1024); if (reply && reply->format == 8 && reply->type == utf8Atom) { const char *name = reinterpret_cast<const char *>(xcb_get_property_value(reply.get())); @@ -2571,7 +2572,7 @@ QString QXcbWindow::windowTitle(const QXcbConnection *conn, xcb_window_t window) } reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, conn->xcb_connection(), - false, window, conn->atom(QXcbAtom::WM_NAME), + false, window, conn->atom(QXcbAtom::AtomWM_NAME), XCB_ATOM_STRING, 0, 1024); if (reply && reply->format == 8 && reply->type == XCB_ATOM_STRING) { const char *name = reinterpret_cast<const char *>(xcb_get_property_value(reply.get())); diff --git a/src/plugins/platforms/xcb/qxcbwmsupport.cpp b/src/plugins/platforms/xcb/qxcbwmsupport.cpp index 50e85c0aa5..0e3c470c89 100644 --- a/src/plugins/platforms/xcb/qxcbwmsupport.cpp +++ b/src/plugins/platforms/xcb/qxcbwmsupport.cpp @@ -30,7 +30,7 @@ void QXcbWMSupport::updateNetWMAtoms() int offset = 0; int remaining = 0; do { - auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024); + auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, root, atom(QXcbAtom::Atom_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024); if (!reply) break; @@ -54,7 +54,7 @@ void QXcbWMSupport::updateVirtualRoots() { net_virtual_roots.clear(); - if (!isSupportedByWM(atom(QXcbAtom::_NET_VIRTUAL_ROOTS))) + if (!isSupportedByWM(atom(QXcbAtom::Atom_NET_VIRTUAL_ROOTS))) return; xcb_window_t root = connection()->primaryScreen()->root(); @@ -62,7 +62,7 @@ void QXcbWMSupport::updateVirtualRoots() int remaining = 0; do { auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), - false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), XCB_ATOM_WINDOW, offset, 1024); + false, root, atom(QXcbAtom::Atom_NET_VIRTUAL_ROOTS), XCB_ATOM_WINDOW, offset, 1024); if (!reply) break; diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 62fd13e5b9..6b62864add 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -68,7 +68,7 @@ public: int offset = 0; QByteArray settings; - xcb_atom_t _xsettings_atom = screen->connection()->atom(QXcbAtom::_XSETTINGS_SETTINGS); + xcb_atom_t _xsettings_atom = screen->connection()->atom(QXcbAtom::Atom_XSETTINGS_SETTINGS); while (1) { auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, screen->xcb_connection(), @@ -104,7 +104,7 @@ public: void populateSettings(const QByteArray &xSettings) { - if (xSettings.length() < 12) + if (xSettings.size() < 12) return; char byteOrder = xSettings.at(0); if (byteOrder != XCB_IMAGE_ORDER_LSB_FIRST && byteOrder != XCB_IMAGE_ORDER_MSB_FIRST) { @@ -192,7 +192,7 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen) auto atom_reply = Q_XCB_REPLY(xcb_intern_atom, screen->xcb_connection(), true, - settings_atom_for_screen.length(), + settings_atom_for_screen.size(), settings_atom_for_screen.constData()); if (!atom_reply) return; |