hypr-dynamic-cursors/src/cursor.hpp

74 lines
2.3 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>
#include <hyprland/src/managers/eventLoop/EventLoopManager.hpp>
2024-06-21 14:32:42 +02:00
#include "mode/ModeRotate.hpp"
#include "mode/ModeTilt.hpp"
2024-07-02 15:35:37 +02:00
#include "mode/ModeStretch.hpp"
#include "other/Shake.hpp"
2024-06-21 14:32:42 +02:00
class CDynamicCursors {
public:
CDynamicCursors();
~CDynamicCursors();
/* 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 */
2024-07-21 15:38:46 +02:00
SP<Aquamarine::IBuffer> renderHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture);
/* hook on setHWCursorBuffer */
2024-07-21 15:38:46 +02:00
bool setHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<Aquamarine::IBuffer> buf);
2024-06-21 14:32:42 +02:00
2024-07-03 00:38:50 +02:00
/* hook on setCursorFromName */
void setShape(const std::string& name);
/* hook on setCursorSoftware */
void unsetShape();
2024-08-25 22:58:55 +02:00
/* hook on move, indicate that next onCursorMoved is actual move */
void setMove();
2024-06-21 14:32:42 +02:00
private:
SP<CEventLoopTimer> tick;
2024-07-02 15:35:37 +02:00
// current state of the cursor
SModeResult resultMode;
double resultShake;
2024-08-25 22:58:55 +02:00
Vector2D lastPos; // used for warp compensation
2024-07-02 15:35:37 +02:00
SModeResult resultShown;
// whether we have already locked software for cursor zoom
bool zoomSoftware = false;
// modes
CModeRotate rotate;
CModeTilt tilt;
2024-07-02 15:35:37 +02:00
CModeStretch stretch;
/* returns the current mode, nullptr if none is selected */
IMode* currentMode();
IMode* lastMode; // used to reset the mode if it was switched (to prune stale data)
// shake
CShake shake;
2024-08-25 22:58:55 +02:00
/* is set true if a genuine move is being performed, and will be reset to false after onCursorMoved */
bool isMove = false;
2024-06-26 17:14:16 +02:00
// calculates the current angle of the cursor, and changes the cursor shape
void calculate(EModeUpdate type);
2024-06-21 14:32:42 +02:00
};
inline std::unique_ptr<CDynamicCursors> g_pDynamicCursors;