Move keyPressEvent(uint) to AbstractClient

The variant with additional timestamp is still in Client.
This commit is contained in:
Martin Gräßlin 2015-10-23 15:32:10 +02:00
parent 717a48a2a1
commit 5d2251875f
4 changed files with 45 additions and 37 deletions

View file

@ -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);
}
}

View file

@ -364,6 +364,7 @@ public:
virtual void growVertical();
virtual void shrinkVertical();
void updateMoveResize(const QPointF &currentGlobalCursor);
void keyPressEvent(uint key_code);
/**
* These values represent positions inside an area

View file

@ -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;

View file

@ -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)