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.06k stars 791 forks source link

Cursor size with HiDPi #2448

Open Adu-3 opened 1 year ago

Adu-3 commented 1 year ago

The Issue:

I came form Plasma KDE to Hyprland and I saw that cursor size with fractional scaling to 1.5 is too problematic , I did append the typical cursor adjustment with other environment variables form the wiki in my config:

env = GDK_BACKEND,wayland,x11 env= QT_QPA_PLATFORM,wayland;xcb env = SDL_VIDEODRIVER,wayland env = CLUTTER_BACKEND,wayland env = XDG_CURRENT_DESKTOP,Hyprland env = XDG_SESSION_TYPE,wayland env = XDG_SESSION_DESKTOP,Hyprland env = QT_AUTO_SCREEN_SCALE_FACTOR,1 env = GTK_THEME,Breeze-Dark env = QT_STYLE_OVERRIDE,Breeze-Dark env = XCURSOR_THEME,Future-Cursors env = XCURSOR_SIZE,24 env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 exec-once=gsettings set org.gnome.desktop.interface cursor-theme 'Future-cursors' exec-once=hyprctl setcursor Future-cursors 24 monitor=eDP-1,highres,auto,1.5

How reproduce

Just change the scale size

Details

Also i did set cursor size using nwg-look to 24 also

