hyprwm / hyprlock

Hyprland's GPU-accelerated screen locking utility
BSD 3-Clause "New" or "Revised" License
718 stars 53 forks source link

rendering issues with scaling in sway #439

Closed RiedleroD closed 1 month ago

RiedleroD commented 1 month ago

When I set my scaling to anything larger than 1 in sway, hyprlock renders at an incorrect resolution, as if compensating for scaling like an XWayland window. Since the lockscreen works differently, however, the output isn't just blurry, but there's a black area around the scaled down "window" of hyprlock. It's not a fractional scaling problem, setting it to 2 has the same effect, the rendered part is just even smaller.

hyprlock at 1.74 scaling: 20240724_00h34m17s_grim

equivalent swaylock-effects at 1.74 scaling: 20240724_00h35m22s_grim

(how did I get those screenshots? sleep 2 && grim)

log output:

[LOG]   | got iface: wl_shm v1
[LOG]   | got iface: wl_drm v2
[LOG]   | got iface: zwp_linux_dmabuf_v1 v4
[LOG]    > Bound to zwp_linux_dmabuf_v1 v4
[LOG]   | got iface: wl_compositor v6
[LOG]    > Bound to wl_compositor v6
[LOG]   | got iface: wl_subcompositor v1
[LOG]   | got iface: wl_data_device_manager v3
[LOG]   | got iface: zwlr_gamma_control_manager_v1 v1
[LOG]   | got iface: zxdg_output_manager_v1 v3
[LOG]   | got iface: ext_idle_notifier_v1 v1
[LOG]   | got iface: zwp_idle_inhibit_manager_v1 v1
[LOG]   | got iface: zwlr_layer_shell_v1 v4
[LOG]   | got iface: xdg_wm_base v2
[LOG]   | got iface: zwp_tablet_manager_v2 v1
[LOG]   | got iface: org_kde_kwin_server_decoration_manager v1
[LOG]   | got iface: zxdg_decoration_manager_v1 v1
[LOG]   | got iface: zwp_relative_pointer_manager_v1 v1
[LOG]   | got iface: zwp_pointer_constraints_v1 v1
[LOG]   | got iface: wp_presentation v1
[LOG]   | got iface: zwlr_output_manager_v1 v4
[LOG]   | got iface: zwlr_output_power_manager_v1 v1
[LOG]   | got iface: zwp_input_method_manager_v2 v1
[LOG]   | got iface: zwp_text_input_manager_v3 v1
[LOG]   | got iface: zwlr_foreign_toplevel_manager_v1 v3
[LOG]   | got iface: ext_session_lock_manager_v1 v1
[LOG]    > Bound to ext_session_lock_manager_v1 v1
[LOG]   | got iface: wp_drm_lease_device_v1 v1
[LOG]   | got iface: zwlr_export_dmabuf_manager_v1 v1
[LOG]   | got iface: zwlr_screencopy_manager_v1 v3
[LOG]    > Bound to zwlr_screencopy_manager_v1 v3
[LOG]   | got iface: zwlr_data_control_manager_v1 v2
[LOG]   | got iface: wp_security_context_manager_v1 v1
[LOG]   | got iface: wp_viewporter v1
[LOG]    > Bound to wp_viewporter v1
[LOG]   | got iface: wp_single_pixel_buffer_manager_v1 v1
[LOG]   | got iface: wp_content_type_manager_v1 v1
[LOG]   | got iface: wp_fractional_scale_manager_v1 v1
[LOG]    > Bound to wp_fractional_scale_manager_v1 v1
[LOG]   | got iface: zxdg_exporter_v1 v1
[LOG]   | got iface: zxdg_importer_v1 v1
[LOG]   | got iface: zxdg_exporter_v2 v1
[LOG]   | got iface: zxdg_importer_v2 v1
[LOG]   | got iface: xdg_activation_v1 v1
[LOG]   | got iface: wp_cursor_shape_manager_v1 v1
[LOG]    > Bound to wp_cursor_shape_manager_v1 v1
[LOG]   | got iface: zwp_virtual_keyboard_manager_v1 v1
[LOG]   | got iface: zwlr_virtual_pointer_manager_v1 v2
[LOG]   | got iface: zwlr_input_inhibit_manager_v1 v1
[LOG]   | got iface: zwp_keyboard_shortcuts_inhibit_manager_v1 v1
[LOG]   | got iface: zwp_pointer_gestures_v1 v3
[LOG]   | got iface: wl_seat v8
[LOG]    > Bound to wl_seat v8
[LOG]   | got iface: zwp_primary_selection_device_manager_v1 v1
[LOG]   | got iface: wl_output v4
[LOG]    > Bound to wl_output v4
[LOG] [core] dmabufFeedbackMainDevice
[LOG] output 48 make California Institute of Technology model 0x1402
[LOG] output 48 name eDP-1
[LOG] output 48 description California Institute of Technology 0x1402 (eDP-1)
[LOG] output 48 done
[LOG] Running on sway
[ERR] No cairo surface!
[LOG] Locking session
[LOG] onLockLocked called
[LOG] configure with serial 58698
[LOG] Configuring surface for logical [Vector2D: x: 1637, y: 1023] and pixel [Vector2D: x: 1637, y: 1023]
[LOG] Got fractional scale: 1.7583333
[LOG] configure with serial 58698
[LOG] Configuring surface for logical [Vector2D: x: 1637, y: 1023] and pixel [Vector2D: x: 2878, y: 1798]

