Move startMoveResize() to AbstractClient

The implementation calls a virtual doStartMoveResize() which allows
Client to do it's X11 specific tasks (creating moveResizeWindow, grabbing
input).

The base implementation is no longer virtual.
This commit is contained in:
Martin Gräßlin 2015-10-22 18:16:21 +02:00
parent 9e323227a1
commit c83f041005
4 changed files with 47 additions and 30 deletions

View file

@ -1124,9 +1124,9 @@ void AbstractClient::updateHaveResizeEffect()
s_haveResizeEffect = effects && static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Resize);
}
bool AbstractClient::startMoveResize()
bool AbstractClient::doStartMoveResize()
{
return false;
return true;
}
}

View file

@ -698,7 +698,16 @@ protected:
void updateCursor();
void startDelayedMoveResize();
void stopDelayedMoveResize();
virtual bool startMoveResize();
bool startMoveResize();
/**
* Called from @link startMoveResize.
*
* Implementing classes should return @c false if starting move resize should
* get aborted. In that case @link startMoveResize will also return @c false.
*
* Base implementation returns @c true.
**/
virtual bool doStartMoveResize();
void finishMoveResize(bool cancel);
/**
* Leaves the move resize mode.

View file

@ -468,6 +468,7 @@ protected:
void setGeometryRestore(const QRect &geo) override;
void updateTabGroupStates(TabGroup::States states) override;
void doMove(int x, int y) override;
bool doStartMoveResize() override;
private Q_SLOTS:
void delayedSetShortcut();
@ -543,7 +544,6 @@ private:
int checkShadeGeometry(int w, int h);
void getSyncCounter();
void sendSyncRequest();
bool startMoveResize() override;
void leaveMoveResize() override;
void handleMoveResize(int x, int y, int x_root, int y_root);
void handleMoveResize(const QPoint &local, const QPoint &global);

View file

@ -2605,7 +2605,7 @@ void Client::positionGeometryTip()
}
}
bool Client::startMoveResize()
bool AbstractClient::startMoveResize()
{
assert(!isMoveResize());
assert(QWidget::keyboardGrabber() == NULL);
@ -2615,6 +2615,39 @@ bool Client::startMoveResize()
return false; // popups have grab
if (isFullScreen() && (screens()->count() < 2 || !isMovableAcrossScreens()))
return false;
if (!doStartMoveResize()) {
return false;
}
setMoveResize(true);
workspace()->setClientIsMoving(this);
const Position mode = moveResizePointerMode();
if (mode != PositionCenter) { // means "isResize()" but moveResizeMode = true is set below
if (maximizeMode() == MaximizeFull) { // partial is cond. reset in finishMoveResize
setGeometryRestore(geometry()); // "restore" to current geometry
setMaximize(false, false);
}
}
if (quickTileMode() != QuickTileNone && mode != PositionCenter) { // Cannot use isResize() yet
// Exit quick tile mode when the user attempts to resize a tiled window
updateQuickTileMode(QuickTileNone); // Do so without restoring original geometry
setGeometryRestore(geometry());
emit quickTileModeChanged();
}
updateHaveResizeEffect();
updateInitialMoveResizeGeometry();
checkUnrestrictedMoveResize();
emit clientStartUserMovedResized(this);
if (ScreenEdges::self()->isDesktopSwitchingMovingClients())
ScreenEdges::self()->reserveDesktopSwitching(true, Qt::Vertical|Qt::Horizontal);
return true;
}
bool Client::doStartMoveResize()
{
bool has_grab = false;
// This reportedly improves smoothness of the moveresize operation,
// something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug*
@ -2638,31 +2671,6 @@ bool Client::startMoveResize()
m_moveResizeGrabWindow.reset();
return false;
}
setMoveResize(true);
workspace()->setClientIsMoving(this);
const Position mode = moveResizePointerMode();
if (mode != PositionCenter) { // means "isResize()" but moveResizeMode = true is set below
if (maximizeMode() == MaximizeFull) { // partial is cond. reset in finishMoveResize
geom_restore = geometry(); // "restore" to current geometry
setMaximize(false, false);
}
}
if (quickTileMode() != QuickTileNone && mode != PositionCenter) { // Cannot use isResize() yet
// Exit quick tile mode when the user attempts to resize a tiled window
updateQuickTileMode(QuickTileNone); // Do so without restoring original geometry
geom_restore = geometry();
emit quickTileModeChanged();
}
updateHaveResizeEffect();
updateInitialMoveResizeGeometry();
checkUnrestrictedMoveResize();
emit clientStartUserMovedResized(this);
if (ScreenEdges::self()->isDesktopSwitchingMovingClients())
ScreenEdges::self()->reserveDesktopSwitching(true, Qt::Vertical|Qt::Horizontal);
return true;
}