hyprland-plugins/hyprtrails/trail.hpp

66 lines
1.8 KiB
C++
Raw Permalink 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:
2024-04-27 14:03:46 +02:00
CTrail(PHLWINDOW);
2023-11-04 01:39:14 +01:00
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
2024-03-31 03:18:20 +02:00
virtual void draw(CMonitor*, float a);
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
2024-04-27 14:03:46 +02:00
virtual void updateWindow(PHLWINDOW);
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:
2024-05-08 14:48:33 +02:00
SP<HOOK_CALLBACK_FN> pTickCb;
2023-11-04 18:28:57 +01:00
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
SBoxExtents m_seExtents;
2023-11-04 01:39:14 +01:00
2024-04-27 14:03:46 +02:00
PHLWINDOWREF m_pWindow;
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;
};