hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.99k stars 852 forks source link

Support Xwayland HiDPI scaling for multi-monitor with different scale factors #6281

Open moetayuko opened 4 months ago

moetayuko commented 4 months ago

Description

The issue

The official Xwayland scaling solution xwayland:force_zero_scaling does not support multi-monitor with different scale factors. Specifically, when having two monitors of scale factors 2 and 1, Xwayland apps look good on the one of scale factor 2, but 2x larger on the one of scale factor 1.

The history

There's a draft https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733 and corresponding wlroots patches to fix the issue mentioned above: Xwayland apps will be downscaled on the monitor of scale factor 1 so they look good on both screens.

These patches were even documented in Hyprland wiki but removed after https://github.com/hyprwm/Hyprland/pull/2870 in favor of zero scaling. Nonetheless, they continued to work so users could still patch the corresponding packages to get the desired behavior, until the recent Xwayland refactoring.

What can be done

The easy way

Since Hyprland's Xwayland implementation now deviates from wlroots, the wlroots patch for https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733 is no longer effective. A new Hyprland-specific patch could be developed.

The sane(?) way

A new scaling solution for mutter is in development at https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3567, which does not require patching xorg-xwayland. A similar approach could be implemented for Hyprland.

vaxerski commented 4 months ago

sounds reasonable to do it the gnome way

AstralPhnx commented 3 months ago

I've actually been testing the GNOME version of this commit for mutter as OP linked and can confirm its effectiveness, however there was some weird issues with electron which may or may not be directly related to mutter itself in that case but it was also mostly related to window resizing so probably won't be a huge issue for hyprland.

To confirm I can also replicate this issue on Fedora Silverblue on my end

Nojike commented 2 months ago

For xwayland apps cursor size are small issue. Source:

Sometimes in XWayland apps, the cursor is half the usual cursor size.

You can try adding the following as a startup script to manage the cursor for XWayland apps, replacing the cursor theme name and size as needed:

xsetroot -xcf /usr/share/icons/$your_cursor_theme_name/cursors/left_ptr 48

The -xcf option tells xsetroot to set the root window’s cursor using an X11 cursor file (XCF) format, and 48 is the size of the cursor in pixels.

Another option is to change your XWayland launch script to add the following:

export XCURSOR_SIZE=48 export XCURSOR_THEME=Adwaita