mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 13:29:48 +01:00
lockSurface: fix dynamic output mode and scale updates (#462)
* lockSurface: reload widgets on output change * lockSurface: only configure when scale actually changed * lockSurface: enable fsv1 per default for all compositors
This commit is contained in:
parent
9393a3e94d
commit
f673759d01
2 changed files with 17 additions and 7 deletions
|
@ -16,10 +16,12 @@ 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;
|
||||||
|
const bool SAMESCALE = PSURF->fractionalScale == scale / 120.0;
|
||||||
PSURF->fractionalScale = scale / 120.0;
|
PSURF->fractionalScale = scale / 120.0;
|
||||||
|
|
||||||
Debug::log(LOG, "Got fractional scale: {}", PSURF->fractionalScale);
|
Debug::log(LOG, "Got fractional scale: {}", PSURF->fractionalScale);
|
||||||
|
|
||||||
if (PSURF->readyForFrame)
|
if (!SAMESCALE && PSURF->readyForFrame)
|
||||||
PSURF->onScaleUpdate();
|
PSURF->onScaleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +57,9 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PFRACTIONALSCALING = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:fractional_scaling");
|
const auto PFRACTIONALSCALING = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:fractional_scaling");
|
||||||
const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 ||
|
const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 || /* auto enable */ (**PFRACTIONALSCALING == 2);
|
||||||
/* auto */ (**PFRACTIONALSCALING == 2 && (g_pHyprlock->m_sCurrentDesktop == "Hyprland" || g_pHyprlock->m_sCurrentDesktop == "niri"));
|
const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr();
|
||||||
const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr();
|
const auto PVIEWPORTER = g_pHyprlock->getViewporter();
|
||||||
const auto PVIEWPORTER = g_pHyprlock->getViewporter();
|
|
||||||
|
|
||||||
if (ENABLE_FSV1 && PFRACTIONALMGR && PVIEWPORTER) {
|
if (ENABLE_FSV1 && PFRACTIONALMGR && PVIEWPORTER) {
|
||||||
fractional = wp_fractional_scale_manager_v1_get_fractional_scale(PFRACTIONALMGR, surface);
|
fractional = wp_fractional_scale_manager_v1_get_fractional_scale(PFRACTIONALMGR, surface);
|
||||||
|
@ -87,9 +88,12 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
|
||||||
Debug::log(LOG, "configure with serial {}", serial_);
|
Debug::log(LOG, "configure with serial {}", serial_);
|
||||||
|
|
||||||
const bool SAMESERIAL = serial == serial_;
|
const bool SAMESERIAL = serial == serial_;
|
||||||
|
const bool SAMESIZE = logicalSize == size_;
|
||||||
|
const bool SAMESCALE = appliedScale == fractionalScale;
|
||||||
|
|
||||||
serial = serial_;
|
serial = serial_;
|
||||||
logicalSize = size_;
|
logicalSize = size_;
|
||||||
|
appliedScale = fractionalScale;
|
||||||
|
|
||||||
if (fractional) {
|
if (fractional) {
|
||||||
size = (size_ * fractionalScale).floor();
|
size = (size_ * fractionalScale).floor();
|
||||||
|
@ -127,6 +131,11 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (readyForFrame && !(SAMESIZE && SAMESCALE)) {
|
||||||
|
g_pRenderer->removeWidgetsFor(this);
|
||||||
|
Debug::log(LOG, "Reloading widgets");
|
||||||
|
}
|
||||||
|
|
||||||
readyForFrame = true;
|
readyForFrame = true;
|
||||||
|
|
||||||
render();
|
render();
|
||||||
|
|
|
@ -34,6 +34,7 @@ class CSessionLockSurface {
|
||||||
wl_egl_window* eglWindow = nullptr;
|
wl_egl_window* eglWindow = nullptr;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
Vector2D logicalSize;
|
Vector2D logicalSize;
|
||||||
|
float appliedScale;
|
||||||
EGLSurface eglSurface = nullptr;
|
EGLSurface eglSurface = nullptr;
|
||||||
wp_fractional_scale_v1* fractional = nullptr;
|
wp_fractional_scale_v1* fractional = nullptr;
|
||||||
wp_viewport* viewport = nullptr;
|
wp_viewport* viewport = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue