diff --git a/src/autotype/xcb/AutoTypeXCB.cpp b/src/autotype/xcb/AutoTypeXCB.cpp index e6ac74bbf..5d58e33c6 100644 --- a/src/autotype/xcb/AutoTypeXCB.cpp +++ b/src/autotype/xcb/AutoTypeXCB.cpp @@ -723,6 +723,12 @@ bool AutoTypePlatformX11::keysymModifiers(KeySym keysym, int keycode, unsigned i * are set ON, many events will be sent. */ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym) +{ + SendKey(keysym,true); + SendKey(keysym,false); +} + +void AutoTypePlatformX11::SendKey(KeySym keysym, bool isKeyDown) { Window cur_focus; int revert_to; @@ -802,8 +808,11 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym) /* press and release key */ event.keycode = keycode; - SendEvent(&event, KeyPress); - SendEvent(&event, KeyRelease); + if (isKeyDown) { + SendEvent(&event, KeyPress); + } else { + SendEvent(&event, KeyRelease); + } /* release the modifiers */ SendModifier(&event, press_mask, KeyRelease); @@ -840,6 +849,22 @@ void AutoTypeExecutorX11::execKey(AutoTypeKey* action) m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(action->key)); } +void AutoTypeExecutorX11::execClearField(AutoTypeClearField* action = nullptr) +{ + Q_UNUSED(action); + + m_platform->SendKey(XK_Control_L, true); + m_platform->SendKeyPressedEvent(XK_a); + m_platform->SendKey(XK_Control_L, false); + m_platform->SendKeyPressedEvent(XK_Delete); + + timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 25 * 1000 * 1000; + nanosleep(&ts, nullptr); +} + + int AutoTypePlatformX11::initialTimeout() { return 500; diff --git a/src/autotype/xcb/AutoTypeXCB.h b/src/autotype/xcb/AutoTypeXCB.h index dc251e3f9..186d0eb8b 100644 --- a/src/autotype/xcb/AutoTypeXCB.h +++ b/src/autotype/xcb/AutoTypeXCB.h @@ -58,6 +58,7 @@ public: KeySym keyToKeySym(Qt::Key key); void SendKeyPressedEvent(KeySym keysym); + void SendKey(KeySym keysym, bool isKeyDown); signals: void globalShortcutTriggered(); @@ -126,6 +127,7 @@ public: void execChar(AutoTypeChar* action) override; void execKey(AutoTypeKey* action) override; + void execClearField(AutoTypeClearField* action) override; private: AutoTypePlatformX11* const m_platform;