From 0af128039e10bd27ac8392d195d3b34f8b1459e7 Mon Sep 17 00:00:00 2001 From: Roland Pallai <dap78@magex.hu> Date: Fri, 27 Jan 2023 14:29:56 +0100 Subject: [PATCH 081/147] QXcbConnection::getTimestamp: do not return stale timestamp The problem is `PropertyNotify` event generated by `xcb_delete_property()` at return could be reported as an actual timestamp at next call due to a missing `state` filter. Because `PropertyNotify` is generated even if an unchanged property value is set we can get rid of this delete event easily. This issue causes observable problems in kwin_x11 (KDE project) too. Fixes: QTBUG-56595 Pick-to: 5.15 6.2 6.4 6.5 Change-Id: Ice6cfa934e3769d86e9f7264e369dc5918c8542a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> (cherry picked from commit 03ac8c7397b9f070a8ef5f33b4675411293b0723) --- src/plugins/platforms/xcb/qxcbatom.cpp | 2 ++ src/plugins/platforms/xcb/qxcbatom.h | 2 ++ src/plugins/platforms/xcb/qxcbconnection.cpp | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp index 780816605a..a769ddadbd 100644 --- a/src/plugins/platforms/xcb/qxcbatom.cpp +++ b/src/plugins/platforms/xcb/qxcbatom.cpp @@ -90,6 +90,8 @@ static const char *xcb_atomnames = { "_QT_CLOSE_CONNECTION\0" + "_QT_GET_TIMESTAMP\0" + "_MOTIF_WM_HINTS\0" "DTWM_IS_RUNNING\0" diff --git a/src/plugins/platforms/xcb/qxcbatom.h b/src/plugins/platforms/xcb/qxcbatom.h index 9cf93ec314..1ce6cca573 100644 --- a/src/plugins/platforms/xcb/qxcbatom.h +++ b/src/plugins/platforms/xcb/qxcbatom.h @@ -91,6 +91,8 @@ public: // Qt/XCB specific _QT_CLOSE_CONNECTION, + _QT_GET_TIMESTAMP, + _MOTIF_WM_HINTS, DTWM_IS_RUNNING, diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 533018f35b..631ade2ec7 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -804,8 +804,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::_QT_GET_TIMESTAMP); + xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, dummyAtom, XCB_ATOM_INTEGER, 32, 0, nullptr); connection()->flush(); @@ -837,8 +837,6 @@ xcb_timestamp_t QXcbConnection::getTimestamp() xcb_timestamp_t timestamp = pn->time; free(event); - xcb_delete_property(xcb_connection(), window, dummyAtom); - return timestamp; } -- 2.40.1