2024-03-07 04:19:38 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cairo/cairo.h>
|
|
|
|
|
|
|
|
class CHyprcursorImplementation;
|
|
|
|
|
|
|
|
namespace Hyprcursor {
|
|
|
|
|
|
|
|
/*!
|
2024-03-07 15:50:48 +01:00
|
|
|
Simple struct for styles
|
2024-03-07 04:19:38 +01:00
|
|
|
*/
|
2024-03-07 15:50:48 +01:00
|
|
|
struct SCursorStyleInfo {
|
2024-03-07 16:10:45 +01:00
|
|
|
/*!
|
2024-03-07 15:50:48 +01:00
|
|
|
Shape size.
|
|
|
|
|
|
|
|
0 means "any" or "unspecified".
|
2024-03-07 04:19:38 +01:00
|
|
|
*/
|
|
|
|
unsigned int size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Basic Hyprcursor manager.
|
|
|
|
|
|
|
|
Has to be created for either a specified theme, or
|
|
|
|
nullptr if you want to use a default from the env.
|
|
|
|
|
|
|
|
If no env is set, picks the first found.
|
|
|
|
|
|
|
|
If none found, bool valid() will be false.
|
|
|
|
|
|
|
|
If loading fails, bool valid() will be false.
|
|
|
|
*/
|
|
|
|
class CHyprcursorManager {
|
|
|
|
public:
|
|
|
|
CHyprcursorManager(const char* themeName);
|
|
|
|
~CHyprcursorManager();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the theme was successfully loaded,
|
|
|
|
i.e. everything is A-OK and nothing should fail.
|
|
|
|
*/
|
|
|
|
bool valid();
|
|
|
|
|
2024-03-07 15:50:48 +01:00
|
|
|
/*!
|
|
|
|
Loads this theme at a given style, synchronously.
|
2024-03-07 16:10:45 +01:00
|
|
|
|
|
|
|
Returns whether it succeeded.
|
2024-03-07 15:50:48 +01:00
|
|
|
*/
|
|
|
|
bool loadThemeStyle(const SCursorStyleInfo& info);
|
|
|
|
|
2024-03-07 04:19:38 +01:00
|
|
|
/*!
|
|
|
|
Returns a cairo_surface_t for a given cursor
|
|
|
|
shape and size.
|
|
|
|
|
2024-03-07 15:50:48 +01:00
|
|
|
Once done with a size, call cursorSurfaceDone()
|
2024-03-07 04:19:38 +01:00
|
|
|
*/
|
2024-03-07 15:50:48 +01:00
|
|
|
cairo_surface_t* getSurfaceFor(const char* shape, const SCursorStyleInfo& info);
|
2024-03-07 04:19:38 +01:00
|
|
|
|
|
|
|
/*!
|
2024-03-07 15:50:48 +01:00
|
|
|
Marks a certain style as done, allowing it to be potentially freed
|
2024-03-07 04:19:38 +01:00
|
|
|
*/
|
2024-03-07 15:50:48 +01:00
|
|
|
void cursorSurfaceStyleDone(const SCursorStyleInfo&);
|
2024-03-07 04:19:38 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
CHyprcursorImplementation* impl = nullptr;
|
|
|
|
bool finalizedAndValid = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|