renderer: add mouse zoom animations (#10882)
Adds animations for the mouse zoom effect.
This commit is contained in:
parent
e827b75e22
commit
e9c5594186
6 changed files with 20 additions and 10 deletions
|
|
@ -972,6 +972,7 @@ void CConfigManager::setDefaultAnimationVars() {
|
|||
m_animationTree.createNode("border", "global");
|
||||
m_animationTree.createNode("borderangle", "global");
|
||||
m_animationTree.createNode("workspaces", "global");
|
||||
m_animationTree.createNode("zoomFactor", "global");
|
||||
|
||||
// layer
|
||||
m_animationTree.createNode("layersIn", "layers");
|
||||
|
|
@ -1129,8 +1130,11 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
|
|||
w->uncacheWindowDecos();
|
||||
}
|
||||
|
||||
for (auto const& m : g_pCompositor->m_monitors)
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
for (auto const& m : g_pCompositor->m_monitors) {
|
||||
*(m->m_cursorZoom) = *PZOOMFACTOR;
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->m_id);
|
||||
}
|
||||
|
||||
// Update the keyboard layout to the cfg'd one if this is not the first launch
|
||||
if (!m_isFirstLaunch) {
|
||||
|
|
|
|||
|
|
@ -1142,7 +1142,9 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
|
|||
// decorations will probably need a repaint
|
||||
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source" ||
|
||||
COMMAND.starts_with("windowrule")) {
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
for (auto const& m : g_pCompositor->m_monitors) {
|
||||
*(m->m_cursorZoom) = *PZOOMFACTOR;
|
||||
g_pHyprRenderer->damageMonitor(m);
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->m_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ static int ratHandler(void* data) {
|
|||
CMonitor::CMonitor(SP<Aquamarine::IOutput> output_) : m_state(this), m_output(output_) {
|
||||
g_pAnimationManager->createAnimation(0.f, m_specialFade, g_pConfigManager->getAnimationPropertyConfig("specialWorkspaceIn"), AVARDAMAGE_NONE);
|
||||
m_specialFade->setUpdateCallback([this](auto) { g_pHyprRenderer->damageMonitor(m_self.lock()); });
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
g_pAnimationManager->createAnimation(*PZOOMFACTOR, m_cursorZoom, g_pConfigManager->getAnimationPropertyConfig("zoomFactor"), AVARDAMAGE_NONE);
|
||||
m_cursorZoom->setUpdateCallback([this](auto) { g_pHyprRenderer->damageMonitor(m_self.lock()); });
|
||||
}
|
||||
|
||||
CMonitor::~CMonitor() {
|
||||
|
|
@ -917,8 +920,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
|
|||
}
|
||||
|
||||
void CMonitor::addDamage(const pixman_region32_t* rg) {
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) {
|
||||
if (m_cursorZoom->value() != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) {
|
||||
m_damage.damageEntire();
|
||||
g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
|
||||
} else if (m_damage.damage(rg))
|
||||
|
|
@ -930,8 +932,7 @@ void CMonitor::addDamage(const CRegion& rg) {
|
|||
}
|
||||
|
||||
void CMonitor::addDamage(const CBox& box) {
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) {
|
||||
if (m_cursorZoom->value() != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) {
|
||||
m_damage.damageEntire();
|
||||
g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,6 +178,8 @@ class CMonitor {
|
|||
// for special fade/blur
|
||||
PHLANIMVAR<float> m_specialFade;
|
||||
|
||||
PHLANIMVAR<float> m_cursorZoom;
|
||||
|
||||
struct {
|
||||
bool canTear = false;
|
||||
bool nextRenderTorn = false;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
|
|||
if (PMONITOR == nullptr)
|
||||
return;
|
||||
|
||||
if (*PZOOMFACTOR != 1.f)
|
||||
if (PMONITOR->m_cursorZoom->value() != 1.f)
|
||||
g_pHyprRenderer->damageMonitor(PMONITOR);
|
||||
|
||||
bool skipFrameSchedule = PMONITOR->shouldSkipScheduleFrameOnMouseEvent();
|
||||
|
|
|
|||
|
|
@ -1163,13 +1163,14 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) {
|
|||
static auto PDAMAGEBLINK = CConfigValue<Hyprlang::INT>("debug:damage_blink");
|
||||
static auto PDIRECTSCANOUT = CConfigValue<Hyprlang::INT>("render:direct_scanout");
|
||||
static auto PVFR = CConfigValue<Hyprlang::INT>("misc:vfr");
|
||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||
static auto PANIMENABLED = CConfigValue<Hyprlang::INT>("animations:enabled");
|
||||
static auto PFIRSTLAUNCHANIM = CConfigValue<Hyprlang::INT>("animations:first_launch_animation");
|
||||
static auto PTEARINGENABLED = CConfigValue<Hyprlang::INT>("general:allow_tearing");
|
||||
|
||||
static int damageBlinkCleanup = 0; // because double-buffered
|
||||
|
||||
const float ZOOMFACTOR = pMonitor->m_cursorZoom->value();
|
||||
|
||||
if (pMonitor->m_pixelSize.x < 1 || pMonitor->m_pixelSize.y < 1) {
|
||||
Debug::log(ERR, "Refusing to render a monitor because of an invalid pixel size: {}", pMonitor->m_pixelSize);
|
||||
return;
|
||||
|
|
@ -1298,16 +1299,16 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) {
|
|||
TRACY_GPU_ZONE("Render");
|
||||
|
||||
static bool zoomLock = false;
|
||||
if (zoomLock && *PZOOMFACTOR == 1.f) {
|
||||
if (zoomLock && ZOOMFACTOR == 1.f) {
|
||||
g_pPointerManager->unlockSoftwareAll();
|
||||
zoomLock = false;
|
||||
} else if (!zoomLock && *PZOOMFACTOR != 1.f) {
|
||||
} else if (!zoomLock && ZOOMFACTOR != 1.f) {
|
||||
g_pPointerManager->lockSoftwareAll();
|
||||
zoomLock = true;
|
||||
}
|
||||
|
||||
if (pMonitor == g_pCompositor->getMonitorFromCursor())
|
||||
g_pHyprOpenGL->m_renderData.mouseZoomFactor = std::clamp(*PZOOMFACTOR, 1.f, INFINITY);
|
||||
g_pHyprOpenGL->m_renderData.mouseZoomFactor = std::clamp(ZOOMFACTOR, 1.f, INFINITY);
|
||||
else
|
||||
g_pHyprOpenGL->m_renderData.mouseZoomFactor = 1.f;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue