diff --git a/abstract_client.cpp b/abstract_client.cpp index a35177bf6d..edecf629a8 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "abstract_client.h" #include "decorations/decorationpalette.h" +#include "cursor.h" #include "effects.h" #include "focuschain.h" #include "outline.h" @@ -1259,4 +1260,44 @@ void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot) } } +void AbstractClient::keyPressEvent(uint key_code) +{ + if (!isMove() && !isResize()) + return; + bool is_control = key_code & Qt::CTRL; + bool is_alt = key_code & Qt::ALT; + key_code = key_code & ~Qt::KeyboardModifierMask; + int delta = is_control ? 1 : is_alt ? 32 : 8; + QPoint pos = Cursor::pos(); + switch(key_code) { + case Qt::Key_Left: + pos.rx() -= delta; + break; + case Qt::Key_Right: + pos.rx() += delta; + break; + case Qt::Key_Up: + pos.ry() -= delta; + break; + case Qt::Key_Down: + pos.ry() += delta; + break; + case Qt::Key_Space: + case Qt::Key_Return: + case Qt::Key_Enter: + finishMoveResize(false); + setMoveResizePointerButtonDown(false); + updateCursor(); + break; + case Qt::Key_Escape: + finishMoveResize(true); + setMoveResizePointerButtonDown(false); + updateCursor(); + break; + default: + return; + } + Cursor::setPos(pos); +} + } diff --git a/abstract_client.h b/abstract_client.h index bfd5add9cf..4e7045f6f8 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -364,6 +364,7 @@ public: virtual void growVertical(); virtual void shrinkVertical(); void updateMoveResize(const QPointF ¤tGlobalCursor); + void keyPressEvent(uint key_code); /** * These values represent positions inside an area diff --git a/client.h b/client.h index 0f85446bfa..9a1b0453a5 100644 --- a/client.h +++ b/client.h @@ -292,7 +292,8 @@ public: QString caption(bool full = true, bool stripped = false) const override; - void keyPressEvent(uint key_code, xcb_timestamp_t time = XCB_TIME_CURRENT_TIME); // FRAME ?? + using AbstractClient::keyPressEvent; + void keyPressEvent(uint key_code, xcb_timestamp_t time); // FRAME ?? void updateMouseGrab() override; xcb_window_t moveResizeGrabWindow() const; diff --git a/events.cpp b/events.cpp index 09ab7fbdb5..f022b85758 100644 --- a/events.cpp +++ b/events.cpp @@ -1461,42 +1461,7 @@ void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction) void Client::keyPressEvent(uint key_code, xcb_timestamp_t time) { updateUserTime(time); - if (!isMove() && !isResize()) - return; - bool is_control = key_code & Qt::CTRL; - bool is_alt = key_code & Qt::ALT; - key_code = key_code & ~Qt::KeyboardModifierMask; - int delta = is_control ? 1 : is_alt ? 32 : 8; - QPoint pos = Cursor::pos(); - switch(key_code) { - case Qt::Key_Left: - pos.rx() -= delta; - break; - case Qt::Key_Right: - pos.rx() += delta; - break; - case Qt::Key_Up: - pos.ry() -= delta; - break; - case Qt::Key_Down: - pos.ry() += delta; - break; - case Qt::Key_Space: - case Qt::Key_Return: - case Qt::Key_Enter: - finishMoveResize(false); - setMoveResizePointerButtonDown(false); - updateCursor(); - break; - case Qt::Key_Escape: - finishMoveResize(true); - setMoveResizePointerButtonDown(false); - updateCursor(); - break; - default: - return; - } - Cursor::setPos(pos); + AbstractClient::keyPressEvent(key_code); } void Client::syncEvent(xcb_sync_alarm_notify_event_t* e)