From f4b02d5a8c7fdec8861ee91e93d158c1c44828a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 23 Oct 2015 13:33:18 +0200 Subject: [PATCH] Move handleMoveResize to AbstractClient Sync related code is split out into dedicated virtual methods so that Client can provide the X11 specific implementation. General handling, though is completely in AbstractClient. --- abstract_client.cpp | 9 +++++++++ abstract_client.h | 14 ++++++++++++++ client.h | 4 ++-- geometry.cpp | 47 ++++++++++++++++++++++++++++----------------- 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/abstract_client.cpp b/abstract_client.cpp index edf3c3004b..df24d87e68 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -1137,6 +1137,15 @@ void AbstractClient::doPerformMoveResize() { } +bool AbstractClient::isWaitingForMoveResizeSync() const +{ + return false; +} + +void AbstractClient::doResizeSync() +{ +} + void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot) { QuickTileMode mode = QuickTileNone; diff --git a/abstract_client.h b/abstract_client.h index 3b488f063a..ab38a388e8 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -730,6 +730,20 @@ protected: * activates quick tiling or maximization */ void checkQuickTilingMaximizationZones(int xroot, int yroot); + /** + * Whether a sync request is still pending. + * Default implementation returns @c false. + **/ + virtual bool isWaitingForMoveResizeSync() const; + /** + * Called during handling a resize. Implementing subclasses can use this + * method to perform windowing system specific syncing. + * + * Default implementation does nothing. + **/ + virtual void doResizeSync(); + void handleMoveResize(int x, int y, int x_root, int y_root); + void handleMoveResize(const QPoint &local, const QPoint &global); static bool haveResizeEffect() { return s_haveResizeEffect; diff --git a/client.h b/client.h index fdde6b88d1..b1d2df2781 100644 --- a/client.h +++ b/client.h @@ -469,6 +469,8 @@ protected: void doMove(int x, int y) override; bool doStartMoveResize() override; void doPerformMoveResize() override; + bool isWaitingForMoveResizeSync() const override; + void doResizeSync() override; private Q_SLOTS: void delayedSetShortcut(); @@ -544,8 +546,6 @@ private: void getSyncCounter(); void sendSyncRequest(); void leaveMoveResize() override; - void handleMoveResize(int x, int y, int x_root, int y_root); - void handleMoveResize(const QPoint &local, const QPoint &global); void positionGeometryTip() override; void grabButton(int mod); void ungrabButton(int mod); diff --git a/geometry.cpp b/geometry.cpp index f85beba2cf..4811686821 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2823,7 +2823,7 @@ void Client::updateMoveResize(const QPointF ¤tGlobalCursor) handleMoveResize(pos(), currentGlobalCursor.toPoint()); } -void Client::handleMoveResize(const QPoint &local, const QPoint &global) +void AbstractClient::handleMoveResize(const QPoint &local, const QPoint &global) { const QRect oldGeo = geometry(); handleMoveResize(local.x(), local.y(), global.x(), global.y()); @@ -2831,6 +2831,7 @@ void Client::handleMoveResize(const QPoint &local, const QPoint &global) if (quickTileMode() != QuickTileNone && oldGeo != geometry()) { GeometryUpdatesBlocker blocker(this); setQuickTileMode(QuickTileNone); + const QRect &geom_restore = geometryRestore(); setMoveOffset(QPoint(double(moveOffset().x()) / double(oldGeo.width()) * double(geom_restore.width()), double(moveOffset().y()) / double(oldGeo.height()) * double(geom_restore.height()))); if (rules()->checkMaximize(MaximizeRestore) == MaximizeRestore) @@ -2842,9 +2843,14 @@ void Client::handleMoveResize(const QPoint &local, const QPoint &global) } } -void Client::handleMoveResize(int x, int y, int x_root, int y_root) +bool Client::isWaitingForMoveResizeSync() const { - if (syncRequest.isPending && isResize()) + return syncRequest.isPending && isResize(); +} + +void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root) +{ + if (isWaitingForMoveResizeSync()) return; // we're still waiting for the client or the timeout const Position mode = moveResizePointerMode(); @@ -2866,7 +2872,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) } // ShadeHover or ShadeActive, ShadeNormal was already avoided above - if (mode != PositionCenter && shade_mode != ShadeNone) + if (mode != PositionCenter && shadeMode() != ShadeNone) setShade(ShadeNone); QPoint globalPos(x_root, y_root); @@ -3154,20 +3160,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) return; if (isResize() && !haveResizeEffect()) { - if (!syncRequest.timeout) { - syncRequest.timeout = new QTimer(this); - connect(syncRequest.timeout, &QTimer::timeout, this, &Client::performMoveResize); - syncRequest.timeout->setSingleShot(true); - } - if (syncRequest.counter != XCB_NONE) { - syncRequest.timeout->start(250); - sendSyncRequest(); - } else { // for clients not supporting the XSYNC protocol, we - syncRequest.isPending = true; // limit the resizes to 30Hz to take pointless load from X11 - syncRequest.timeout->start(33); // and the client, the mouse is still moved at full speed - } // and no human can control faster resizes anyway - const QRect &moveResizeGeom = moveResizeGeometry(); - m_client.setGeometry(0, 0, moveResizeGeom.width() - (borderLeft() + borderRight()), moveResizeGeom.height() - (borderTop() + borderBottom())); + doResizeSync(); } else performMoveResize(); @@ -3176,6 +3169,24 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) } } +void Client::doResizeSync() +{ + if (!syncRequest.timeout) { + syncRequest.timeout = new QTimer(this); + connect(syncRequest.timeout, &QTimer::timeout, this, &Client::performMoveResize); + syncRequest.timeout->setSingleShot(true); + } + if (syncRequest.counter != XCB_NONE) { + syncRequest.timeout->start(250); + sendSyncRequest(); + } else { // for clients not supporting the XSYNC protocol, we + syncRequest.isPending = true; // limit the resizes to 30Hz to take pointless load from X11 + syncRequest.timeout->start(33); // and the client, the mouse is still moved at full speed + } // and no human can control faster resizes anyway + const QRect &moveResizeGeom = moveResizeGeometry(); + m_client.setGeometry(0, 0, moveResizeGeom.width() - (borderLeft() + borderRight()), moveResizeGeom.height() - (borderTop() + borderBottom())); +} + void AbstractClient::performMoveResize() { const QRect &moveResizeGeom = moveResizeGeometry();