mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 10:25:58 +01:00
input-capture: impl force release
This commit is contained in:
parent
e0321f721e
commit
255db25664
6 changed files with 28 additions and 2 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "eventLoop/EventLoopManager.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "helpers/varlist/VarList.hpp"
|
||||
#include "protocols/InputCapture.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <iterator>
|
||||
|
@ -126,6 +127,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["denywindowfromgroup"] = denyWindowFromGroup;
|
||||
m_mDispatchers["event"] = event;
|
||||
m_mDispatchers["global"] = global;
|
||||
m_mDispatchers["releaseinputcapture"] = releaseInputCapture;
|
||||
|
||||
m_tScrollTimer.reset();
|
||||
|
||||
|
@ -716,6 +718,14 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
|
|||
|
||||
m_iPassPressed = (int)pressed;
|
||||
|
||||
// We only process the releaseinputcapture dispatcher when input capture is active
|
||||
if (PROTO::inputCapture->isCaptured()) {
|
||||
if (k.handler == "releaseinputcapture")
|
||||
res = DISPATCHER->second(k.arg);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// if the dispatchers says to pass event then we will
|
||||
if (k.handler == "mouse")
|
||||
res = DISPATCHER->second((pressed ? "1" : "0") + k.arg);
|
||||
|
@ -2891,3 +2901,8 @@ SDispatchResult CKeybindManager::event(std::string args) {
|
|||
g_pEventManager->postEvent(SHyprIPCEvent{"custom", args});
|
||||
return {};
|
||||
}
|
||||
|
||||
SDispatchResult CKeybindManager::releaseInputCapture(std::string args) {
|
||||
PROTO::inputCapture->forceRelease();
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -217,6 +217,7 @@ class CKeybindManager {
|
|||
static SDispatchResult denyWindowFromGroup(std::string);
|
||||
static SDispatchResult global(std::string);
|
||||
static SDispatchResult event(std::string);
|
||||
static SDispatchResult releaseInputCapture(std::string);
|
||||
|
||||
friend class CCompositor;
|
||||
friend class CInputManager;
|
||||
|
|
|
@ -1316,7 +1316,7 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
|||
const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);
|
||||
|
||||
bool passEvent = !PROTO::inputCapture->isCaptured() && (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard));
|
||||
bool passEvent = (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard)) && !PROTO::inputCapture->isCaptured();
|
||||
|
||||
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
||||
|
||||
|
|
|
@ -67,6 +67,14 @@ void CInputCaptureProtocol::sendKeymap(SP<IKeyboard> keyboard, const std::unique
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::forceRelease() {
|
||||
Debug::log(LOG, "[input-capture] Force Input released");
|
||||
active = false;
|
||||
|
||||
for (const auto& manager : m_vManagers)
|
||||
manager->sendForceRelease();
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) {
|
||||
for (const auto& manager : m_vManagers)
|
||||
manager->sendKey(keyCode, state);
|
||||
|
|
|
@ -13,6 +13,8 @@ class CInputCaptureProtocol : public IWaylandProtocol {
|
|||
bool isCaptured();
|
||||
|
||||
void updateKeymap();
|
||||
void forceRelease();
|
||||
|
||||
void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
||||
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state);
|
||||
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d3674e1f4eac730efc01c08e794a988be31ec73e
|
||||
Subproject commit 0c7cf263faeae9429942c6ffbc1e9b5dfd709bf4
|
Loading…
Reference in a new issue