diff options
| author | Vaxry <vaxry@vaxry.net> | 2025-01-24 13:37:23 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2025-01-24 13:37:30 +0000 |
| commit | 57a39984dddd00fd1aca436e149b7566e5e48d95 (patch) | |
| tree | cf22f222bc6bd6525415dd3b33f7274611f87cc6 /src | |
| parent | 944e36ea2e71db20cf3f8b2e5cbf978a5bf5268b (diff) | |
input: abord dnd op on escape pressed
ref #9154
Diffstat (limited to 'src')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 4 | ||||
| -rw-r--r-- | src/protocols/core/DataDevice.cpp | 6 | ||||
| -rw-r--r-- | src/protocols/core/DataDevice.hpp | 3 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index f4a55a73..4706c1e1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -4,6 +4,7 @@ #include "../protocols/LayerShell.hpp" #include "../protocols/ShortcutsInhibit.hpp" #include "../protocols/GlobalShortcuts.hpp" +#include "../protocols/core/DataDevice.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "KeybindManager.hpp" #include "PointerManager.hpp" @@ -432,6 +433,9 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) { const xkb_keysym_t keysym = xkb_state_key_get_one_sym(pKeyboard->resolveBindsBySym ? pKeyboard->xkbSymState : m_pXKBTranslationState, KEYCODE); const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(pKeyboard->xkbState, KEYCODE); + if (keysym == XKB_KEY_Escape || internalKeysym == XKB_KEY_Escape) + PROTO::data->abortDndIfPresent(); + // handleInternalKeybinds returns true when the key should be suppressed, // while this function returns true when the key event should be sent if (handleInternalKeybinds(internalKeysym)) diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index ade16498..36437dd4 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -814,3 +814,9 @@ void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, timespec* when) { bool CWLDataDeviceProtocol::dndActive() { return dnd.currentSource; } + +void CWLDataDeviceProtocol::abortDndIfPresent() { + if (!dndActive()) + return; + abortDrag(); +} diff --git a/src/protocols/core/DataDevice.hpp b/src/protocols/core/DataDevice.hpp index 5101862e..d8bc2b9c 100644 --- a/src/protocols/core/DataDevice.hpp +++ b/src/protocols/core/DataDevice.hpp @@ -144,6 +144,9 @@ class CWLDataDeviceProtocol : public IWaylandProtocol { // TODO: move handling to seatmgr bool dndActive(); + // called on an escape key pressed, for moments where it gets stuck + void abortDndIfPresent(); + private: void destroyResource(CWLDataDeviceManagerResource* resource); void destroyResource(CWLDataDeviceResource* resource); |
