From eedbde464e736eab64b4cf213e814fa02e1b2a53 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 8 Oct 2022 13:48:54 +0300 Subject: [PATCH] utils: Drop updateXTime() --- autotests/test_x11_timestamp_update.cpp | 8 ++++---- src/activation.cpp | 6 +++--- src/events.cpp | 8 ++++---- src/netinfo.cpp | 2 +- src/screenedge.cpp | 2 +- src/tabbox/tabbox.cpp | 4 ++-- src/utils/common.cpp | 10 ---------- src/utils/common.h | 1 - src/workspace.cpp | 2 +- src/x11window.cpp | 6 +++--- 10 files changed, 19 insertions(+), 30 deletions(-) diff --git a/autotests/test_x11_timestamp_update.cpp b/autotests/test_x11_timestamp_update.cpp index fcc8dec95b..0f9383cc0a 100644 --- a/autotests/test_x11_timestamp_update.cpp +++ b/autotests/test_x11_timestamp_update.cpp @@ -61,7 +61,7 @@ void X11TimestampUpdateTest::testGrabAfterServerTime() // this test tries to grab the X keyboard with a timestamp in future // that should fail, but after updating the X11 timestamp, it should // work again - KWin::updateXTime(); + KWin::kwinApp()->updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); @@ -72,7 +72,7 @@ void X11TimestampUpdateTest::testGrabAfterServerTime() QCOMPARE(KWin::grabXKeyboard(), false); // let's update timestamp, now it should work again - KWin::updateXTime(); + KWin::kwinApp()->updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); } @@ -84,7 +84,7 @@ void X11TimestampUpdateTest::testBeforeLastGrabTime() // timestamp it should work again // first set the grab timestamp - KWin::updateXTime(); + KWin::kwinApp()->updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); @@ -97,7 +97,7 @@ void X11TimestampUpdateTest::testBeforeLastGrabTime() QCOMPARE(KWin::grabXKeyboard(), false); // let's update timestamp, now it should work again - KWin::updateXTime(); + KWin::kwinApp()->updateXTime(); QVERIFY(KWin::xTime() >= timestamp); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); diff --git a/src/activation.cpp b/src/activation.cpp index 509b591bc2..530d3a9d2e 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -602,7 +602,7 @@ bool Workspace::restoreFocus() // a timestamp *sigh*, kwin's timestamp would be older than the timestamp // that was used by whoever caused the focus change, and therefore // the attempt to restore the focus would fail due to old timestamp - updateXTime(); + kwinApp()->updateXTime(); if (should_get_focus.count() > 0) { return requestFocus(should_get_focus.last()); } else if (m_lastActiveWindow) { @@ -636,7 +636,7 @@ void X11Window::updateUserTime(xcb_timestamp_t time) { // copied in Group::updateUserTime if (time == XCB_TIME_CURRENT_TIME) { - updateXTime(); + kwinApp()->updateXTime(); time = xTime(); } if (time != -1U @@ -930,7 +930,7 @@ void Group::updateUserTime(xcb_timestamp_t time) { // copy of X11Window::updateUserTime if (time == XCB_CURRENT_TIME) { - updateXTime(); + kwinApp()->updateXTime(); time = xTime(); } if (time != -1U diff --git a/src/events.cpp b/src/events.cpp index 1a7b79ffa0..2d0efcc108 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -179,7 +179,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) const auto *event = reinterpret_cast(e); if (event->parent == kwinApp()->x11RootWindow() && !QWidget::find(event->window) && !event->override_redirect) { // see comments for allowWindowActivation() - updateXTime(); + kwinApp()->updateXTime(); const xcb_timestamp_t t = xTime(); xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, event->window, atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 32, 1, &t); } @@ -195,7 +195,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) return true; } case XCB_MAP_REQUEST: { - updateXTime(); + kwinApp()->updateXTime(); const auto *event = reinterpret_cast(e); if (X11Window *window = findClient(Predicate::WindowMatch, event->window)) { @@ -281,7 +281,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) if (event->event == kwinApp()->x11RootWindow() && (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) { Xcb::CurrentInput currentInput; - updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp) + kwinApp()->updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp) // it seems we can "loose" focus reversions when the closing window hold a grab // => catch the typical pattern (though we don't want the focus on the root anyway) #348935 const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR; @@ -1251,7 +1251,7 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) // To not run into these errors we try to wait for the destroy notify. For this we // generate a round trip to the X server and wait a very short time span before // handling the release. - updateXTime(); + kwinApp()->updateXTime(); // using 1 msec to not just move it at the end of the event loop but add an very short // timespan to cover cases like unmap() followed by destroy(). The only other way to // ensure that the window is not destroyed when we do the release handling is to grab diff --git a/src/netinfo.cpp b/src/netinfo.cpp index 43e398466c..5957efdbb3 100644 --- a/src/netinfo.cpp +++ b/src/netinfo.cpp @@ -202,7 +202,7 @@ void RootInfo::moveResize(xcb_window_t w, int x_root, int y_root, unsigned long { X11Window *c = Workspace::self()->findClient(Predicate::WindowMatch, w); if (c) { - updateXTime(); // otherwise grabbing may have old timestamp - this message should include timestamp + kwinApp()->updateXTime(); // otherwise grabbing may have old timestamp - this message should include timestamp c->NETMoveResize(Xcb::fromXNative(x_root), Xcb::fromXNative(y_root), (Direction)direction); } } diff --git a/src/screenedge.cpp b/src/screenedge.cpp index b27376f19e..a612c9ce98 100644 --- a/src/screenedge.cpp +++ b/src/screenedge.cpp @@ -1514,7 +1514,7 @@ bool ScreenEdges::handleDndNotify(xcb_window_t window, const QPoint &point) continue; } if (edge->isReserved() && edge->window() == window) { - updateXTime(); + kwinApp()->updateXTime(); edge->check(point, QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC), true); return true; } diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp index 2c5c2f699a..76dd38eeda 100644 --- a/src/tabbox/tabbox.cpp +++ b/src/tabbox/tabbox.cpp @@ -1534,7 +1534,7 @@ bool TabBox::establishTabBoxGrab() m_forcedGlobalMouseGrab = true; return true; } - updateXTime(); + kwinApp()->updateXTime(); if (!grabXKeyboard()) { return false; } @@ -1558,7 +1558,7 @@ void TabBox::removeTabBoxGrab() m_forcedGlobalMouseGrab = false; return; } - updateXTime(); + kwinApp()->updateXTime(); ungrabXKeyboard(); Q_ASSERT(m_forcedGlobalMouseGrab); m_forcedGlobalMouseGrab = false; diff --git a/src/utils/common.cpp b/src/utils/common.cpp index f01738458e..11c26e8e24 100644 --- a/src/utils/common.cpp +++ b/src/utils/common.cpp @@ -24,11 +24,6 @@ #ifndef KCMRULES #include #include - -#include "main.h" - -#include - #endif Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg) @@ -71,11 +66,6 @@ StrutRect &StrutRect::operator=(const StrutRect &other) return *this; } -void updateXTime() -{ - kwinApp()->updateXTime(); -} - static int server_grab_count = 0; void grabXServer() diff --git a/src/utils/common.h b/src/utils/common.h index 0058d5971c..43ec0bdd93 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -115,7 +115,6 @@ enum class QuickTileFlag { }; Q_DECLARE_FLAGS(QuickTileMode, QuickTileFlag) -void KWIN_EXPORT updateXTime(); void KWIN_EXPORT grabXServer(); void KWIN_EXPORT ungrabXServer(); bool KWIN_EXPORT grabXKeyboard(xcb_window_t w = XCB_WINDOW_NONE); diff --git a/src/workspace.cpp b/src/workspace.cpp index 12f2e8f888..121e20ed2f 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -325,7 +325,7 @@ void Workspace::initializeX11() if (Xcb::Extensions::self()->isSyncAvailable()) { m_syncAlarmFilter.reset(new SyncAlarmX11Filter); } - updateXTime(); // Needed for proper initialization of user_time in Client ctor + kwinApp()->updateXTime(); // Needed for proper initialization of user_time in Client ctor const uint32_t nullFocusValues[] = {true}; m_nullFocus.reset(new Xcb::Window(QRect(-1, -1, 1, 1), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, nullFocusValues)); diff --git a/src/x11window.cpp b/src/x11window.cpp index e9675d1831..0f085bd76d 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -2038,7 +2038,7 @@ bool X11Window::takeFocus() demandAttention(false); // window cannot take input, at least withdraw urgency } if (info->supportsProtocol(NET::TakeFocusProtocol)) { - updateXTime(); + kwinApp()->updateXTime(); sendClientMessage(window(), atoms->wm_protocols, atoms->wm_take_focus); } workspace()->setShouldGetFocus(this); @@ -2378,7 +2378,7 @@ void X11Window::sendSyncRequest() m_syncRequest.value.hi++; } if (m_syncRequest.lastTimestamp >= xTime()) { - updateXTime(); + kwinApp()->updateXTime(); } // Send the message to client @@ -4656,7 +4656,7 @@ bool X11Window::doStartInteractiveMoveResize() m_moveResizeGrabWindow.create(Xcb::toXNative(r), XCB_WINDOW_CLASS_INPUT_ONLY, 0, nullptr, kwinApp()->x11RootWindow()); m_moveResizeGrabWindow.map(); m_moveResizeGrabWindow.raise(); - updateXTime(); + kwinApp()->updateXTime(); const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(kwinApp()->x11Connection(), false, m_moveResizeGrabWindow, XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursors::self()->mouse()->x11Cursor(cursor()), xTime());