mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 19:05:58 +01:00
notifications: fix notifications on manually rotated monitor (#5599)
This commit is contained in:
parent
02cbf049d2
commit
c99803af15
2 changed files with 11 additions and 7 deletions
|
@ -76,7 +76,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
|
||||||
|
|
||||||
const auto SCALE = pMonitor->scale;
|
const auto SCALE = pMonitor->scale;
|
||||||
|
|
||||||
const auto MONSIZE = pMonitor->vecPixelSize;
|
const auto MONSIZE = pMonitor->vecTransformedSize;
|
||||||
|
|
||||||
cairo_text_extents_t cairoExtents;
|
cairo_text_extents_t cairoExtents;
|
||||||
int iconW = 0, iconH = 0;
|
int iconW = 0, iconH = 0;
|
||||||
|
@ -185,16 +185,19 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
|
||||||
|
|
||||||
void CHyprNotificationOverlay::draw(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) {
|
if (m_pCairo && m_pCairoSurface) {
|
||||||
cairo_destroy(m_pCairo);
|
cairo_destroy(m_pCairo);
|
||||||
cairo_surface_destroy(m_pCairoSurface);
|
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_pCairo = cairo_create(m_pCairoSurface);
|
||||||
m_pLastMonitor = pMonitor;
|
m_pLastMonitor = pMonitor;
|
||||||
|
m_vecLastSize = MONSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the notifications
|
// Draw the notifications
|
||||||
|
@ -232,12 +235,12 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
||||||
#endif
|
#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);
|
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CHyprNotificationOverlay::hasAny() {
|
bool CHyprNotificationOverlay::hasAny() {
|
||||||
return !m_dNotifications.empty();
|
return !m_dNotifications.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ class CHyprNotificationOverlay {
|
||||||
cairo_t* m_pCairo = nullptr;
|
cairo_t* m_pCairo = nullptr;
|
||||||
|
|
||||||
CMonitor* m_pLastMonitor = nullptr;
|
CMonitor* m_pLastMonitor = nullptr;
|
||||||
|
Vector2D m_vecLastSize = Vector2D(-1, -1);
|
||||||
|
|
||||||
CTexture m_tTexture;
|
CTexture m_tTexture;
|
||||||
|
|
||||||
|
@ -62,4 +63,4 @@ class CHyprNotificationOverlay {
|
||||||
std::string m_szIconFontName = "Sans";
|
std::string m_szIconFontName = "Sans";
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
|
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
|
||||||
|
|
Loading…
Reference in a new issue