2024-06-21 14:32:42 +02:00
|
|
|
#include "globals.hpp"
|
2024-11-09 16:12:27 +01:00
|
|
|
#include <memory>
|
2024-06-28 14:08:13 +02:00
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
#define private public
|
2024-06-21 14:32:42 +02:00
|
|
|
#include <hyprland/src/managers/PointerManager.hpp>
|
2024-06-22 15:01:47 +02:00
|
|
|
#undef private
|
2024-06-21 14:32:42 +02:00
|
|
|
#include <hyprutils/math/Vector2D.hpp>
|
2024-06-30 22:38:08 +02:00
|
|
|
#include <hyprland/src/managers/eventLoop/EventLoopManager.hpp>
|
2024-11-09 16:12:27 +01:00
|
|
|
#include <hyprcursor/hyprcursor.hpp>
|
2024-06-21 14:32:42 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
#include "mode/ModeRotate.hpp"
|
|
|
|
#include "mode/ModeTilt.hpp"
|
2024-07-02 15:35:37 +02:00
|
|
|
#include "mode/ModeStretch.hpp"
|
2024-06-28 14:08:13 +02:00
|
|
|
#include "other/Shake.hpp"
|
2024-11-09 16:12:27 +01:00
|
|
|
#include "highres.hpp"
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
class CDynamicCursors {
|
|
|
|
public:
|
2024-06-30 22:38:08 +02:00
|
|
|
CDynamicCursors();
|
|
|
|
~CDynamicCursors();
|
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
/* hook on onCursorMoved */
|
|
|
|
void onCursorMoved(CPointerManager* pointers);
|
2024-06-26 17:14:16 +02:00
|
|
|
/* called on tick */
|
|
|
|
void onTick(CPointerManager* pointers);
|
2024-06-22 15:01:47 +02:00
|
|
|
|
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);
|
2024-06-22 15:01:47 +02:00
|
|
|
/* hook on renderHWCursorBuffer */
|
2024-07-21 15:38:46 +02:00
|
|
|
SP<Aquamarine::IBuffer> renderHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture);
|
2024-06-22 15:01:47 +02:00
|
|
|
/* 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-11-09 16:12:27 +01:00
|
|
|
/* hook on updateTheme */
|
|
|
|
void updateTheme();
|
2024-07-03 00:38:50 +02:00
|
|
|
|
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:
|
2024-06-30 22:38:08 +02:00
|
|
|
SP<CEventLoopTimer> tick;
|
|
|
|
|
2024-11-09 16:12:27 +01:00
|
|
|
/* hyprcursor handler for highres images */
|
|
|
|
CHighresHandler highres;
|
|
|
|
|
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;
|
2024-06-28 14:08:13 +02:00
|
|
|
|
|
|
|
// 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;
|
2024-10-10 13:04:46 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
/* returns the current mode, nullptr if none is selected */
|
|
|
|
IMode* currentMode();
|
2024-10-10 13:04:46 +02:00
|
|
|
IMode* lastMode; // used to reset the mode if it was switched (to prune stale data)
|
2024-06-28 14:08:13 +02:00
|
|
|
|
|
|
|
// shake
|
|
|
|
CShake shake;
|
2024-06-22 15:46:00 +02:00
|
|
|
|
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
|
2024-06-28 14:08:13 +02:00
|
|
|
void calculate(EModeUpdate type);
|
2024-06-21 14:32:42 +02:00
|
|
|
};
|
|
|
|
|
2024-11-09 16:12:27 +01:00
|
|
|
inline UP<CDynamicCursors> g_pDynamicCursors;
|