Commit 8a3be2ba authored by Martin Flöser's avatar Martin Flöser

Move the Position mode from Client to AbstractClient

parent c3f14521
......@@ -648,6 +648,12 @@ protected:
void setMoveResizeGeometry(const QRect &geo) {
m_moveResize.geometry = geo;
}
Position moveResizePointerMode() const {
return m_moveResize.pointer;
}
void setMoveResizePointerMode(Position mode) {
m_moveResize.pointer = mode;
}
private:
void handlePaletteChange();
......@@ -702,6 +708,7 @@ private:
QPoint invertedOffset;
QRect initialGeometry;
QRect geometry;
Position pointer = PositionCenter;
} m_moveResize;
};
......
......@@ -140,7 +140,6 @@ Client::Client()
// Set the initial mapping state
mapping_state = Withdrawn;
mode = PositionCenter;
buttonDown = false;
info = NULL;
......@@ -1842,7 +1841,7 @@ bool Client::wantsInput() const
*/
void Client::updateCursor()
{
Position m = mode;
Position m = moveResizePointerMode();
if (!isResizable() || isShade())
m = PositionCenter;
Qt::CursorShape c = Qt::ArrowCursor;
......@@ -2275,7 +2274,7 @@ void Client::processDecorationButtonRelease(QMouseEvent *event)
stopDelayedMoveResize();
if (isMoveResize()) {
finishMoveResize(false);
mode = mousePosition();
setMoveResizePointerMode(mousePosition());
}
updateCursor();
}
......@@ -2288,8 +2287,8 @@ void Client::processDecorationMove()
}
// TODO: handle modifiers
Position newmode = mousePosition();
if (newmode != mode) {
mode = newmode;
if (newmode != moveResizePointerMode()) {
setMoveResizePointerMode(newmode);
updateCursor();
}
}
......
......@@ -378,10 +378,10 @@ public:
bool hasOffscreenXineramaStrut() const;
bool isMove() const {
return isMoveResize() && mode == PositionCenter;
return isMoveResize() && moveResizePointerMode() == PositionCenter;
}
bool isResize() const {
return isMoveResize() && mode != PositionCenter;
return isMoveResize() && moveResizePointerMode() != PositionCenter;
}
// Decorations <-> Effects
......@@ -636,7 +636,6 @@ private:
static bool s_haveResizeEffect;
bool m_managed;
Position mode;
Xcb::GeometryHints m_geometryHints;
void sendSyntheticConfigureNotify();
enum MappingState {
......
......@@ -975,7 +975,7 @@ void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
return; // care only about leaving the whole frame
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
if (!buttonDown) {
mode = PositionCenter;
setMoveResizePointerMode(PositionCenter);
updateCursor();
}
bool lostMouse = !rect().contains(QPoint(e->event_x, e->event_y));
......@@ -1239,7 +1239,7 @@ bool Client::processDecorationButtonPress(int button, int /*state*/, int x, int
&& com != Options::MouseOperationsMenu // actions where it's not possible to get the matching
&& com != Options::MouseMinimize // mouse release event
&& com != Options::MouseDragTab) {
mode = mousePosition();
setMoveResizePointerMode(mousePosition());
buttonDown = true;
setMoveOffset(QPoint(x/* - padding_left*/, y/* - padding_top*/));
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
......@@ -1307,7 +1307,7 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in
stopDelayedMoveResize();
if (isMoveResize()) {
finishMoveResize(false);
mode = mousePosition();
setMoveResizePointerMode(mousePosition());
}
updateCursor();
}
......@@ -1398,8 +1398,8 @@ bool Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_ro
}
}
Position newmode = modKeyDown(state) ? PositionCenter : mousePosition();
if (newmode != mode) {
mode = newmode;
if (newmode != moveResizePointerMode()) {
setMoveResizePointerMode(newmode);
updateCursor();
}
return false;
......@@ -1506,7 +1506,7 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
setMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
setUnrestrictedMoveResize(false);
mode = convert[ direction ];
setMoveResizePointerMode(convert[ direction ]);
if (!startMoveResize())
buttonDown = false;
updateCursor();
......
......@@ -1857,6 +1857,7 @@ bool Client::isResizable() const
return false;
if (rules()->checkSize(QSize()).isValid()) // forced size
return false;
const Position mode = moveResizePointerMode();
if ((mode == PositionTop || mode == PositionTopLeft || mode == PositionTopRight ||
mode == PositionLeft || mode == PositionBottomLeft) && rules()->checkPosition(invalidPoint) != invalidPoint)
return false;
......@@ -2641,6 +2642,7 @@ bool Client::startMoveResize()
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
......@@ -2843,6 +2845,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
if (syncRequest.isPending && isResize())
return; // we're still waiting for the client or the timeout
const Position mode = moveResizePointerMode();
if ((mode == PositionCenter && !isMovableAcrossScreens())
|| (mode != PositionCenter && (isShade() || !isResizable())))
return;
......@@ -2905,7 +2908,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
if (isResize()) {
QRect orig = initialMoveResizeGeometry();
Sizemode sizemode = SizemodeAny;
auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizemode]() {
auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizemode, &mode]() {
switch(mode) {
case PositionTopLeft:
setMoveResizeGeometry(QRect(topleft, orig.bottomRight()));
......
......@@ -1220,7 +1220,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
break;
if (isMoveResize())
finishMoveResize(false);
mode = PositionCenter;
setMoveResizePointerMode(PositionCenter);
buttonDown = true;
setMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
......@@ -1245,12 +1245,14 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
bool right = x >= 2 * width() / 3;
bool top = y < height() / 3;
bool bot = y >= 2 * height() / 3;
Position mode;
if (top)
mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
else if (bot)
mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
else
mode = (x < width() / 2) ? PositionLeft : PositionRight;
setMoveResizePointerMode(mode);
setInvertedMoveOffset(rect().bottomRight() - moveOffset);
setUnrestrictedMoveResize((command == Options::MouseUnrestrictedResize));
if (!startMoveResize())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment