Move buttonDown from Client to AbstractClient
Bundled together with other moveResize functionality. We might need to investigate whether this variable is needed at all.
This commit is contained in:
parent
605acaf60e
commit
b8e68307bb
6 changed files with 28 additions and 24 deletions
|
@ -672,6 +672,12 @@ protected:
|
|||
void setMoveResizePointerMode(Position mode) {
|
||||
m_moveResize.pointer = mode;
|
||||
}
|
||||
bool isMoveResizePointerButtonDown() const {
|
||||
return m_moveResize.buttonDown;
|
||||
}
|
||||
void setMoveResizePointerButtonDown(bool down) {
|
||||
m_moveResize.buttonDown = down;
|
||||
}
|
||||
void checkUnrestrictedMoveResize();
|
||||
|
||||
private:
|
||||
|
@ -728,6 +734,7 @@ private:
|
|||
QRect initialGeometry;
|
||||
QRect geometry;
|
||||
Position pointer = PositionCenter;
|
||||
bool buttonDown = false;
|
||||
} m_moveResize;
|
||||
};
|
||||
|
||||
|
|
|
@ -140,8 +140,6 @@ Client::Client()
|
|||
// Set the initial mapping state
|
||||
mapping_state = Withdrawn;
|
||||
|
||||
buttonDown = false;
|
||||
|
||||
info = NULL;
|
||||
|
||||
shade_mode = ShadeNone;
|
||||
|
@ -1644,7 +1642,7 @@ void Client::syncTabGroupFor(QString property, bool fromThisClient)
|
|||
|
||||
void Client::dontMoveResize()
|
||||
{
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
stopDelayedMoveResize();
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
|
@ -2270,7 +2268,7 @@ void Client::processDecorationButtonRelease(QMouseEvent *event)
|
|||
}
|
||||
|
||||
if (event->buttons() == Qt::NoButton) {
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
stopDelayedMoveResize();
|
||||
if (isMoveResize()) {
|
||||
finishMoveResize(false);
|
||||
|
@ -2282,7 +2280,7 @@ void Client::processDecorationButtonRelease(QMouseEvent *event)
|
|||
|
||||
void Client::processDecorationMove()
|
||||
{
|
||||
if (buttonDown) {
|
||||
if (isMoveResizePointerButtonDown()) {
|
||||
return;
|
||||
}
|
||||
// TODO: handle modifiers
|
||||
|
|
1
client.h
1
client.h
|
@ -610,7 +610,6 @@ private:
|
|||
QStringList activityList;
|
||||
int m_activityUpdatesBlocked;
|
||||
bool m_blockedActivityUpdatesRequireTransients;
|
||||
bool buttonDown;
|
||||
Xcb::Window m_moveResizeGrabWindow;
|
||||
bool move_resize_has_keyboard_grab;
|
||||
int moveResizeStartScreen;
|
||||
|
|
22
events.cpp
22
events.cpp
|
@ -974,7 +974,7 @@ void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
|
|||
if (e->event != frameId())
|
||||
return; // care only about leaving the whole frame
|
||||
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
|
||||
if (!buttonDown) {
|
||||
if (!isMoveResizePointerButtonDown()) {
|
||||
setMoveResizePointerMode(PositionCenter);
|
||||
updateCursor();
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
|
|||
cancelAutoRaise();
|
||||
workspace()->cancelDelayFocus();
|
||||
cancelShadeHoverTimer();
|
||||
if (shade_mode == ShadeHover && !isMoveResize() && !buttonDown) {
|
||||
if (shade_mode == ShadeHover && !isMoveResize() && !isMoveResizePointerButtonDown()) {
|
||||
shadeHoverTimer = new QTimer(this);
|
||||
connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeUnhover()));
|
||||
shadeHoverTimer->setSingleShot(true);
|
||||
|
@ -1096,7 +1096,7 @@ static bool modKeyDown(int state) {
|
|||
// return value matters only when filtering events before decoration gets them
|
||||
bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time)
|
||||
{
|
||||
if (buttonDown) {
|
||||
if (isMoveResizePointerButtonDown()) {
|
||||
if (w == wrapperId())
|
||||
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
||||
return true;
|
||||
|
@ -1240,7 +1240,7 @@ bool Client::processDecorationButtonPress(int button, int /*state*/, int x, int
|
|||
&& com != Options::MouseMinimize // mouse release event
|
||||
&& com != Options::MouseDragTab) {
|
||||
setMoveResizePointerMode(mousePosition());
|
||||
buttonDown = true;
|
||||
setMoveResizePointerButtonDown(true);
|
||||
setMoveOffset(QPoint(x/* - padding_left*/, y/* - padding_top*/));
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
||||
setUnrestrictedMoveResize(false);
|
||||
|
@ -1303,7 +1303,7 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in
|
|||
buttonMask &= ~XCB_BUTTON_MASK_3;
|
||||
|
||||
if ((state & buttonMask) == 0) {
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
stopDelayedMoveResize();
|
||||
if (isMoveResize()) {
|
||||
finishMoveResize(false);
|
||||
|
@ -1387,7 +1387,7 @@ bool Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_ro
|
|||
}
|
||||
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
|
||||
return true; // care only about the whole frame
|
||||
if (!buttonDown) {
|
||||
if (!isMoveResizePointerButtonDown()) {
|
||||
if (w == inputId()) {
|
||||
int x = x_root - geometry().x();// + padding_left;
|
||||
int y = y_root - geometry().y();// + padding_top;
|
||||
|
@ -1485,7 +1485,7 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
|
|||
performMouseCommand(Options::MouseMove, QPoint(x_root, y_root));
|
||||
else if (isMoveResize() && direction == NET::MoveResizeCancel) {
|
||||
finishMoveResize(true);
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
} else if (direction >= NET::TopLeft && direction <= NET::Left) {
|
||||
static const Position convert[] = {
|
||||
|
@ -1502,13 +1502,13 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
|
|||
return;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
buttonDown = true;
|
||||
setMoveResizePointerButtonDown(true);
|
||||
setMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
||||
setUnrestrictedMoveResize(false);
|
||||
setMoveResizePointerMode(convert[ direction ]);
|
||||
if (!startMoveResize())
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
} else if (direction == NET::KeyboardMove) {
|
||||
// ignore mouse coordinates given in the message, mouse position is used by the moving algorithm
|
||||
|
@ -1548,12 +1548,12 @@ void Client::keyPressEvent(uint key_code, xcb_timestamp_t time)
|
|||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
finishMoveResize(false);
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
finishMoveResize(true);
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -2799,9 +2799,9 @@ void Client::startDelayedMoveResize()
|
|||
delayedMoveResizeTimer->setSingleShot(true);
|
||||
connect(delayedMoveResizeTimer, &QTimer::timeout, this,
|
||||
[this]() {
|
||||
assert(buttonDown);
|
||||
assert(isMoveResizePointerButtonDown());
|
||||
if (!startMoveResize()) {
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
}
|
||||
updateCursor();
|
||||
stopDelayedMoveResize();
|
||||
|
@ -2854,7 +2854,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
|
|||
QPoint p(QPoint(x/* - padding_left*/, y/* - padding_top*/) - moveOffset());
|
||||
if (p.manhattanLength() >= QApplication::startDragDistance()) {
|
||||
if (!startMoveResize()) {
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1221,13 +1221,13 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
setMoveResizePointerMode(PositionCenter);
|
||||
buttonDown = true;
|
||||
setMoveResizePointerButtonDown(true);
|
||||
setMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
||||
setUnrestrictedMoveResize((command == Options::MouseActivateRaiseAndUnrestrictedMove
|
||||
|| command == Options::MouseUnrestrictedMove));
|
||||
if (!startMoveResize())
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
|
@ -1237,7 +1237,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
break;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
buttonDown = true;
|
||||
setMoveResizePointerButtonDown(true);
|
||||
const QPoint moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global
|
||||
setMoveOffset(moveOffset);
|
||||
int x = moveOffset.x(), y = moveOffset.y();
|
||||
|
@ -1256,7 +1256,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
setInvertedMoveOffset(rect().bottomRight() - moveOffset);
|
||||
setUnrestrictedMoveResize((command == Options::MouseUnrestrictedResize));
|
||||
if (!startMoveResize())
|
||||
buttonDown = false;
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue