fix: fix damage issues

This commit is contained in:
Virt 2024-06-21 16:36:10 +02:00
commit facfa7f356
4 changed files with 38 additions and 3 deletions

View file

@ -13,7 +13,7 @@
#include "cursor.hpp"
#include "renderer.hpp"
void CDynamicCursors::render(CPointerManager* pointers, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
void CDynamicCursors::renderSoftware(CPointerManager* pointers, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
if (!pointers->hasCursor())
return;
@ -38,11 +38,33 @@ void CDynamicCursors::render(CPointerManager* pointers, SP<CMonitor> pMonitor, t
return;
box.scale(pMonitor->scale);
// we rotate the cursor by our calculated amount
box.rot = this->calculate(&pointers->pointerPos);
// now pass the hotspot to rotate around
renderCursorTextureInternalWithDamage(texture, &box, &damage, 1.F, pointers->currentCursorImage.hotspot);
}
void CDynamicCursors::damageSoftware(CPointerManager* pointers) {
// we damage a 3x3 area around the cursor, to accomodate for all possible hotspots and rotations
Vector2D size = pointers->currentCursorImage.size / pointers->currentCursorImage.scale;
CBox b = CBox{pointers->pointerPos, size * 3}.translate(-(pointers->currentCursorImage.hotspot + size));
static auto PNOHW = CConfigValue<Hyprlang::INT>("cursor:no_hardware_cursors");
for (auto& mw : pointers->monitorStates) {
if (mw->monitor.expired())
continue;
if ((mw->softwareLocks > 0 || mw->hardwareFailed || *PNOHW) && b.overlaps({mw->monitor->vecPosition, mw->monitor->vecSize})) {
g_pHyprRenderer->damageBox(&b, mw->monitor->shouldSkipScheduleFrameOnMouseEvent());
break;
}
}
}
double CDynamicCursors::calculate(Vector2D* pos) {
static auto* const* PLENGTH = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_LENGTH)->getDataStaticPtr();