Skip to content

Commit

Permalink
Use QTimer::singleShort
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 20, 2020
1 parent 384f780 commit 8584ff1
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions QHotkey/qhotkey_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class QHotkeyPrivateX11 : public QHotkeyPrivate
private:
static const QVector<quint32> specialModifiers;
static const quint32 validModsMask;
QTimer *releaseTimer = nullptr;
xcb_key_press_event_t prevHandledEvent;
xcb_key_press_event_t prevEvent;

Expand Down Expand Up @@ -75,17 +74,11 @@ bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *mes
} else if (genericEvent->response_type == XCB_KEY_RELEASE) {
xcb_key_release_event_t keyEvent = *static_cast<xcb_key_release_event_t *>(message);
this->prevEvent = keyEvent;
auto *timer = new QTimer(this);
timer->setSingleShot(true);
timer->setInterval(50);
connect(timer, &QTimer::timeout, this, [this, keyEvent, timer] {
QTimer::singleShot(50, [this, keyEvent] {
if(this->prevEvent.time == keyEvent.time && this->prevEvent.response_type == keyEvent.response_type && this->prevEvent.detail == keyEvent.detail){
this->releaseShortcut({keyEvent.detail, keyEvent.state & QHotkeyPrivateX11::validModsMask});
}
delete timer;
});
timer->start();
this->releaseTimer = timer;
this->prevHandledEvent = keyEvent;
}

Expand Down

0 comments on commit 8584ff1

Please sign in to comment.