hyprland-plugins/hyprtrails/trail.hpp

65 lines
1.9 KiB
C++
Raw Normal View History

2023-11-04 01:39:14 +01:00
#pragma once
#define WLR_USE_UNSTABLE
#include <deque>
#include <hyprland/src/plugins/PluginAPI.hpp>
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
struct box {
float x = 0, y = 0, w = 0, h = 0;
2023-11-04 18:28:57 +01:00
//
Vector2D middle() {
return Vector2D{x + w / 2.0, y + h / 2.0};
}
2023-11-04 01:39:14 +01:00
};
struct point2 {
point2(const Vector2D& v) {
x = v.x;
y = v.y;
}
point2() {
x = 0;
y = 0;
}
float x = 0, y = 0;
};
class CTrail : public IHyprWindowDecoration {
2023-11-04 18:28:57 +01:00
public:
2023-11-04 01:39:14 +01:00
CTrail(CWindow*);
virtual ~CTrail();
2023-11-11 15:39:46 +01:00
virtual SDecorationPositioningInfo getPositioningInfo();
2023-11-04 01:39:14 +01:00
2023-11-11 15:39:46 +01:00
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
2023-11-04 01:39:14 +01:00
2023-11-11 15:39:46 +01:00
virtual void draw(CMonitor*, float a, const Vector2D& offset);
2023-11-04 01:39:14 +01:00
2023-11-11 15:39:46 +01:00
virtual eDecorationType getDecorationType();
2023-11-04 01:39:14 +01:00
2023-11-11 15:39:46 +01:00
virtual void updateWindow(CWindow*);
2023-11-04 01:39:14 +01:00
2023-11-11 15:39:46 +01:00
virtual void damageEntire();
2023-11-04 01:39:14 +01:00
2023-11-04 18:28:57 +01:00
private:
HOOK_CALLBACK_FN* pTickCb = nullptr;
void onTick();
2023-11-04 01:39:14 +01:00
std::deque<std::pair<box, std::chrono::system_clock::time_point>> m_dLastGeoms;
2023-11-04 18:28:57 +01:00
int m_iTimer = 0;
2023-11-04 01:39:14 +01:00
2023-11-04 18:28:57 +01:00
SWindowDecorationExtents m_seExtents;
2023-11-04 01:39:14 +01:00
2023-11-04 18:28:57 +01:00
CWindow* m_pWindow = nullptr;
2023-11-04 01:39:14 +01:00
2023-11-04 18:28:57 +01:00
Vector2D m_vLastWindowPos;
Vector2D m_vLastWindowSize;
2023-11-04 01:39:14 +01:00
2023-11-04 18:28:57 +01:00
CBox m_bLastBox = {0};
bool m_bNeedsDamage = false;
2023-11-04 01:39:14 +01:00
};