From 3c2e1a71c403b35e689b55b8534bafb1e3011b73 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 15 May 2021 13:56:35 +0300 Subject: [PATCH] Unvirtualize Toplevel::bufferGeometry() This makes the implementation of the buffer geometry consistent with the frame geometry and the client geometry and removes a virtual method call from a few hot paths. --- src/deleted.cpp | 6 ------ src/deleted.h | 2 -- src/events.cpp | 1 + src/internal_client.cpp | 6 +----- src/internal_client.h | 1 - src/toplevel.cpp | 1 + src/toplevel.h | 8 +++++++- src/unmanaged.cpp | 6 +----- src/unmanaged.h | 1 - src/waylandclient.cpp | 5 ----- src/waylandclient.h | 2 -- src/x11client.cpp | 5 ----- src/x11client.h | 2 -- 13 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/deleted.cpp b/src/deleted.cpp index 5a4b7ec8bf..f04a18fe32 100644 --- a/src/deleted.cpp +++ b/src/deleted.cpp @@ -71,7 +71,6 @@ void Deleted::copyToDeleted(Toplevel* c) { Q_ASSERT(dynamic_cast< Deleted* >(c) == nullptr); Toplevel::copyToDeleted(c); - m_bufferGeometry = c->bufferGeometry(); m_frameMargins = c->frameMargins(); m_bufferScale = c->bufferScale(); desk = c->desktop(); @@ -135,11 +134,6 @@ void Deleted::unrefWindow() deleteLater(); } -QRect Deleted::bufferGeometry() const -{ - return m_bufferGeometry; -} - QMargins Deleted::frameMargins() const { return m_frameMargins; diff --git a/src/deleted.h b/src/deleted.h index d0e16d1681..215bb8a674 100644 --- a/src/deleted.h +++ b/src/deleted.h @@ -32,7 +32,6 @@ public: void refWindow(); void unrefWindow(); void discard(); - QRect bufferGeometry() const override; QMargins frameMargins() const override; qreal bufferScale() const override; int desktop() const override; @@ -112,7 +111,6 @@ private: void copyToDeleted(Toplevel* c); ~Deleted() override; // deleted only using unrefWindow() - QRect m_bufferGeometry; QMargins m_frameMargins; int delete_refcount; diff --git a/src/events.cpp b/src/events.cpp index 20380e7595..756fc38923 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -1256,6 +1256,7 @@ void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e) QRect old = m_frameGeometry; m_clientGeometry = newgeom; m_frameGeometry = newgeom; + m_bufferGeometry = newgeom; emit bufferGeometryChanged(this, old); emit clientGeometryChanged(this, old); emit frameGeometryChanged(this, old); diff --git a/src/internal_client.cpp b/src/internal_client.cpp index 35237fffef..d2a003eb90 100644 --- a/src/internal_client.cpp +++ b/src/internal_client.cpp @@ -102,11 +102,6 @@ bool InternalClient::eventFilter(QObject *watched, QEvent *event) return false; } -QRect InternalClient::bufferGeometry() const -{ - return m_clientGeometry; -} - qreal InternalClient::bufferScale() const { if (m_internalWindow) { @@ -477,6 +472,7 @@ void InternalClient::commitGeometry(const QRect &rect) m_clientGeometry = frameRectToClientRect(rect); m_frameGeometry = rect; + m_bufferGeometry = m_clientGeometry; addWorkspaceRepaint(visibleGeometry()); updateGeometryBeforeUpdateBlocking(); diff --git a/src/internal_client.h b/src/internal_client.h index 948c130f41..e12be08ef4 100644 --- a/src/internal_client.h +++ b/src/internal_client.h @@ -24,7 +24,6 @@ public: bool eventFilter(QObject *watched, QEvent *event) override; - QRect bufferGeometry() const override; qreal bufferScale() const override; QString captionNormal() const override; QString captionSuffix() const override; diff --git a/src/toplevel.cpp b/src/toplevel.cpp index 6d08ffe7b4..90af9bcd2e 100644 --- a/src/toplevel.cpp +++ b/src/toplevel.cpp @@ -104,6 +104,7 @@ void Toplevel::detectShape(xcb_window_t id) void Toplevel::copyToDeleted(Toplevel* c) { m_internalId = c->internalId(); + m_bufferGeometry = c->m_bufferGeometry; m_frameGeometry = c->m_frameGeometry; m_clientGeometry = c->m_clientGeometry; m_visual = c->m_visual; diff --git a/src/toplevel.h b/src/toplevel.h index 3a4bc3dd23..076fabd362 100644 --- a/src/toplevel.h +++ b/src/toplevel.h @@ -306,7 +306,7 @@ public: * For Wayland clients, this method returns rectangle that the main surface * occupies on the screen, in global screen coordinates. */ - virtual QRect bufferGeometry() const = 0; + QRect bufferGeometry() const; /** * Returns the geometry of the Toplevel, excluding invisible portions, e.g. * server-side and client-side drop shadows, etc. @@ -701,6 +701,7 @@ protected: void setDepth(int depth); QRect m_frameGeometry; QRect m_clientGeometry; + QRect m_bufferGeometry; xcb_visualid_t m_visual; int bit_depth; NETWinInfo* info; @@ -744,6 +745,11 @@ inline void Toplevel::setWindowHandles(xcb_window_t w) m_client.reset(w, false); } +inline QRect Toplevel::bufferGeometry() const +{ + return m_bufferGeometry; +} + inline QRect Toplevel::clientGeometry() const { return m_clientGeometry; diff --git a/src/unmanaged.cpp b/src/unmanaged.cpp index f168475e9c..d5fe9f921a 100644 --- a/src/unmanaged.cpp +++ b/src/unmanaged.cpp @@ -98,6 +98,7 @@ bool Unmanaged::track(xcb_window_t w) } setWindowHandles(w); // the window is also the frame Xcb::selectInput(w, attr->your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE); + m_bufferGeometry = geo.rect(); m_frameGeometry = geo.rect(); m_clientGeometry = geo.rect(); checkScreen(); @@ -160,11 +161,6 @@ bool Unmanaged::hasScheduledRelease() const return m_scheduledRelease; } -QRect Unmanaged::bufferGeometry() const -{ - return m_frameGeometry; -} - int Unmanaged::desktop() const { return NET::OnAllDesktops; // TODO for some window types should be the current desktop? diff --git a/src/unmanaged.h b/src/unmanaged.h index 8ad4a99834..94cb2ee314 100644 --- a/src/unmanaged.h +++ b/src/unmanaged.h @@ -26,7 +26,6 @@ public: bool track(xcb_window_t w); bool hasScheduledRelease() const; static void deleteUnmanaged(Unmanaged* c); - QRect bufferGeometry() const override; int desktop() const override; QStringList activities() const override; QVector desktops() const override; diff --git a/src/waylandclient.cpp b/src/waylandclient.cpp index ddbe79c2c8..9c799c30f1 100644 --- a/src/waylandclient.cpp +++ b/src/waylandclient.cpp @@ -329,11 +329,6 @@ QRect WaylandClient::requestedClientGeometry() const return m_requestedClientGeometry; } -QRect WaylandClient::bufferGeometry() const -{ - return m_bufferGeometry; -} - QSize WaylandClient::requestedClientSize() const { return requestedClientGeometry().size(); diff --git a/src/waylandclient.h b/src/waylandclient.h index 8339c33392..308656f101 100644 --- a/src/waylandclient.h +++ b/src/waylandclient.h @@ -23,7 +23,6 @@ class WaylandClient : public AbstractClient public: WaylandClient(KWaylandServer::SurfaceInterface *surface); - QRect bufferGeometry() const override; QString captionNormal() const override; QString captionSuffix() const override; QPoint clientContentPos() const override; @@ -76,7 +75,6 @@ private: QString m_captionNormal; QString m_captionSuffix; QRect m_requestedFrameGeometry; - QRect m_bufferGeometry; QRect m_requestedClientGeometry; SyncMode m_positionSyncMode = SyncMode::Sync; SyncMode m_sizeSyncMode = SyncMode::Sync; diff --git a/src/x11client.cpp b/src/x11client.cpp index 3620b6e12b..afcbf09361 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -2494,11 +2494,6 @@ QRect X11Client::inputGeometry() const return m_bufferGeometry; } -QRect X11Client::bufferGeometry() const -{ - return m_bufferGeometry; -} - QPoint X11Client::framePosToClientPos(const QPoint &point) const { int x = point.x(); diff --git a/src/x11client.h b/src/x11client.h index f34d2bd4f6..c9a4eb6331 100644 --- a/src/x11client.h +++ b/src/x11client.h @@ -81,7 +81,6 @@ public: xcb_window_t frameId() const override; QRect inputGeometry() const override; - QRect bufferGeometry() const override; QPoint framePosToClientPos(const QPoint &point) const override; QPoint clientPosToFramePos(const QPoint &point) const override; @@ -475,7 +474,6 @@ private: } m_fullscreenMode; MaximizeMode max_mode; - QRect m_bufferGeometry; xcb_colormap_t m_colormap; QString cap_normal, cap_iconic, cap_suffix; Group* in_group;