mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 09:25:59 +01:00
input: improved path handling; null check return value of fopen. (#3061)
This commit is contained in:
parent
3a1f30519b
commit
f0da0b0be4
2 changed files with 6 additions and 8 deletions
|
@ -139,13 +139,12 @@ void CKeybindManager::updateXKBTranslationState() {
|
||||||
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
||||||
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
||||||
|
|
||||||
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
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 = FILEPATH == "" ? NULL : fopen(FILEPATH.c_str(), "r");
|
FILE* const KEYMAPFILE = FILEPATH == "" ? NULL : fopen(absolutePath(FILEPATH, g_pConfigManager->configCurrentPath).c_str(), "r");
|
||||||
|
|
||||||
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
|
auto PKEYMAP = KEYMAPFILE ? xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, 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);
|
xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
if (KEYMAPFILE)
|
if (KEYMAPFILE)
|
||||||
fclose(KEYMAPFILE);
|
fclose(KEYMAPFILE);
|
||||||
|
|
||||||
|
|
|
@ -784,10 +784,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
if (!FILEPATH.empty()) {
|
if (!FILEPATH.empty()) {
|
||||||
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
||||||
|
|
||||||
if (!std::filesystem::exists(path))
|
if (FILE* const KEYMAPFILE = fopen(path.c_str(), "r"); !KEYMAPFILE)
|
||||||
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
Debug::log(ERR, "Cannot open input:kb_file= file for reading");
|
||||||
else {
|
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);
|
KEYMAP = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
fclose(KEYMAPFILE);
|
fclose(KEYMAPFILE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue