Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input-field: add capslock and numlock options #182

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 79 additions & 52 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,68 +90,67 @@ in {
backgrounds = mkOption {
description = "Background configurations";
type = listOf (submodule {
options =
{
monitor = mkOption {
description = "The monitor to apply the given wallpaper to";
type = str;
default = "";
};
options = {
monitor = mkOption {
description = "The monitor to apply the given wallpaper to";
type = str;
default = "";
};

path = mkOption {
description = "The path to the wallpaper";
type = str;
default = "echo '/home/me/someImage.png'"; # only png supported for now
};
path = mkOption {
description = "The path to the wallpaper";
type = str;
default = "echo '/home/me/someImage.png'"; # only png supported for now
};

color = mkOption {
description = "Background color";
type = str;
default = "rgba(25, 20, 20, 1.0)";
};
color = mkOption {
description = "Background color";
type = str;
default = "rgba(25, 20, 20, 1.0)";
};

blur_size = mkOption {
description = "Blur size";
type = int;
default = 8;
};
blur_size = mkOption {
description = "Blur size";
type = int;
default = 8;
};

blur_passes = mkOption {
description = "Blur passes";
type = int;
default = 0;
};
blur_passes = mkOption {
description = "Blur passes";
type = int;
default = 0;
};

noise = mkOption {
description = "Noise applied to blur";
type = float;
default = 0.0117;
};
noise = mkOption {
description = "Noise applied to blur";
type = float;
default = 0.0117;
};

contrast = mkOption {
description = "Contrast applied to blur";
type = float;
default = 0.8917;
};
contrast = mkOption {
description = "Contrast applied to blur";
type = float;
default = 0.8917;
};

brightness = mkOption {
description = "Brightness applied to blur";
type = float;
default = 0.8172;
};
brightness = mkOption {
description = "Brightness applied to blur";
type = float;
default = 0.8172;
};

vibrancy = mkOption {
description = "Vibrancy applied to blur";
type = float;
default = 0.1686;
};
vibrancy = mkOption {
description = "Vibrancy applied to blur";
type = float;
default = 0.1686;
};

vibrancy_darkness = mkOption {
description = "Vibrancy darkness applied to blur";
type = float;
default = 0.05;
};
vibrancy_darkness = mkOption {
description = "Vibrancy darkness applied to blur";
type = float;
default = 0.05;
};
};
});
default = [
{}
Expand Down Expand Up @@ -308,6 +307,30 @@ in {
type = str;
default = "center";
};

capslock_color = mkOption {
description = "Color of the input field when Caps Lock is active";
type = str;
default = "-1";
};

numlock_color = mkOption {
description = "Color of the input field when NumLock is active";
type = str;
default = "-1";
};

bothlock_color = mkOption {
description = "Color of the input field when both Caps Lock and NumLock are active";
type = str;
default = "-1";
};

invert_numlock = mkOption {
description = "Whether to change the color when NumLock is not active";
type = bool;
default = false;
};
}
// shadow;
});
Expand Down Expand Up @@ -437,6 +460,10 @@ in {
fail_color = ${input-field.fail_color}
fail_text = ${input-field.fail_text}
fail_transition = ${toString input-field.fail_transition}
capslock_color = ${input-field.capslock_color}
numlock_color = ${input-field.numlock_color}
bothlock_color = ${input-field.bothlock_color}
invert_numlock = ${boolToString input-field.invert_numlock}

position = ${toString input-field.position.x}, ${toString input-field.position.y}
halign = ${input-field.halign}
Expand Down
8 changes: 8 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ void CConfigManager::init() {
m_config.addSpecialConfigValue("input-field", "fail_color", Hyprlang::INT{0xFFCC2222});
m_config.addSpecialConfigValue("input-field", "fail_text", Hyprlang::STRING{"<i>$FAIL</i>"});
m_config.addSpecialConfigValue("input-field", "fail_transition", Hyprlang::INT{300});
m_config.addSpecialConfigValue("input-field", "capslock_color", Hyprlang::INT{-1});
m_config.addSpecialConfigValue("input-field", "numlock_color", Hyprlang::INT{-1});
m_config.addSpecialConfigValue("input-field", "bothlock_color", Hyprlang::INT{-1});
m_config.addSpecialConfigValue("input-field", "invert_numlock", Hyprlang::INT{0});
SHADOWABLE("input-field");

m_config.addSpecialCategory("label", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
Expand Down Expand Up @@ -174,6 +178,10 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
{"fail_color", m_config.getSpecialConfigValue("input-field", "fail_color", k.c_str())},
{"fail_text", m_config.getSpecialConfigValue("input-field", "fail_text", k.c_str())},
{"fail_transition", m_config.getSpecialConfigValue("input-field", "fail_transition", k.c_str())},
{"capslock_color", m_config.getSpecialConfigValue("input-field", "capslock_color", k.c_str())},
{"numlock_color", m_config.getSpecialConfigValue("input-field", "numlock_color", k.c_str())},
{"bothlock_color", m_config.getSpecialConfigValue("input-field", "bothlock_color", k.c_str())},
{"invert_numlock", m_config.getSpecialConfigValue("input-field", "invert_numlock", k.c_str())},
SHADOWABLE("input-field"),
}
});
Expand Down
7 changes: 7 additions & 0 deletions src/core/hyprlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ void CHyprlock::onKey(uint32_t key, bool down) {
return;
}

m_bCapsLock = xkb_state_mod_name_is_active(g_pHyprlock->m_pXKBState, XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED);
m_bNumLock = xkb_state_mod_name_is_active(g_pHyprlock->m_pXKBState, XKB_MOD_NAME_NUM, XKB_STATE_MODS_LOCKED);

if (SYM == XKB_KEY_BackSpace) {
if (m_sPasswordState.passBuffer.length() > 0)
m_sPasswordState.passBuffer = m_sPasswordState.passBuffer.substr(0, m_sPasswordState.passBuffer.length() - 1);
Expand All @@ -766,6 +769,10 @@ void CHyprlock::onKey(uint32_t key, bool down) {
Debug::log(LOG, "Clearing password buffer");

m_sPasswordState.passBuffer = "";
} else if (SYM == XKB_KEY_Caps_Lock) {
m_bCapsLock = !m_bCapsLock;
} else if (SYM == XKB_KEY_Num_Lock) {
m_bNumLock = !m_bNumLock;
} else {
char buf[16] = {0};
int len = xkb_keysym_to_utf8(SYM, buf, 16);
Expand Down
3 changes: 3 additions & 0 deletions src/core/hyprlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class CHyprlock {

bool m_bLocked = false;

bool m_bCapsLock = false;
bool m_bNumLock = false;

//
std::chrono::system_clock::time_point m_tGraceEnds;
Vector2D m_vLastEnterCoords = {};
Expand Down
Loading
Loading