mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
parent
06b07c53e5
commit
6355216f48
3 changed files with 16 additions and 1 deletions
|
@ -21,6 +21,7 @@ CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlan
|
|||
void CConfigManager::init() {
|
||||
m_config.addConfigValue("general:disable_loading_bar", Hyprlang::INT{0});
|
||||
m_config.addConfigValue("general:hide_cursor", Hyprlang::INT{0});
|
||||
m_config.addConfigValue("general:grace", Hyprlang::INT{0});
|
||||
|
||||
m_config.addSpecialCategory("background", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
|
||||
m_config.addSpecialConfigValue("background", "monitor", Hyprlang::STRING{""});
|
||||
|
|
|
@ -25,6 +25,9 @@ CHyprlock::CHyprlock(const std::string& wlDisplay) {
|
|||
Debug::log(ERR, "Failed to create xkb context");
|
||||
|
||||
g_pRenderer = std::make_unique<CRenderer>();
|
||||
|
||||
const auto GRACE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:grace");
|
||||
m_tGraceEnds = **GRACE ? std::chrono::system_clock::now() + std::chrono::seconds(**GRACE) : std::chrono::system_clock::from_time_t(0);
|
||||
}
|
||||
|
||||
// wl_seat
|
||||
|
@ -265,6 +268,8 @@ static void handlePointerEnter(void* data, struct wl_pointer* wl_pointer, uint32
|
|||
g_pHyprlock->m_pCursorShape->hideCursor(serial);
|
||||
else
|
||||
g_pHyprlock->m_pCursorShape->setShape(serial, wp_cursor_shape_device_v1_shape::WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER);
|
||||
|
||||
g_pHyprlock->m_vLastEnterCoords = {wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)};
|
||||
}
|
||||
|
||||
static void handlePointerLeave(void* data, struct wl_pointer* wl_pointer, uint32_t serial, struct wl_surface* surface) {
|
||||
|
@ -276,7 +281,12 @@ static void handlePointerAxis(void* data, wl_pointer* wl_pointer, uint32_t time,
|
|||
}
|
||||
|
||||
static void handlePointerMotion(void* data, struct wl_pointer* wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
;
|
||||
if (g_pHyprlock->m_vLastEnterCoords.distance({wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)}) > 5 &&
|
||||
std::chrono::system_clock::now() < g_pHyprlock->m_tGraceEnds) {
|
||||
|
||||
Debug::log(LOG, "In grace and cursor moved more than 5px, unlocking!");
|
||||
g_pHyprlock->unlockSession();
|
||||
}
|
||||
}
|
||||
|
||||
static void handlePointerButton(void* data, struct wl_pointer* wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t button_state) {
|
||||
|
|
|
@ -61,6 +61,10 @@ class CHyprlock {
|
|||
|
||||
bool m_bTerminate = false;
|
||||
|
||||
//
|
||||
std::chrono::system_clock::time_point m_tGraceEnds;
|
||||
Vector2D m_vLastEnterCoords = {};
|
||||
|
||||
private:
|
||||
struct {
|
||||
wl_display* display = nullptr;
|
||||
|
|
Loading…
Reference in a new issue