core: minor bugfixes (#405)

This commit is contained in:
Jasson 2024-07-07 11:55:59 -04:00 committed by GitHub
parent 7fb3c03500
commit a50296c181
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 21 deletions

View File

@ -16,7 +16,7 @@ static const ext_session_lock_surface_v1_listener lockListener = {
static void handlePreferredScale(void* data, wp_fractional_scale_v1* wp_fractional_scale_v1, uint32_t scale) { static void handlePreferredScale(void* data, wp_fractional_scale_v1* wp_fractional_scale_v1, uint32_t scale) {
const auto PSURF = (CSessionLockSurface*)data; const auto PSURF = (CSessionLockSurface*)data;
PSURF->fractionalScale = scale / 120.0; PSURF->fractionalScale = scale / 120.0;
Debug::log(LOG, "got fractional {}", PSURF->fractionalScale); Debug::log(LOG, "Got fractional scale: {}", PSURF->fractionalScale);
if (PSURF->readyForFrame) if (PSURF->readyForFrame)
PSURF->onScaleUpdate(); PSURF->onScaleUpdate();
@ -35,8 +35,12 @@ CSessionLockSurface::~CSessionLockSurface() {
if (eglWindow) if (eglWindow)
wl_egl_window_destroy(eglWindow); wl_egl_window_destroy(eglWindow);
if (lockSurface)
ext_session_lock_surface_v1_destroy(lockSurface); ext_session_lock_surface_v1_destroy(lockSurface);
if (surface)
wl_surface_destroy(surface); wl_surface_destroy(surface);
if (frameCallback) if (frameCallback)
wl_callback_destroy(frameCallback); wl_callback_destroy(frameCallback);
} }
@ -58,7 +62,7 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) {
lockSurface = ext_session_lock_v1_get_lock_surface(g_pHyprlock->getSessionLock(), surface, output->output); lockSurface = ext_session_lock_v1_get_lock_surface(g_pHyprlock->getSessionLock(), surface, output->output);
if (!surface) { if (!lockSurface) {
Debug::log(CRIT, "Couldn't create ext_session_lock_surface_v1"); Debug::log(CRIT, "Couldn't create ext_session_lock_surface_v1");
exit(1); exit(1);
} }
@ -72,36 +76,41 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
const bool sameSerial = serial == serial_; const bool sameSerial = serial == serial_;
serial = serial_; serial = serial_;
size = (size_ * fractionalScale).floor();
logicalSize = size_; logicalSize = size_;
if (fractional) {
size = (size_ * fractionalScale).floor();
wp_viewport_set_destination(viewport, logicalSize.x, logicalSize.y);
} else {
size = size_;
}
Debug::log(LOG, "Configuring surface for logical {} and pixel {}", logicalSize, size); Debug::log(LOG, "Configuring surface for logical {} and pixel {}", logicalSize, size);
if (!sameSerial) if (!sameSerial)
ext_session_lock_surface_v1_ack_configure(lockSurface, serial); ext_session_lock_surface_v1_ack_configure(lockSurface, serial);
if (fractional)
wp_viewport_set_destination(viewport, logicalSize.x, logicalSize.y);
wl_surface_set_buffer_scale(surface, 1); wl_surface_set_buffer_scale(surface, 1);
wl_surface_damage_buffer(surface, 0, 0, 0xFFFF, 0xFFFF); wl_surface_damage_buffer(surface, 0, 0, 0xFFFF, 0xFFFF);
if (!eglWindow) if (!eglWindow) {
eglWindow = wl_egl_window_create(surface, size.x, size.y); eglWindow = wl_egl_window_create(surface, size.x, size.y);
else
wl_egl_window_resize(eglWindow, size.x, size.y, 0, 0);
if (!eglWindow) { if (!eglWindow) {
Debug::log(CRIT, "Couldn't create eglWindow"); Debug::log(CRIT, "Couldn't create eglWindow");
exit(1); exit(1);
} }
} else
if (!eglSurface) wl_egl_window_resize(eglWindow, size.x, size.y, 0, 0);
eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->eglConfig, eglWindow, nullptr);
if (!eglSurface) { if (!eglSurface) {
Debug::log(CRIT, "Couldn't create eglSurface: {}", (int)glGetError()); eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->eglConfig, eglWindow, nullptr);
exit(1); if (!eglSurface) {
Debug::log(CRIT, "Couldn't create eglSurface: {}", (int)eglGetError());
// Clean up resources to prevent leaks
wl_egl_window_destroy(eglWindow);
eglWindow = nullptr;
exit(1); // Consider graceful exit or fallback
}
} }
readyForFrame = true; readyForFrame = true;
@ -147,6 +156,8 @@ void CSessionLockSurface::onCallback() {
wl_callback_destroy(frameCallback); wl_callback_destroy(frameCallback);
frameCallback = nullptr; frameCallback = nullptr;
if (needsFrame && !g_pHyprlock->m_bTerminate && g_pEGL) if (needsFrame && !g_pHyprlock->m_bTerminate && g_pEGL) {
needsFrame = false;
render(); render();
}
} }