From c99803af157c4715e3a9a4477c64e12cb4749833 Mon Sep 17 00:00:00 2001 From: FUFSoB <32937947+FUFSoB@users.noreply.github.com> Date: Tue, 16 Apr 2024 01:47:39 +0500 Subject: [PATCH] notifications: fix notifications on manually rotated monitor (#5599) --- src/debug/HyprNotificationOverlay.cpp | 15 +++++++++------ src/debug/HyprNotificationOverlay.hpp | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp index ced27814..dffa6889 100644 --- a/src/debug/HyprNotificationOverlay.cpp +++ b/src/debug/HyprNotificationOverlay.cpp @@ -76,7 +76,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) { const auto SCALE = pMonitor->scale; - const auto MONSIZE = pMonitor->vecPixelSize; + const auto MONSIZE = pMonitor->vecTransformedSize; cairo_text_extents_t cairoExtents; int iconW = 0, iconH = 0; @@ -185,16 +185,19 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) { void CHyprNotificationOverlay::draw(CMonitor* pMonitor) { - if (m_pLastMonitor != pMonitor || !m_pCairo || !m_pCairoSurface) { + const auto MONSIZE = pMonitor->vecTransformedSize; + + if (m_pLastMonitor != pMonitor || m_vecLastSize != MONSIZE || !m_pCairo || !m_pCairoSurface) { if (m_pCairo && m_pCairoSurface) { cairo_destroy(m_pCairo); cairo_surface_destroy(m_pCairoSurface); } - m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y); + m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, MONSIZE.x, MONSIZE.y); m_pCairo = cairo_create(m_pCairoSurface); m_pLastMonitor = pMonitor; + m_vecLastSize = MONSIZE; } // Draw the notifications @@ -232,12 +235,12 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); #endif - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, MONSIZE.x, MONSIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); - CBox pMonBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y}; + CBox pMonBox = {0, 0, MONSIZE.x, MONSIZE.y}; g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f); } bool CHyprNotificationOverlay::hasAny() { return !m_dNotifications.empty(); -} \ No newline at end of file +} diff --git a/src/debug/HyprNotificationOverlay.hpp b/src/debug/HyprNotificationOverlay.hpp index 5599b71b..25934734 100644 --- a/src/debug/HyprNotificationOverlay.hpp +++ b/src/debug/HyprNotificationOverlay.hpp @@ -55,6 +55,7 @@ class CHyprNotificationOverlay { cairo_t* m_pCairo = nullptr; CMonitor* m_pLastMonitor = nullptr; + Vector2D m_vecLastSize = Vector2D(-1, -1); CTexture m_tTexture; @@ -62,4 +63,4 @@ class CHyprNotificationOverlay { std::string m_szIconFontName = "Sans"; }; -inline std::unique_ptr g_pHyprNotificationOverlay; \ No newline at end of file +inline std::unique_ptr g_pHyprNotificationOverlay;