feat: add dispatcher to trigger magnification

closes: #51
This commit is contained in:
Virt 2025-01-10 22:06:23 +01:00
commit 94eaf75d09
8 changed files with 80 additions and 2 deletions

View file

@ -110,6 +110,15 @@ double CShake::update(Vector2D pos) {
return this->zoom->value();
}
void CShake::force(std::optional<int> duration, std::optional<float> size) {
static auto* const* PTIMEOUT = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_TIMEOUT);
static auto* const* PBASE = (Hyprlang::FLOAT* const*) getConfig(CONFIG_SHAKE_BASE);
started = true;
*this->zoom = size.value_or(**PBASE);
this->end = steady_clock::now() + milliseconds(duration.value_or(**PTIMEOUT));
}
void CShake::warp(Vector2D old, Vector2D pos) {
auto delta = pos - old;

View file

@ -1,4 +1,5 @@
#include "helpers/AnimatedVariable.hpp"
#include <bits/getopt_ext.h>
#include <hyprutils/animation/AnimatedVariable.hpp>
#include <hyprutils/math/Vector2D.hpp>
#include <vector>
@ -20,6 +21,9 @@ class CShake {
/* called when a cursor warp has happened (to avoid magnifying on warps) */
void warp(Vector2D old, Vector2D pos);
/* force magnification regardless of speed now */
void force(std::optional<int> duration, std::optional<float> size);
private:
/* tracks whether the current shake has already been announced in the ipc */
bool ipc = false;