mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:05:58 +01:00
Draw HyprError on the last monitor
This commit is contained in:
parent
4d3f2ca96b
commit
7beb9fd606
3 changed files with 29 additions and 11 deletions
|
@ -260,12 +260,10 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
|
||||
g_pHyprRenderer->renderAllClientsForMonitor(PMONITOR->ID, &now);
|
||||
|
||||
// if correct monitor draw hyprerror
|
||||
if (PMONITOR == g_pCompositor->m_vMonitors.front().get())
|
||||
g_pHyprError->draw();
|
||||
|
||||
if (PMONITOR == g_pCompositor->m_pLastMonitor)
|
||||
if (PMONITOR == g_pCompositor->m_pLastMonitor) {
|
||||
g_pHyprNotificationOverlay->draw(PMONITOR);
|
||||
g_pHyprError->draw();
|
||||
}
|
||||
|
||||
// for drawing the debug overlay
|
||||
if (PMONITOR == g_pCompositor->m_vMonitors.front().get() && *PDEBUGOVERLAY == 1) {
|
||||
|
|
|
@ -4,6 +4,22 @@
|
|||
CHyprError::CHyprError() {
|
||||
m_fFadeOpacity.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_NONE);
|
||||
m_fFadeOpacity.registerVar();
|
||||
|
||||
g_pHookSystem->hookDynamic("focusedMon", [&](void* self, std::any param) {
|
||||
if (!m_bIsCreated)
|
||||
return;
|
||||
|
||||
g_pHyprRenderer->damageMonitor(g_pCompositor->m_pLastMonitor);
|
||||
m_bMonitorChanged = true;
|
||||
});
|
||||
|
||||
g_pHookSystem->hookDynamic("preRender", [&](void* self, std::any param) {
|
||||
if (!m_bIsCreated)
|
||||
return;
|
||||
|
||||
if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged)
|
||||
g_pHyprRenderer->damageBox(&m_bDamageBox);
|
||||
});
|
||||
}
|
||||
|
||||
CHyprError::~CHyprError() {
|
||||
|
@ -54,7 +70,7 @@ void CHyprError::createQueued() {
|
|||
const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * LINECOUNT + 3;
|
||||
const double RADIUS = PAD > HEIGHT / 2 ? HEIGHT / 2 - 1 : PAD;
|
||||
|
||||
m_bDamageBox = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2};
|
||||
m_bDamageBox = {0, 0, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2};
|
||||
|
||||
cairo_new_sub_path(CAIRO);
|
||||
cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES);
|
||||
|
@ -137,16 +153,18 @@ void CHyprError::draw() {
|
|||
}
|
||||
}
|
||||
|
||||
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
|
||||
|
||||
if (g_pHyprOpenGL->m_RenderData.pMonitor != PMONITOR)
|
||||
return; // wrong mon
|
||||
const auto PMONITOR = g_pHyprOpenGL->m_RenderData.pMonitor;
|
||||
|
||||
wlr_box monbox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
|
||||
|
||||
if (m_fFadeOpacity.isBeingAnimated())
|
||||
m_bDamageBox.x = (int)PMONITOR->vecPosition.x;
|
||||
m_bDamageBox.y = (int)PMONITOR->vecPosition.y;
|
||||
|
||||
if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged)
|
||||
g_pHyprRenderer->damageBox(&m_bDamageBox);
|
||||
|
||||
m_bMonitorChanged = false;
|
||||
|
||||
g_pHyprOpenGL->renderTexture(m_tTexture, &monbox, m_fFadeOpacity.fl(), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ class CHyprError {
|
|||
CTexture m_tTexture;
|
||||
CAnimatedVariable m_fFadeOpacity;
|
||||
wlr_box m_bDamageBox = {0, 0, 0, 0};
|
||||
|
||||
bool m_bMonitorChanged = false;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.
|
Loading…
Reference in a new issue