From b5e8e3511e1df0592b3b1831325d8dcf3407d6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 16 Oct 2015 09:08:02 +0200 Subject: [PATCH] Track whether Client is in moveResizeMode in AbstractClient Variable moveResizeMode replaced by protected methods isMoveResize() and setMoveResize(). --- abstract_client.h | 17 +++++++++++++++++ client.cpp | 19 +++++++++---------- client.h | 5 ++--- events.cpp | 8 ++++---- geometry.cpp | 10 +++++----- useractions.cpp | 4 ++-- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/abstract_client.h b/abstract_client.h index ff264d8352..fada5870f3 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -599,6 +599,19 @@ protected: **/ virtual void updateTabGroupStates(TabGroup::States states); + /** + * @returns whether the Client is currently in move resize mode + **/ + bool isMoveResize() const { + return m_moveResize.enabled; + } + /** + * Sets whether the Client is in move resize mode to @p enabled. + **/ + void setMoveResize(bool enabled) { + m_moveResize.enabled = enabled; + } + private: void handlePaletteChange(); QSharedPointer m_tabBoxClient; @@ -644,6 +657,10 @@ private: friend class GeometryUpdatesBlocker; QRect m_visibleRectBeforeGeometryUpdate; QRect m_geometryBeforeUpdateBlocking; + + struct { + bool enabled = false; + } m_moveResize; }; /** diff --git a/client.cpp b/client.cpp index 7415001b2a..1ae4ccefa8 100644 --- a/client.cpp +++ b/client.cpp @@ -142,7 +142,6 @@ Client::Client() mode = PositionCenter; buttonDown = false; - moveResizeMode = false; info = NULL; @@ -192,7 +191,7 @@ Client::~Client() //SWrapper::Client::clientRelease(this); if (syncRequest.alarm != XCB_NONE) xcb_sync_destroy_alarm(connection(), syncRequest.alarm); - assert(!moveResizeMode); + assert(!isMoveResize()); assert(m_client == XCB_WINDOW_NONE); assert(m_wrapper == XCB_WINDOW_NONE); //assert( frameId() == None ); @@ -221,13 +220,13 @@ void Client::releaseWindow(bool on_shutdown) if (!on_shutdown) { del = Deleted::create(this); } - if (moveResizeMode) + if (isMoveResize()) emit clientFinishUserMovedResized(this); emit windowClosed(this, del); finishCompositing(); RuleBook::self()->discardUsed(this, true); // Remove ForceTemporarily rules StackingUpdatesBlocker blocker(workspace()); - if (moveResizeMode) + if (isMoveResize()) leaveMoveResize(); finishWindowRules(); blockGeometryUpdates(); @@ -289,13 +288,13 @@ void Client::destroyClient() deleting = true; destroyWindowManagementInterface(); Deleted* del = Deleted::create(this); - if (moveResizeMode) + if (isMoveResize()) emit clientFinishUserMovedResized(this); emit windowClosed(this, del); finishCompositing(ReleaseReason::Destroyed); RuleBook::self()->discardUsed(this, true); // Remove ForceTemporarily rules StackingUpdatesBlocker blocker(workspace()); - if (moveResizeMode) + if (isMoveResize()) leaveMoveResize(); finishWindowRules(); blockGeometryUpdates(); @@ -1648,7 +1647,7 @@ void Client::dontMoveResize() { buttonDown = false; stopDelayedMoveResize(); - if (moveResizeMode) + if (isMoveResize()) finishMoveResize(false); } @@ -1865,7 +1864,7 @@ void Client::updateCursor() c = Qt::SizeHorCursor; break; default: - if (moveResizeMode) + if (isMoveResize()) c = Qt::SizeAllCursor; else c = Qt::ArrowCursor; @@ -1878,7 +1877,7 @@ void Client::updateCursor() m_frame.defineCursor(nativeCursor); if (m_decoInputExtent.isValid()) m_decoInputExtent.defineCursor(nativeCursor); - if (moveResizeMode) { + if (isMoveResize()) { // changing window attributes doesn't change cursor if there's pointer grab active xcb_change_active_pointer_grab(connection(), nativeCursor, xTime(), 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); @@ -2274,7 +2273,7 @@ void Client::processDecorationButtonRelease(QMouseEvent *event) if (event->buttons() == Qt::NoButton) { buttonDown = false; stopDelayedMoveResize(); - if (moveResizeMode) { + if (isMoveResize()) { finishMoveResize(false); mode = mousePosition(); } diff --git a/client.h b/client.h index 579428d3ad..18ad88ac71 100644 --- a/client.h +++ b/client.h @@ -378,10 +378,10 @@ public: bool hasOffscreenXineramaStrut() const; bool isMove() const { - return moveResizeMode && mode == PositionCenter; + return isMoveResize() && mode == PositionCenter; } bool isResize() const { - return moveResizeMode && mode != PositionCenter; + return isMoveResize() && mode != PositionCenter; } // Decorations <-> Effects @@ -630,7 +630,6 @@ private: int m_activityUpdatesBlocked; bool m_blockedActivityUpdatesRequireTransients; bool buttonDown; - bool moveResizeMode; Xcb::Window m_moveResizeGrabWindow; bool move_resize_has_keyboard_grab; bool unrestrictedMoveResize; diff --git a/events.cpp b/events.cpp index 037ea1fa0e..bf63e1c8ba 100644 --- a/events.cpp +++ b/events.cpp @@ -997,7 +997,7 @@ void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e) cancelAutoRaise(); workspace()->cancelDelayFocus(); cancelShadeHoverTimer(); - if (shade_mode == ShadeHover && !moveResizeMode && !buttonDown) { + if (shade_mode == ShadeHover && !isMoveResize() && !buttonDown) { shadeHoverTimer = new QTimer(this); connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeUnhover())); shadeHoverTimer->setSingleShot(true); @@ -1305,7 +1305,7 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in if ((state & buttonMask) == 0) { buttonDown = false; stopDelayedMoveResize(); - if (moveResizeMode) { + if (isMoveResize()) { finishMoveResize(false); mode = mousePosition(); } @@ -1483,7 +1483,7 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction) { if (direction == NET::Move) performMouseCommand(Options::MouseMove, QPoint(x_root, y_root)); - else if (moveResizeMode && direction == NET::MoveResizeCancel) { + else if (isMoveResize() && direction == NET::MoveResizeCancel) { finishMoveResize(true); buttonDown = false; updateCursor(); @@ -1500,7 +1500,7 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction) }; if (!isResizable() || isShade()) return; - if (moveResizeMode) + if (isMoveResize()) finishMoveResize(false); buttonDown = true; moveOffset = QPoint(x_root - x(), y_root - y()); // map from global diff --git a/geometry.cpp b/geometry.cpp index f354ab1f53..8e504a3cdf 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1940,7 +1940,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force) } updateShape(); } else { - if (moveResizeMode) { + if (isMoveResize()) { if (compositing()) // Defer the X update until we leave this mode needsXWindowMove = true; else @@ -2606,7 +2606,7 @@ void Client::positionGeometryTip() bool Client::startMoveResize() { - assert(!moveResizeMode); + assert(!isMoveResize()); assert(QWidget::keyboardGrabber() == NULL); assert(QWidget::mouseGrabber() == NULL); stopDelayedMoveResize(); @@ -2638,7 +2638,7 @@ bool Client::startMoveResize() return false; } - moveResizeMode = true; + setMoveResize(true); workspace()->setClientIsMoving(this); if (mode != PositionCenter) { // means "isResize()" but moveResizeMode = true is set below @@ -2729,7 +2729,7 @@ void Client::leaveMoveResize() xcb_ungrab_pointer(connection(), xTime()); m_moveResizeGrabWindow.reset(); workspace()->setClientIsMoving(0); - moveResizeMode = false; + setMoveResize(false); if (syncRequest.counter == XCB_NONE) // don't forget to sanitize since the timeout will no more fire syncRequest.isPending = false; delete syncRequest.timeout; @@ -2845,7 +2845,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) || (mode != PositionCenter && (isShade() || !isResizable()))) return; - if (!moveResizeMode) { + if (!isMoveResize()) { QPoint p(QPoint(x/* - padding_left*/, y/* - padding_top*/) - moveOffset); if (p.manhattanLength() >= QApplication::startDragDistance()) { if (!startMoveResize()) { diff --git a/useractions.cpp b/useractions.cpp index 363ad36ab0..d0145a8a97 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -1218,7 +1218,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl case Options::MouseUnrestrictedMove: { if (!isMovableAcrossScreens()) break; - if (moveResizeMode) + if (isMoveResize()) finishMoveResize(false); mode = PositionCenter; buttonDown = true; @@ -1235,7 +1235,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl case Options::MouseUnrestrictedResize: { if (!isResizable() || isShade()) break; - if (moveResizeMode) + if (isMoveResize()) finishMoveResize(false); buttonDown = true; moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global