Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notify: fix notifications visibility on manually rotated monitor #5599

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/debug/HyprNotificationOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
3 changes: 2 additions & 1 deletion src/debug/HyprNotificationOverlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class CHyprNotificationOverlay {
cairo_t* m_pCairo = nullptr;

CMonitor* m_pLastMonitor = nullptr;
Vector2D m_vecLastSize = Vector2D(-1, -1);

CTexture m_tTexture;

eIconBackend m_eIconBackend = ICONS_BACKEND_NONE;
std::string m_szIconFontName = "Sans";
};

inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
Loading