my laptop screen resolution is 2880x1800 so neither of the detected ones are quite right. That might be an unrelated rounding error due to fractional scaling tho

PaideiaDilemma commented 1 month ago

Can confirm. The fractional scaling behaves differently on hyprland and sway for some reason.

This patch makes the scaling in sway work properly:

diff --git a/src/core/LockSurface.cpp b/src/core/LockSurface.cpp
index 006a2eb..cd7366d 100644
--- a/src/core/LockSurface.cpp
+++ b/src/core/LockSurface.cpp
@@ -102,13 +102,13 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t ser
ial_) {
     wl_surface_damage_buffer(surface, 0, 0, 0xFFFF, 0xFFFF);

     if (!eglWindow) {
-        eglWindow = wl_egl_window_create(surface, size.x, size.y);
+        eglWindow = wl_egl_window_create(surface, logicalSize.x, logicalSize.y);
         if (!eglWindow) {
             Debug::log(CRIT, "Couldn't create eglWindow");
             exit(1);
         }
     } else
-        wl_egl_window_resize(eglWindow, size.x, size.y, 0, 0);
+        wl_egl_window_resize(eglWindow, logicalSize.x, logicalSize.y, 0, 0);

     if (!eglSurface) {
         eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->e
glConfig, eglWindow, nullptr);

But it breaks it in hyprland, where hyprlock always fits the output, but widgets are not scaled. I am not fully sure, what is intended here.

vaxerski commented 1 month ago

can you post a wayland_debug from sway

also tf is that lockscreen lmao

PaideiaDilemma commented 1 month ago

sway.log

also tf is that lockscreen lmao

probably using sway+hyprlock as a bsod for hyprland xD

RiedleroD commented 1 month ago

also tf is that lockscreen lmao

I just like having a weird lockscreen 😅 I made it myself with some html+css and a QR code generator, rendered into png via FF.

probably using sway+hyprlock as a bsod for hyprland xD

I don't use hyprland at all, I just got frustrated with the absolute state swaylock-effects is in, so I'm looking to switch to hyprlock for my sway setup.

wayland_debug

I tried to look it up, but I'm not sure how to do that. Seems to be something different than the normal sway debug output, right?

vaxerski commented 1 month ago

WAYLAND_DEBUG=1 hyprlock |& tee ~/debug.log

PaideiaDilemma commented 1 month ago

Sorry first log i posted was from entire sway session.

Here from sway with scale 1.5: wl_debug_sway.log Here from hl with scale 1.5: wl_debug_hl.log

vaxerski commented 1 month ago

I don't see a problem here... maybe sway's fractional scale on lockscreens is broken?

IIRC no other lock does support fsv1

PaideiaDilemma commented 1 month ago

Could be. Sway and river behave the same. Niri (smithay impl) errors with EXT_SESSION_LOCK_SURFACE_V1_ERROR_DIMENSIONS_MISMATCH

Should we disable fsv1 for non-hyprland compositors for now?

There is one thing I don't really understand, but it could be that I am misunderstanding fsv1. Shouldn't the widget dimensions scale somehow? Because right now the fractionalScale does not influence the size of widgets at all.

vaxerski commented 1 month ago

that's up to us to do, and atm we just dont

vaxerski commented 1 month ago

Should we disable fsv1 for non-hyprland compositors for now?

we can add an option 0 disable 1 enable 2 default auto

YaLTeR commented 1 month ago

Niri (smithay impl) errors with EXT_SESSION_LOCK_SURFACE_V1_ERROR_DIMENSIONS_MISMATCH

This just appeared: https://github.com/Smithay/smithay/pull/1496, I guess it fixes that

vaxerski commented 1 month ago

correct, it should (can't say for sure I don't understand that devilish language)

PaideiaDilemma commented 1 month ago

Niri works as expected with https://github.com/Smithay/smithay/pull/1496. So this is probably a wlroots bug.

vaxerski commented 1 month ago

likely