input-capture: impl force release

This commit is contained in:
Gwilherm Folliot 2024-10-21 10:27:03 +02:00
parent 93da5ffb12
commit 4fc4388283
No known key found for this signature in database
GPG key ID: 90236D3623DCD660
6 changed files with 3199 additions and 1 deletions

View file

@ -5,6 +5,7 @@
#include "../protocols/ShortcutsInhibit.hpp"
#include "../protocols/GlobalShortcuts.hpp"
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../devices/IKeyboard.hpp"
#include "KeybindManager.hpp"
#include "PointerManager.hpp"
#include "Compositor.hpp"
@ -13,6 +14,7 @@
#include "debug/Log.hpp"
#include "helpers/varlist/VarList.hpp"
#include "../helpers/signal/Signal.hpp"
#include "protocols/InputCapture.hpp"
#include <optional>
#include <iterator>
@ -131,6 +133,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["event"] = event;
m_mDispatchers["global"] = global;
m_mDispatchers["setprop"] = setProp;
m_mDispatchers["releaseinputcapture"] = releaseInputCapture;
m_tScrollTimer.reset();
@ -3160,3 +3163,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
return {};
}
SDispatchResult CKeybindManager::releaseInputCapture(std::string args) {
PROTO::inputCapture->forceRelease();
return {};
}

File diff suppressed because it is too large Load diff

View file

@ -220,6 +220,7 @@ class CKeybindManager {
static SDispatchResult global(std::string);
static SDispatchResult event(std::string);
static SDispatchResult setProp(std::string);
static SDispatchResult releaseInputCapture(std::string);
friend class CCompositor;
friend class CInputManager;

View file

@ -1345,7 +1345,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);

View file

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

View file

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