diff options
author | Michael <[email protected]> | 2023-08-07 10:34:15 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2023-08-07 19:34:15 +0200 |
commit | cebab759d52747c2067217d93096b47281722e57 (patch) | |
tree | d75ec6f1a74cee6f8c5c0656d87f60f9462df8c9 | |
parent | deeeb33c5f919ad5499a10526772b617f24d72ab (diff) | |
download | Hyprland-cebab759d52747c2067217d93096b47281722e57.tar.gz Hyprland-cebab759d52747c2067217d93096b47281722e57.zip |
Close keymap files. Fixes #2904 (#2905)
Signed-off-by: Michael Pacheco <[email protected]>
-rw-r--r-- | src/managers/KeybindManager.cpp | 6 | ||||
-rw-r--r-- | src/managers/input/InputManager.cpp | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c382cabe..94e0dfd4 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -140,10 +140,12 @@ void CKeybindManager::updateXKBTranslationState() { xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()}; - const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + FILE* const KEYMAPFILE = fopen(FILEPATH.c_str(), "r"); auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) : - xkb_keymap_new_from_file(PCONTEXT, fopen(FILEPATH.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + fclose(KEYMAPFILE); if (!PKEYMAP) { g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 1df5acb3..f4382838 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -786,8 +786,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { if (!std::filesystem::exists(path)) Debug::log(ERR, "input:kb_file= file doesnt exist"); - else - KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + else { + FILE* const KEYMAPFILE = fopen(FILEPATH.c_str(), "r"); + KEYMAP = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + fclose(KEYMAPFILE); + } } if (!KEYMAP) |