From ab9e5bf98a2b1869646d9f346a00216bce36a28b Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 2 Jul 2024 14:06:27 +0200 Subject: [PATCH] fixes --- src/devices/IKeyboard.cpp | 17 +++++++++++++++++ src/devices/IKeyboard.hpp | 4 +++- src/devices/Keyboard.cpp | 4 +--- src/managers/input/InputManager.cpp | 2 +- src/protocols/LinuxDMABUF.cpp | 20 ++++++++++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index 4c8f5880..e07385c5 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -2,6 +2,7 @@ #include "../defines.hpp" #include "../helpers/varlist/VarList.hpp" #include "../managers/input/InputManager.hpp" +#include "../managers/SeatManager.hpp" #include #include @@ -148,6 +149,8 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) { } xkb_context_unref(CONTEXT); + + g_pSeatManager->updateActiveKeyboardData(); } void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { @@ -323,7 +326,21 @@ bool IKeyboard::updateModifiersState() { } void IKeyboard::updateXkbStateWithKey(uint32_t xkbKey, bool pressed) { + + const auto contains = std::find(pressedXKB.begin(), pressedXKB.end(), xkbKey) != pressedXKB.end(); + + if (contains && pressed) + return; + if (!contains && !pressed) + return; + + if (contains) + std::erase(pressedXKB, xkbKey); + else + pressedXKB.emplace_back(xkbKey); + xkb_state_update_key(xkbState, xkbKey, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); + if (updateModifiersState()) { keyboardEvents.modifiers.emit(SModifiersEvent{ .depressed = modifiersState.depressed, diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp index 332b8ca0..741a6702 100644 --- a/src/devices/IKeyboard.hpp +++ b/src/devices/IKeyboard.hpp @@ -89,5 +89,7 @@ class IKeyboard : public IHID { WP self; private: - void clearManuallyAllocd(); + void clearManuallyAllocd(); + + std::vector pressedXKB; }; diff --git a/src/devices/Keyboard.cpp b/src/devices/Keyboard.cpp index 867d54a8..f77829a7 100644 --- a/src/devices/Keyboard.cpp +++ b/src/devices/Keyboard.cpp @@ -42,9 +42,7 @@ CKeyboard::CKeyboard(SP keeb) : keyboard(keeb) { }); listeners.modifiers = keeb->events.modifiers.registerListener([this](std::any d) { - auto E = std::any_cast(d); - - updateModifiers(E.depressed, E.latched, E.locked, E.group); + updateModifiersState(); keyboardEvents.modifiers.emit(SModifiersEvent{ .depressed = modifiersState.depressed, diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f166f377..ae1dd7ca 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1327,7 +1327,7 @@ void CInputManager::onKeyboardMod(SP pKeyboard) { const auto LAYOUT = pKeyboard->getActiveLayout(); - pKeyboard->updateXKBTranslationState(pKeyboard->xkbKeymap); + Debug::log(LOG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group); g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->hlName + "," + LAYOUT}); EMIT_HOOK_EVENT("activeLayout", (std::vector{pKeyboard, LAYOUT})); diff --git a/src/protocols/LinuxDMABUF.cpp b/src/protocols/LinuxDMABUF.cpp index 32cace3f..994882c8 100644 --- a/src/protocols/LinuxDMABUF.cpp +++ b/src/protocols/LinuxDMABUF.cpp @@ -288,6 +288,8 @@ CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SPmainDevice, }; resource->sendMainDevice(&deviceArr); + + // Main tranche resource->sendTrancheTargetDevice(&deviceArr); resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)0); @@ -300,6 +302,24 @@ CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SPsendTrancheDone(); + // Scanout tranche + // FIXME: jesus fucking christ this SUCKSSSSSS ASSSSSS + resource->sendTrancheTargetDevice(&deviceArr); + resource->sendTrancheFlags(ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT); + + wl_array indices2; + wl_array_init(&indices2); + for (size_t i = 0; i < feedback->tranches.size(); ++i) { + // FIXME: if the monitor gets the wrong format we'll be FUCKED by drm and no scanout will happen + if (feedback->tranches.at(i).first != DRM_FORMAT_XRGB8888 && feedback->tranches.at(i).first != DRM_FORMAT_XRGB2101010) + continue; + + *((uint16_t*)wl_array_add(&indices2, sizeof(uint16_t))) = i; + } + resource->sendTrancheFormats(&indices2); + wl_array_release(&indices2); + resource->sendTrancheDone(); + resource->sendDone(); }