hypr-dynamic-cursors/src/cursor.hpp

54 lines
1.8 KiB
C++
Raw Normal View History

2024-06-21 14:32:42 +02:00
#include "globals.hpp"
#define private public
2024-06-21 14:32:42 +02:00
#include <hyprland/src/managers/PointerManager.hpp>
#undef private
2024-06-21 14:32:42 +02:00
#include <hyprutils/math/Vector2D.hpp>
class CDynamicCursors;
class CDynamicCursors {
public:
/* hook on onCursorMoved */
void onCursorMoved(CPointerManager* pointers);
2024-06-26 17:14:16 +02:00
/* called on tick */
void onTick(CPointerManager* pointers);
2024-06-21 16:06:55 +02:00
/* hook on renderSoftwareCursorsFor */
2024-06-21 16:36:10 +02:00
void renderSoftware(CPointerManager* pointers, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos);
/* hook on damageIfSoftware*/
void damageSoftware(CPointerManager* pointers);
/* hook on renderHWCursorBuffer */
wlr_buffer* renderHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture);
/* hook on setHWCursorBuffer */
bool setHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, wlr_buffer* buf);
2024-06-21 14:32:42 +02:00
private:
// current angle of the cursor in radiants
double angle;
2024-06-27 17:21:39 +02:00
// current zoom value of the cursor
double zoom = 1;
2024-06-27 18:04:49 +02:00
// whether we have already locked software
bool software = false;
2024-06-26 17:14:16 +02:00
// calculates the current angle of the cursor, and changes the cursor shape
void calculate(bool tick);
2024-06-26 17:14:16 +02:00
// calculate the angle of the cursor if stick
double calculateStick();
2024-06-21 14:32:42 +02:00
// this is the end of the virtual stick
Vector2D end;
2024-06-26 17:14:16 +02:00
// calculate the angle of the cursor if air
double calculateAir();
// ring buffer of last position samples
std::vector<Vector2D> samples;
int samples_index = 0;
2024-06-27 17:21:39 +02:00
double calculateShake();
std::vector<Vector2D> shake_samples;
std::vector<double> shake_samples_distance;
int shake_samples_index = 0;
2024-06-21 14:32:42 +02:00
};
inline std::unique_ptr<CDynamicCursors> g_pDynamicCursors;