2024-07-03 00:38:50 +02:00
|
|
|
#include "config/config.hpp"
|
2024-07-02 15:35:37 +02:00
|
|
|
#include "mode/Mode.hpp"
|
2024-06-26 17:14:16 +02:00
|
|
|
#include "src/debug/Log.hpp"
|
2024-07-21 15:38:46 +02:00
|
|
|
#include "src/helpers/math/Math.hpp"
|
2024-06-30 22:38:08 +02:00
|
|
|
#include "src/managers/eventLoop/EventLoopManager.hpp"
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
#include <cmath>
|
2024-06-22 15:01:47 +02:00
|
|
|
#include <cstdlib>
|
2024-06-26 17:14:16 +02:00
|
|
|
#include <cstring>
|
2024-06-27 17:21:39 +02:00
|
|
|
#include <hyprlang.hpp>
|
2024-07-21 15:38:46 +02:00
|
|
|
#include <gbm.h>
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
#define private public
|
|
|
|
#include <hyprland/src/managers/PointerManager.hpp>
|
2024-06-21 16:06:55 +02:00
|
|
|
#include <hyprland/src/render/OpenGL.hpp>
|
2024-06-22 15:01:47 +02:00
|
|
|
#include <hyprland/src/Compositor.hpp>
|
2024-06-21 14:32:42 +02:00
|
|
|
#undef private
|
|
|
|
|
2024-06-21 16:06:55 +02:00
|
|
|
#include <hyprland/src/config/ConfigValue.hpp>
|
2024-07-03 14:29:33 +02:00
|
|
|
#include <hyprland/src/protocols/core/Compositor.hpp>
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-06-21 16:06:55 +02:00
|
|
|
#include "cursor.hpp"
|
|
|
|
#include "renderer.hpp"
|
2024-06-21 14:32:42 +02:00
|
|
|
|
2024-06-30 22:38:08 +02:00
|
|
|
void tickRaw(SP<CEventLoopTimer> self, void* data) {
|
2024-07-03 00:38:50 +02:00
|
|
|
static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED);
|
2024-06-30 22:38:08 +02:00
|
|
|
|
|
|
|
if (**PENABLED && g_pDynamicCursors)
|
|
|
|
g_pDynamicCursors->onTick(g_pPointerManager.get());
|
|
|
|
|
|
|
|
const int TIMEOUT = g_pHyprRenderer->m_pMostHzMonitor ? 1000.0 / g_pHyprRenderer->m_pMostHzMonitor->refreshRate : 16;
|
|
|
|
self->updateTimeout(std::chrono::milliseconds(TIMEOUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
CDynamicCursors::CDynamicCursors() {
|
|
|
|
this->tick = SP<CEventLoopTimer>(new CEventLoopTimer(std::chrono::microseconds(500), tickRaw, nullptr));
|
|
|
|
g_pEventLoopManager->addTimer(this->tick);
|
|
|
|
}
|
|
|
|
|
|
|
|
CDynamicCursors::~CDynamicCursors() {
|
|
|
|
// stop and deallocate timer
|
|
|
|
g_pEventLoopManager->removeTimer(this->tick);
|
|
|
|
this->tick.reset();
|
|
|
|
|
|
|
|
// release software lock
|
|
|
|
if (zoomSoftware) {
|
|
|
|
g_pPointerManager->unlockSoftwareAll();
|
|
|
|
zoomSoftware = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
/*
|
|
|
|
Reimplements rendering of the software cursor.
|
|
|
|
Is also largely identical to hyprlands impl, but uses our custom rendering to rotate the cursor.
|
|
|
|
*/
|
2024-06-21 16:36:10 +02:00
|
|
|
void CDynamicCursors::renderSoftware(CPointerManager* pointers, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
|
2024-07-03 00:38:50 +02:00
|
|
|
static auto* const* PNEAREST = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_NEAREST);
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
if (!pointers->hasCursor())
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto state = pointers->stateFor(pMonitor);
|
2024-07-02 15:35:37 +02:00
|
|
|
auto zoom = resultShown.scale;
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
if ((!state->hardwareFailed && state->softwareLocks == 0)) {
|
2024-07-03 14:29:33 +02:00
|
|
|
if (pointers->currentCursorImage.surface)
|
|
|
|
pointers->currentCursorImage.surface->resource()->frame(now);
|
|
|
|
|
2024-06-21 14:32:42 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto box = state->box.copy();
|
|
|
|
if (overridePos.has_value()) {
|
|
|
|
box.x = overridePos->x;
|
|
|
|
box.y = overridePos->y;
|
|
|
|
}
|
|
|
|
|
2024-06-28 16:31:47 +02:00
|
|
|
// poperly transform hotspot, this first has to undo the hotspot transform from getCursorBoxGlobal
|
|
|
|
box.x = box.x + pointers->currentCursorImage.hotspot.x - pointers->currentCursorImage.hotspot.x * zoom;
|
|
|
|
box.y = box.y + pointers->currentCursorImage.hotspot.y - pointers->currentCursorImage.hotspot.y * zoom;
|
|
|
|
|
2024-06-21 14:32:42 +02:00
|
|
|
if (box.intersection(CBox{{}, {pMonitor->vecSize}}).empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto texture = pointers->getCurrentCursorTexture();
|
|
|
|
if (!texture)
|
|
|
|
return;
|
|
|
|
|
|
|
|
box.scale(pMonitor->scale);
|
2024-06-27 17:21:39 +02:00
|
|
|
box.w *= zoom;
|
|
|
|
box.h *= zoom;
|
2024-06-21 16:36:10 +02:00
|
|
|
|
|
|
|
// we rotate the cursor by our calculated amount
|
2024-07-02 15:35:37 +02:00
|
|
|
box.rot = resultShown.rotation;
|
2024-06-21 14:32:42 +02:00
|
|
|
|
2024-06-21 16:36:10 +02:00
|
|
|
// now pass the hotspot to rotate around
|
2024-07-21 15:38:46 +02:00
|
|
|
renderCursorTextureInternalWithDamage(texture, &box, &damage, 1.F, nullptr, 0, pointers->currentCursorImage.hotspot * state->monitor->scale * zoom, zoom > 1 && **PNEAREST, resultShown.stretch.angle, resultShown.stretch.magnitude);
|
2024-07-03 14:29:33 +02:00
|
|
|
|
|
|
|
if (pointers->currentCursorImage.surface)
|
|
|
|
pointers->currentCursorImage.surface->resource()->frame(now);
|
2024-06-21 14:32:42 +02:00
|
|
|
}
|
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
/*
|
|
|
|
This function implements damaging the screen such that the software cursor is drawn.
|
|
|
|
It is largely identical to hyprlands implementation, but expands the damage reagion, to accomodate various rotations.
|
|
|
|
*/
|
2024-06-21 16:36:10 +02:00
|
|
|
void CDynamicCursors::damageSoftware(CPointerManager* pointers) {
|
|
|
|
|
2024-07-03 16:25:02 +02:00
|
|
|
// we damage a padding of the diagonal around the hotspot, to accomodate for all possible hotspots and rotations
|
2024-07-02 15:35:37 +02:00
|
|
|
auto zoom = resultShown.scale;
|
2024-06-27 17:21:39 +02:00
|
|
|
Vector2D size = pointers->currentCursorImage.size / pointers->currentCursorImage.scale * zoom;
|
2024-07-18 08:49:59 +02:00
|
|
|
int diagonal = size.size();
|
2024-07-03 16:25:02 +02:00
|
|
|
Vector2D padding = {diagonal, diagonal};
|
|
|
|
|
|
|
|
CBox b = CBox{pointers->pointerPos, size + (padding * 2)}.translate(-(pointers->currentCursorImage.hotspot * zoom + padding));
|
2024-06-21 16:36:10 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
/*
|
|
|
|
This function reimplements the hardware cursor buffer drawing.
|
|
|
|
It is largely copied from hyprland, but adjusted to allow the cursor to be rotated.
|
|
|
|
*/
|
2024-07-21 15:38:46 +02:00
|
|
|
SP<Aquamarine::IBuffer> CDynamicCursors::renderHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture) {
|
|
|
|
static auto* const* PHW_DEBUG = (Hyprlang::INT* const*) getConfig(CONFIG_HW_DEBUG);
|
2024-07-03 00:38:50 +02:00
|
|
|
static auto* const* PNEAREST = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_NEAREST);
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
auto output = state->monitor->output;
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
auto maxSize = output->cursorPlaneSize();
|
|
|
|
auto zoom = resultShown.scale;
|
2024-07-03 16:25:02 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
auto cursorSize = pointers->currentCursorImage.size * zoom;
|
|
|
|
int cursorDiagonal = cursorSize.size();
|
|
|
|
auto cursorPadding = Vector2D{cursorDiagonal, cursorDiagonal};
|
|
|
|
auto targetSize = cursorSize + cursorPadding * 2;
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (maxSize == Vector2D{})
|
|
|
|
return nullptr;
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (maxSize != Vector2D{-1, -1}) {
|
|
|
|
if (targetSize.x > maxSize.x || targetSize.y > maxSize.y) {
|
|
|
|
Debug::log(TRACE, "hardware cursor too big! {} > {}", pointers->currentCursorImage.size, maxSize);
|
2024-06-22 15:01:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2024-07-21 15:38:46 +02:00
|
|
|
} else
|
|
|
|
maxSize = targetSize;
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (!state->monitor->cursorSwapchain || maxSize != state->monitor->cursorSwapchain->currentOptions().size) {
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (!state->monitor->cursorSwapchain)
|
|
|
|
state->monitor->cursorSwapchain = Aquamarine::CSwapchain::create(state->monitor->output->getBackend()->preferredAllocator(), state->monitor->output->getBackend());
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
auto options = state->monitor->cursorSwapchain->currentOptions();
|
|
|
|
options.size = maxSize;
|
|
|
|
options.length = 2;
|
|
|
|
options.scanout = true;
|
|
|
|
options.cursor = true;
|
|
|
|
options.multigpu = state->monitor->output->getBackend()->preferredAllocator()->drmFD() != g_pCompositor->m_iDRMFD;
|
|
|
|
// We do not set the format. If it's unset (DRM_FORMAT_INVALID) then the swapchain will pick for us,
|
|
|
|
// but if it's set, we don't wanna change it.
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (!state->monitor->cursorSwapchain->reconfigure(options)) {
|
|
|
|
Debug::log(TRACE, "Failed to reconfigure cursor swapchain");
|
2024-06-22 15:01:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
auto buf = state->monitor->cursorSwapchain->next(nullptr);
|
2024-06-22 15:01:47 +02:00
|
|
|
if (!buf) {
|
|
|
|
Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CRegion damage = {0, 0, INT16_MAX, INT16_MAX};
|
|
|
|
|
|
|
|
g_pHyprRenderer->makeEGLCurrent();
|
2024-07-21 15:38:46 +02:00
|
|
|
g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor.get();
|
|
|
|
|
|
|
|
auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format);
|
|
|
|
if (!RBO) {
|
|
|
|
|
|
|
|
// dumb copy won't work with this plugin, as we just copy the buffer, and can't apply transformations to it
|
|
|
|
Debug::log(TRACE, "Failed to create cursor RB with format {}, mod {}", buf->dmabuf().format, buf->dmabuf().modifier);
|
|
|
|
static auto PDUMB = CConfigValue<Hyprlang::INT>("cursor:allow_dumb_copy");
|
|
|
|
if (!*PDUMB)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
auto bufData = buf->beginDataPtr(0);
|
|
|
|
auto bufPtr = std::get<0>(bufData);
|
|
|
|
|
|
|
|
// clear buffer
|
|
|
|
memset(bufPtr, 0, std::get<2>(bufData));
|
|
|
|
|
|
|
|
auto texBuffer = pointers->currentCursorImage.pBuffer ? pointers->currentCursorImage.pBuffer : pointers->currentCursorImage.surface->resource()->current.buffer;
|
|
|
|
|
|
|
|
if (texBuffer) {
|
|
|
|
auto textAttrs = texBuffer->shm();
|
|
|
|
auto texData = texBuffer->beginDataPtr(GBM_BO_TRANSFER_WRITE);
|
|
|
|
auto texPtr = std::get<0>(texData);
|
|
|
|
Debug::log(TRACE, "cursor texture {}x{} {} {} {}", textAttrs.size.x, textAttrs.size.y, (void*)texPtr, textAttrs.format, textAttrs.stride);
|
|
|
|
// copy cursor texture
|
|
|
|
for (int i = 0; i < texBuffer->shm().size.y; i++)
|
|
|
|
memcpy(bufPtr + i * buf->dmabuf().strides[0], texPtr + i * textAttrs.stride, textAttrs.stride);
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->endDataPtr();
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
RBO->bind();
|
|
|
|
|
|
|
|
g_pHyprOpenGL->beginSimple(state->monitor.get(), damage, RBO);
|
|
|
|
|
|
|
|
if (**PHW_DEBUG)
|
|
|
|
g_pHyprOpenGL->clear(CColor{rand() / float(RAND_MAX), rand() / float(RAND_MAX), rand() / float(RAND_MAX), 1.F});
|
|
|
|
else
|
|
|
|
g_pHyprOpenGL->clear(CColor{0.F, 0.F, 0.F, 0.F});
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
|
2024-06-22 15:01:47 +02:00
|
|
|
// the box should start in the middle portion, rotate by our calculated amount
|
2024-07-21 15:38:46 +02:00
|
|
|
CBox xbox = {cursorPadding, Vector2D{pointers->currentCursorImage.size / pointers->currentCursorImage.scale * state->monitor->scale * zoom}.round()};
|
2024-07-02 15:35:37 +02:00
|
|
|
xbox.rot = resultShown.rotation;
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
// use our custom draw function
|
2024-07-21 15:38:46 +02:00
|
|
|
renderCursorTextureInternalWithDamage(texture, &xbox, &damage, 1.F, pointers->currentCursorImage.waitTimeline, pointers->currentCursorImage.waitPoint, pointers->currentCursorImage.hotspot * state->monitor->scale * zoom, zoom > 1 && **PNEAREST, resultShown.stretch.angle, resultShown.stretch.magnitude);
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
g_pHyprOpenGL->end();
|
|
|
|
glFlush();
|
|
|
|
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr;
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
g_pHyprRenderer->onRenderbufferDestroy(RBO.get());
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Implements the hardware cursor setting.
|
|
|
|
It is also mostly the same as stock hyprland, but with the hotspot translated more into the middle.
|
|
|
|
*/
|
2024-07-21 15:38:46 +02:00
|
|
|
bool CDynamicCursors::setHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<Aquamarine::IBuffer> buf) {
|
|
|
|
if (!(state->monitor->output->getBackend()->capabilities() & Aquamarine::IBackendImplementation::eBackendCapabilities::AQ_BACKEND_CAPABILITY_POINTER))
|
2024-06-22 15:01:47 +02:00
|
|
|
return false;
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
auto PMONITOR = state->monitor.lock();
|
2024-06-26 11:44:27 +02:00
|
|
|
|
2024-07-03 16:25:02 +02:00
|
|
|
// we need to transform the hotspot manually as we need to indent it by the padding
|
2024-07-18 08:49:59 +02:00
|
|
|
int diagonal = pointers->currentCursorImage.size.size();
|
2024-07-03 16:25:02 +02:00
|
|
|
Vector2D padding = {diagonal, diagonal};
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
const auto HOTSPOT = CBox{((pointers->currentCursorImage.hotspot * PMONITOR->scale) + padding) * resultShown.scale, {0, 0}}
|
|
|
|
.transform(wlTransformToHyprutils(invertTransform(PMONITOR->transform)), PMONITOR->cursorSwapchain->currentOptions().size.x, PMONITOR->cursorSwapchain->currentOptions().size.y)
|
2024-06-26 11:44:27 +02:00
|
|
|
.pos();
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
Debug::log(TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->szName, HOTSPOT);
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
if (!state->monitor->output->setCursor(buf, HOTSPOT))
|
2024-06-22 15:01:47 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
state->cursorFrontBuffer = buf;
|
|
|
|
|
2024-07-21 15:38:46 +02:00
|
|
|
g_pCompositor->scheduleFrameForMonitor(state->monitor.get(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
|
2024-06-22 15:01:47 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Handles cursor move events.
|
|
|
|
*/
|
|
|
|
void CDynamicCursors::onCursorMoved(CPointerManager* pointers) {
|
|
|
|
if (!pointers->hasCursor())
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
|
|
|
auto state = pointers->stateFor(m);
|
|
|
|
|
|
|
|
state->box = pointers->getCursorBoxLogicalForMonitor(state->monitor.lock());
|
|
|
|
|
|
|
|
if (state->hardwareFailed || !state->entered)
|
|
|
|
continue;
|
|
|
|
|
2024-06-22 15:46:00 +02:00
|
|
|
const auto CURSORPOS = pointers->getCursorPosForMonitor(m);
|
2024-07-21 15:38:46 +02:00
|
|
|
m->output->moveCursor(CURSORPOS);
|
2024-06-26 17:14:16 +02:00
|
|
|
}
|
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
calculate(MOVE);
|
2024-06-26 17:14:16 +02:00
|
|
|
}
|
|
|
|
|
2024-07-03 00:38:50 +02:00
|
|
|
void CDynamicCursors::setShape(const std::string& shape) {
|
|
|
|
g_pShapeRuleHandler->activate(shape);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDynamicCursors::unsetShape() {
|
|
|
|
g_pShapeRuleHandler->activate("clientside");
|
|
|
|
}
|
|
|
|
|
2024-06-26 18:02:09 +02:00
|
|
|
/*
|
|
|
|
Handle cursor tick events.
|
|
|
|
*/
|
2024-06-26 17:14:16 +02:00
|
|
|
void CDynamicCursors::onTick(CPointerManager* pointers) {
|
2024-06-28 14:08:13 +02:00
|
|
|
calculate(TICK);
|
|
|
|
}
|
|
|
|
|
|
|
|
IMode* CDynamicCursors::currentMode() {
|
2024-07-03 00:38:50 +02:00
|
|
|
static auto const* PMODE = (Hyprlang::STRING const*) getConfig(CONFIG_MODE);
|
|
|
|
auto mode = g_pShapeRuleHandler->getModeOr(*PMODE);
|
2024-06-26 18:02:09 +02:00
|
|
|
|
2024-07-03 00:38:50 +02:00
|
|
|
if (mode == "rotate") return &rotate;
|
|
|
|
else if (mode == "tilt") return &tilt;
|
|
|
|
else if (mode == "stretch") return &stretch;
|
2024-06-28 14:08:13 +02:00
|
|
|
else return nullptr;
|
2024-06-26 17:14:16 +02:00
|
|
|
}
|
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
void CDynamicCursors::calculate(EModeUpdate type) {
|
2024-07-03 00:38:50 +02:00
|
|
|
static auto* const* PTHRESHOLD = (Hyprlang::INT* const*) getConfig(CONFIG_THRESHOLD);
|
|
|
|
static auto* const* PSHAKE = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE);
|
|
|
|
static auto* const* PSHAKE_EFFECTS = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_EFFECTS);
|
2024-06-27 17:21:39 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
IMode* mode = currentMode();
|
2024-06-26 17:14:16 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
// calculate angle and zoom
|
|
|
|
if (mode) {
|
2024-07-02 15:35:37 +02:00
|
|
|
if (mode->strategy() == type) resultMode = mode->update(g_pPointerManager->pointerPos);
|
|
|
|
} else resultMode = SModeResult();
|
2024-06-27 17:21:39 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
if (**PSHAKE) {
|
2024-07-02 15:35:37 +02:00
|
|
|
if (type == TICK) resultShake = shake.update(g_pPointerManager->pointerPos);
|
2024-06-28 14:08:13 +02:00
|
|
|
|
2024-07-02 15:35:37 +02:00
|
|
|
// reset mode results if shaking
|
|
|
|
if (resultShake > 1 && !**PSHAKE_EFFECTS) resultMode = SModeResult();
|
|
|
|
} else resultShake = 1;
|
2024-06-29 15:38:59 +02:00
|
|
|
|
2024-07-02 15:35:37 +02:00
|
|
|
auto result = resultMode;
|
|
|
|
result.scale *= resultShake;
|
2024-06-29 15:38:59 +02:00
|
|
|
|
2024-07-02 15:35:37 +02:00
|
|
|
if (resultShown.hasDifference(&result, **PTHRESHOLD * (PI / 180.0), 0.01, 0.01)) {
|
|
|
|
resultShown = result;
|
|
|
|
resultShown.clamp(**PTHRESHOLD * (PI / 180.0), 0.01, 0.01); // clamp low values so it is rendered pixel-perfectly when no effect
|
2024-06-28 14:08:13 +02:00
|
|
|
|
|
|
|
// lock software cursors if zooming
|
2024-07-02 15:35:37 +02:00
|
|
|
if (resultShown.scale > 1) {
|
2024-06-28 14:08:13 +02:00
|
|
|
if (!zoomSoftware) {
|
|
|
|
g_pPointerManager->lockSoftwareAll();
|
|
|
|
zoomSoftware = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (zoomSoftware) {
|
|
|
|
// damage so it is cleared properly
|
|
|
|
g_pPointerManager->damageIfSoftware();
|
|
|
|
|
|
|
|
g_pPointerManager->unlockSoftwareAll();
|
|
|
|
zoomSoftware = false;
|
|
|
|
}
|
|
|
|
}
|
2024-06-26 17:14:16 +02:00
|
|
|
|
|
|
|
// damage software and change hardware cursor shape
|
|
|
|
g_pPointerManager->damageIfSoftware();
|
|
|
|
|
2024-07-03 00:38:50 +02:00
|
|
|
bool entered = false;
|
|
|
|
|
2024-06-26 17:14:16 +02:00
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
|
|
|
auto state = g_pPointerManager->stateFor(m);
|
2024-07-03 00:38:50 +02:00
|
|
|
|
|
|
|
if (state->entered) entered = true;
|
2024-06-26 17:14:16 +02:00
|
|
|
if (state->hardwareFailed || !state->entered)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_pPointerManager->attemptHardwareCursor(state);
|
|
|
|
}
|
2024-07-03 00:38:50 +02:00
|
|
|
|
|
|
|
// there should always be one monitor entered
|
|
|
|
// this fixes an issue wheter the cursor shape would not properly update after change
|
|
|
|
if (!entered) {
|
|
|
|
Debug::log(LOG, "[dynamic-cursors] updating because none entered");
|
|
|
|
g_pPointerManager->recheckEnteredOutputs();
|
|
|
|
g_pPointerManager->updateCursorBackend();
|
|
|
|
}
|
2024-06-26 17:14:16 +02:00
|
|
|
}
|
|
|
|
}
|