summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-27 12:32:00 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-27 12:32:00 +0200
commit31a079b347ddede3f672b0b059967f5e6bc74a36 (patch)
treec957d8af9866189dbaaa71f4481e13e860ff640c /src/render
parent50b991674b6d6607477232a774d5f730789d18a8 (diff)
added DPMS
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp6
-rw-r--r--src/render/OpenGL.hpp12
-rw-r--r--src/render/Renderer.cpp27
-rw-r--r--src/render/Renderer.hpp16
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp2
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.hpp2
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp2
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.hpp2
-rw-r--r--src/render/decorations/IHyprWindowDecoration.hpp4
9 files changed, 39 insertions, 34 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 91d6b0c5..eaf029a5 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -139,7 +139,7 @@ GLuint CHyprOpenGLImpl::compileShader(const GLuint& type, std::string src) {
return shader;
}
-void CHyprOpenGLImpl::begin(SMonitor* pMonitor, pixman_region32_t* pDamage, bool fake) {
+void CHyprOpenGLImpl::begin(CMonitor* pMonitor, pixman_region32_t* pDamage, bool fake) {
m_RenderData.pMonitor = pMonitor;
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
@@ -941,7 +941,7 @@ void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const
cairo_surface_flush(CAIROSURFACE);
}
-void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
+void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
static auto *const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue;
@@ -1011,7 +1011,7 @@ void CHyprOpenGLImpl::clearWithTex() {
}
}
-void CHyprOpenGLImpl::destroyMonitorResources(SMonitor* pMonitor) {
+void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].mirrorFB.release();
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].primaryFB.release();
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].stencilTex.destroyTexture();
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 84cfcd39..8c70529c 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -40,7 +40,7 @@ struct SMonitorRenderData {
};
struct SCurrentRenderData {
- SMonitor* pMonitor = nullptr;
+ CMonitor* pMonitor = nullptr;
float projection[9];
SMonitorRenderData* pCurrentMonData = nullptr;
@@ -56,7 +56,7 @@ public:
CHyprOpenGLImpl();
- void begin(SMonitor*, pixman_region32_t*, bool fake = false);
+ void begin(CMonitor*, pixman_region32_t*, bool fake = false);
void end();
void renderRect(wlr_box*, const CColor&, int round = 0);
@@ -78,7 +78,7 @@ public:
void scissor(const pixman_box32*);
void scissor(const int x, const int y, const int w, const int h);
- void destroyMonitorResources(SMonitor*);
+ void destroyMonitorResources(CMonitor*);
SCurrentRenderData m_RenderData;
@@ -91,8 +91,8 @@ public:
std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
- std::unordered_map<SMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
- std::unordered_map<SMonitor*, CTexture> m_mMonitorBGTextures;
+ std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
+ std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
private:
std::list<GLuint> m_lBuffers;
@@ -117,7 +117,7 @@ private:
GLuint createProgram(const std::string&, const std::string&);
GLuint compileShader(const GLuint&, std::string);
- void createBGTextureForMonitor(SMonitor*);
+ void createBGTextureForMonitor(CMonitor*);
// returns the out FB, can be either Mirror or MirrorSwap
CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index a00d6f11..11e0384b 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -65,7 +65,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
wlr_presentation_surface_sampled_on_output(g_pCompositor->m_sWLRPresentation, surface, RDATA->output);
}
-bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, SMonitor* pMonitor) {
+bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
wlr_box geometry = pWindow->getFullWindowBoundingBox();
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
@@ -107,7 +107,7 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
return false;
}
-void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
+void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr;
for (auto& w : g_pCompositor->m_vWindows) {
@@ -162,7 +162,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor
g_pHyprError->draw();
}
-void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode) {
+void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode) {
if (pWindow->m_bHidden)
return;
@@ -266,7 +266,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
}
-void CHyprRenderer::renderLayer(SLayerSurface* pLayer, SMonitor* pMonitor, timespec* time) {
+void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
if (pLayer->fadingOut) {
g_pHyprOpenGL->renderSnapshot(&pLayer);
return;
@@ -504,7 +504,7 @@ void apply_exclusive(struct wlr_box* usable_area, uint32_t anchor, int32_t exclu
}
}
-void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::vector<std::unique_ptr<SLayerSurface>>& layerSurfaces, bool exclusiveZone, wlr_box* usableArea) {
+void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std::unique_ptr<SLayerSurface>>& layerSurfaces, bool exclusiveZone, wlr_box* usableArea) {
wlr_box full_area = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y};
for (auto& ls : layerSurfaces) {
@@ -674,7 +674,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height);
}
-void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
+void CHyprRenderer::damageMonitor(CMonitor* pMonitor) {
wlr_box damageBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y};
wlr_output_damage_add_box(pMonitor->damage, &damageBox);
@@ -709,7 +709,7 @@ void CHyprRenderer::damageRegion(pixman_region32_t* rg) {
}
}
-void CHyprRenderer::renderDragIcon(SMonitor* pMonitor, timespec* time) {
+void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) {
if (!(g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.iconMapped && g_pInputManager->m_sDrag.dragIcon->surface))
return;
@@ -735,19 +735,24 @@ DAMAGETRACKINGMODES CHyprRenderer::damageTrackingModeFromStr(const std::string&
return DAMAGE_TRACKING_INVALID;
}
-bool CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) {
+bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) {
Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str());
// if it's disabled, disable and ignore
if (pMonitorRule->disabled) {
- wlr_output_enable(pMonitor->output, 0);
- wlr_output_commit(pMonitor->output);
- Events::listener_monitorDestroy(nullptr, pMonitor->output);
+ if (pMonitor->m_bEnabled)
+ pMonitor->onDisconnect();
+
return false;
}
+ if (!pMonitor->m_bEnabled) {
+ pMonitor->onConnect(true); // enable it.
+ force = true;
+ }
+
// Check if the rule isn't already applied
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1) && pMonitor->transform == pMonitorRule->transform) {
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index 3c9b18bd..728f278d 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -34,9 +34,9 @@ public:
void damageBox(wlr_box*);
void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageRegion(pixman_region32_t*);
- void damageMonitor(SMonitor*);
- bool applyMonitorRule(SMonitor*, SMonitorRule*, bool force = false);
- bool shouldRenderWindow(CWindow*, SMonitor*);
+ void damageMonitor(CMonitor*);
+ bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false);
+ bool shouldRenderWindow(CWindow*, CMonitor*);
bool shouldRenderWindow(CWindow*);
void ensureCursorRenderingMode();
bool shouldRenderCursor();
@@ -46,11 +46,11 @@ public:
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
private:
- void arrangeLayerArray(SMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
- void renderWorkspaceWithFullscreenWindow(SMonitor*, CWorkspace*, timespec*);
- void renderWindow(CWindow*, SMonitor*, timespec*, bool, eRenderPassMode);
- void renderLayer(SLayerSurface*, SMonitor*, timespec*);
- void renderDragIcon(SMonitor*, timespec*);
+ void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
+ void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
+ void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode);
+ void renderLayer(SLayerSurface*, CMonitor*, timespec*);
+ void renderDragIcon(CMonitor*, timespec*);
bool m_bHasARenderedCursor = true;
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index a03181c0..5c2d00b9 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -48,7 +48,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
}
}
-void CHyprDropShadowDecoration::draw(SMonitor* pMonitor, float a) {
+void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
if (!g_pCompositor->windowValidMapped(m_pWindow))
return;
diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp
index f734c111..a90f2b0f 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.hpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.hpp
@@ -9,7 +9,7 @@ public:
virtual SWindowDecorationExtents getWindowDecorationExtents();
- virtual void draw(SMonitor*, float a);
+ virtual void draw(CMonitor*, float a);
virtual eDecorationType getDecorationType();
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 2d46d7a0..eadcd167 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -64,7 +64,7 @@ void CHyprGroupBarDecoration::damageEntire() {
g_pHyprRenderer->damageBox(&dm);
}
-void CHyprGroupBarDecoration::draw(SMonitor* pMonitor, float a) {
+void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
// get how many bars we will draw
int barsToDraw = m_dwGroupMembers.size();
diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp
index 76baab65..00570347 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.hpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.hpp
@@ -10,7 +10,7 @@ public:
virtual SWindowDecorationExtents getWindowDecorationExtents();
- virtual void draw(SMonitor*, float a);
+ virtual void draw(CMonitor*, float a);
virtual eDecorationType getDecorationType();
diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp
index 4066b6f3..e6f65f7e 100644
--- a/src/render/decorations/IHyprWindowDecoration.hpp
+++ b/src/render/decorations/IHyprWindowDecoration.hpp
@@ -14,7 +14,7 @@ struct SWindowDecorationExtents {
};
class CWindow;
-struct SMonitor;
+struct CMonitor;
interface IHyprWindowDecoration {
public:
@@ -22,7 +22,7 @@ public:
virtual SWindowDecorationExtents getWindowDecorationExtents() = 0;
- virtual void draw(SMonitor*, float a) = 0;
+ virtual void draw(CMonitor*, float a) = 0;
virtual eDecorationType getDecorationType() = 0;