and I still have issues with firefox ( native not flatpak ) and other apps where I see my cursor in the desktop pretty normal sized and when I hover the mouse around the waybar or when opening and moveing my cursor in it it get resized and become bigger. Furthermore, when I use rofi menu the mouse become tiny even if i try passing --dpi argument :(. In addition, using when using any screen recoreding software using Pipewire (Like OBS and wf-recoreder was tested also ) the mouse become dramatically oversized and here like that and affect every other program until I close it: https://github.com/hyprwm/Hyprland/assets/88736671/b68b00e6-97f8-4e03-9bee-9c1c6d1c1e38 It might be related to scaling because when I get selecting resolution I got 1280 X 720 while my screen is Full HD: image for now OBS and rofi problems are unsolvable while cursor size on the bar and other applications could be fixed with changing the cursor size using nwg-look to match desktop cursor size.

Setup

If you need any further information or configuration to try just let me know

Edit : After some further investigations I have found that with Fractional scaling some apps and games also are recognizing my monitor as 1280 X 720 and not 1920 X 1080 , and I think it might be the problem for this weird mouse changing

Zeioth commented 1 year ago

Add this to your ~/.profile to set any cursor size you want.

export QT_SCALE_FACTOR=2.6
export ELM_SCALE=2.6
export GDK_SCALE=2.6
export XCURSOR_SIZE=108

It's applyed when the session starts. But you can also:

source ~/.profile

To make the changes inmediate.

Adu-3 commented 1 year ago

Thanks for reply , those variables are making some apps more bigger with fractional scaling as it was set in the config and XCURSOR_SIZE was already set in my config and sadly it does not affect any app. However , I tried to scale back to 1 and scale everything font to match the desired goal using nwg-look and other apps settings and using them make apps scaled to 1.5 and I could say it is the best result that it have got so far but on the other hand, cursor size seems to be matched using nwg-look and some environment variables like:

but it is inaccurate by a character or two and when reducing its size using 'hyprctl setcursor Future-cursors 24' (BTW i use 36 cursor size when using '1' scaling that means the command is scaling down) it become more accurate (not completely) but smaller in desktop . I'm not sure weather it is KDE that wrote old configs for QT or gtk or anything similar to that makes kind of conflict but i tried to edit with nwg-look but with no luck.

All I can say now under fractional scaling cursor and resolution are major issues even with hidpi patch from the AUR I'm not turning back to it.

but the mouse accuracy under normal scaling '1' is weird even if you get back to the original cursor or any theme cursor all of them are affected.while the issue is not present under KDE. Here is the top of my config

env = WLR_NO_HARDWARE_CURSORS,1 env = GDK_BACKEND,wayland,x11 env = QT_QPA_PLATFORM,wayland;xcb env = SDL_VIDEODRIVER,wayland env = CLUTTER_BACKEND,wayland env = XDG_CURRENT_DESKTOP,Hyprland env = XDG_SESSION_TYPE,wayland env = XDG_SESSION_DESKTOP,Hyprland env = GTK_THEME,Breeze-Dark env = QT_STYLE_OVERRIDE,Breeze env = QT_QPA_PLATFORMTHEME,qt5ct env = XCURSOR_THEME,Future-cursors env = XCURSOR_SIZE,24 env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 env = QT_AUTO_SCREEN_SCALE_FACTOR,1 env = QT_SCALE_FACTOR,1.5 env = GDK_SCALE,1.5 env = ELM_SCALE,1.5 monitor=eDP-1,highres,auto,1 exec-once=gsettings set org.gnome.desktop.interface cursor-theme 'Future-cursors' exec-once=hyprctl setcursor Future-cursors 24 exec-once=/usr/lib/polkit-kde-authentication-agent-1 exec-once=nm-applet --indicator exec-once=waybar exec-once=hyprpaper exec-once=/usr/lib/kdeconnectd exec-once=dunst exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP exec-once=fcitx5 -D exec-once=swayidle -w timeout 200 'swaylock-fancy'

TLATER commented 1 year ago

So, getting wayland-native things to have correct cursor sizes works pretty well for me. I now run a little script with exec-once before anything else:

hyprctl setcursor 'Bibata-Original-Ice' 24
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Original-Ice'
gsettings set org.gnome.desktop.interface cursor-size '24'

I use gsettings because it's more predictable and portable than some random imperative gui application.

This sets up my cursor theme and a basic size, which is automatically scaled for me on my hidpi display to look correct - without any additional settings - for wayland-native applications.

Since xorg obviously doesn't do scaling, that's where XCURSOR_SIZE needs to be set. Currently I set it to 48 because hyprctl monitors says my main monitor has a scale factor of 2.0, export-ing it into my profile before hyprland even starts. I also use XCURSOR_THEME to set the cursor theme. I also run

xsetroot -cursor_name left_ptr

during the above script, because without it xwayland will reset the cursor to the default x cursor when leaving an xorg application's window.

This works ok, except somehow for rofi, which seems to completely ignore the xcursor variables. I don't know why, emacs does fine and runs with the exact same environment.

M1cha commented 1 year ago

I think there's a conceptional issue with QT applications:

Now, when I set XCURSOR_SIZE to double the native size(48), then all xwayland applications use the correct size. But that also breaks wayland-native QT applications because they actually interpret the XCURSOR_SIZE environment variable - even when running under wayland. They now have a cursor double the expected size(probably 48). It looks like for whatever reason they render the cursor as XCURSOR_SIZE * scale even when running under wayland. There's an old, unsolved issue about that: https://bugreports.qt.io/browse/QTBUG-87778.

So right now there's no way to have the cursor be the correct size in all applications. Either xwayland is too small or wayland-QT is too big. I'm not sure if the fault lies within hyprland or within QT. Are we setting set_buffer_scale on the cursor correctly as indicated by the QTBUG?

andresilva commented 11 months ago

FWIW this seems to be related to fractional scaling. When I set the scale to either 1 or 2, then mouse cursor size is properly applied by GTK apps.

AnhQuanTrl commented 8 months ago

I have a somewhat similar problem. When I set scaling to fractional scaling, the cursor when hovered on waybar or my terminal (alacritty) is bigger than on hyperland.

MariaSolOs commented 8 months ago

I'm having a similar issue but it only happens when hovering over dunst notifications. I've set XCURSOR_SIZE to 16 and I'm using a scale of 2, but for some reason the cursor seems to grow to a size of 24 when hovering over dunst popups.

vaxerski commented 3 months ago

is this still a thing?

michaelhthomas commented 3 months ago

Still a thing. With 1.5 fractional scaling I've noticed that my cursors are (slightly) larger in GTK-based apps than when hovering over the desktop or plain wayland clients like foot.

andresilva commented 3 months ago

Have you tested latest master? It seems to have been solved for me with the recent hyprland re-implementation of cursor handling (which is not yet in any release).

kaushiksahu18 commented 1 month ago

i am also facing the same issue i guess

the above panal in the video is wayber, although its happning with every apps (on apps, cursor becomes big and on wallpaper it becomes small again)

video

i have set (decrise the size of my cusor) by dconf

20240627_17h45m16s_grim

its just night mode