added opacity rule

This commit is contained in:
vaxerski 2022-04-22 14:37:38 +02:00
parent a8e5e9c558
commit 94811485c9
4 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,9 @@
#include "events/Events.hpp"
#include "helpers/SubsurfaceTree.hpp"
struct SWindowSpecialRenderData {
float alpha = 1.f;
};
class CWindow {
public:
@ -76,6 +79,8 @@ public:
// For hidden windows and stuff
bool m_bHidden = false;
// Special render data, rules, etc
SWindowSpecialRenderData m_sSpecialRenderData;
// For the list lookup
bool operator==(const CWindow& rhs) {

View File

@ -259,6 +259,7 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
// verify we support a rule
if (RULE != "float"
&& RULE != "tile"
&& RULE.find("opacity") != 0
&& RULE.find("move") != 0
&& RULE.find("size") != 0
&& RULE.find("pseudo") != 0

View File

@ -86,6 +86,12 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bIsFloating = false;
} else if (r.szRule.find("pseudo") == 0) {
PWINDOW->m_bIsPseudotiled = true;
} else if (r.szRule.find("opacity") == 0) {
try {
PWINDOW->m_sSpecialRenderData.alpha = std::stof(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
} catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
}
}

View File

@ -92,11 +92,14 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
renderdata.fadeAlpha = pWindow->m_fAlpha;
renderdata.alpha = pWindow == g_pCompositor->m_pLastWindow ? g_pConfigManager->getFloat("decoration:active_opacity") : g_pConfigManager->getFloat("decoration:inactive_opacity");
// apply window special data
renderdata.alpha *= pWindow->m_sSpecialRenderData.alpha;
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
// border
if (decorate && !pWindow->m_bX11DoesntWantBorders)
drawBorderForWindow(pWindow, pMonitor, pWindow->m_fAlpha);
drawBorderForWindow(pWindow, pMonitor, pWindow->m_fAlpha * renderdata.alpha);
if (pWindow->m_bIsX11) {
if (pWindow->m_uSurface.xwayland->surface) {