Track whether Client is in moveResizeMode in AbstractClient

Variable moveResizeMode replaced by protected methods isMoveResize()
and setMoveResize().
This commit is contained in:
Martin Gräßlin 2015-10-16 09:08:02 +02:00
parent 75f3964db7
commit b5e8e3511e
6 changed files with 39 additions and 24 deletions

View file

@ -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<TabBox::TabBoxClientImpl> m_tabBoxClient;
@ -644,6 +657,10 @@ private:
friend class GeometryUpdatesBlocker;
QRect m_visibleRectBeforeGeometryUpdate;
QRect m_geometryBeforeUpdateBlocking;
struct {
bool enabled = false;
} m_moveResize;
};
/**

View file

@ -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();
}

View file

@ -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;

View file

@ -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

View file

@ -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()) {

View file

@ -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