Move keyPressEvent(uint) to AbstractClient
The variant with additional timestamp is still in Client.
This commit is contained in:
parent
717a48a2a1
commit
5d2251875f
4 changed files with 45 additions and 37 deletions
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
#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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
3
client.h
3
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;
|
||||
|
||||
|
|
37
events.cpp
37
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)
|
||||
|
|
Loading…
Reference in a new issue