Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong scaling and position of previews in ranger (in both sway and hyprland) #122

Closed
dev-forty-two opened this issue Aug 26, 2023 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@dev-forty-two
Copy link

I have a 2K screen and I am using a scaling factor of 1.35 with both sway and hyprland. This results in an issue similar to the one reported in #113. It does not happen with a scaling factor of 1.

Screenshot-2023-08-27-024730

Here is my log:

 _    _      _                                           
| |  | |    | |                                _     _   
| |  | | ___| |__   ___ _ __ _____   _  __ _ _| |_ _| |_ 
| |  | |/ _ \ '_ \ / _ \ '__|_  / | | |/ _` |_   _|_   _|
| |__| |  __/ |_) |  __/ |   / /| |_| | (_| | |_|   |_|  
 \____/ \___|_.__/ \___|_|  /___|\__,_|\__, |            
                                        __/ |            
                                       |___/     v2.9.1
[2023-08-27 03:00:17.661] [terminal] [info] TERM="foot", TERM_PROGRAM=""
[2023-08-27 03:00:17.662] [terminal] [info] PTY = /dev/pts/15
[2023-08-27 03:00:17.662] [wayland] [info] Using sway socket /run/user/1000/sway-ipc.1000.3151243.sock
[2023-08-27 03:00:17.666] [wayland] [info] Using sway socket /run/user/1000/sway-ipc.1000.3151243.sock
[2023-08-27 03:00:17.667] [wayland] [info] Canvas created
[2023-08-27 03:00:17.667] [main] [info] Listening for commands on socket /tmp/ueberzugpp-3244564.socket
[2023-08-27 03:00:17.709] [main] [info] Command received: {"action":"add","identifier":"preview","max_height":39,"max_width":82,"path":"/home/<username>/.cache/ranger/8a2b1a35dfe8d2460d043cbaa8ed62d8f350b04accc54827301ad5b17facdad2cce3532cbe757f5409b1faa1fdc8d571593be1782ad2b2939b8cff1b80bc4798.jpg","x":81,"y":1}
[2023-08-27 03:00:17.746] [opencv] [info] Loading image /home/<username>/.cache/ranger/8a2b1a35dfe8d2460d043cbaa8ed62d8f350b04accc54827301ad5b17facdad2cce3532cbe757f5409b1faa1fdc8d571593be1782ad2b2939b8cff1b80bc4798.jpg
[2023-08-27 03:00:27.075] [main] [error] SIGTERM received, exiting.
[2023-08-27 03:00:27.098] [main] [info] Exiting ueberzugpp

@Manix80
Copy link

Manix80 commented Sep 5, 2023

same problem here with ncspot and ranger (hyprland)

also with a 4k scale screen in 1.5

@jstkdng
Copy link
Owner

jstkdng commented Sep 13, 2023

hey, sorry for the delay. I gave it a go recently but can't find the culprit. I'd suggest using sixel or kitty as those seem to work fine.

@Kabouik
Copy link

Kabouik commented Sep 14, 2023

I got the same issue on my phone running Droidian (Wayland, Phosh) and Foot terminal, with ytfzf as well as lobster (and likely nnn but I didn't configure it to use ueberzugpp yet):

ss20230914-014539

Will try on Sway on my computer when I get some time to build ueberzugpp for it.

@jstkdng
Copy link
Owner

jstkdng commented Sep 14, 2023

hey, I think that's an issue with ytfzf and your fzf setup. Since gnome wayland isn't supported it must be using sixel and that works fine

@nicobuzeta
Copy link

Same problem with alacritty, sway, and 4k at 1.5 scale

@15cm
Copy link

15cm commented Oct 22, 2023

Same issue on Alacritty, Hyprland, Nvidia, with a 4k monitor under a 2 scale factor and a 2k Monitor under a 1.25 scale factor.

I managed to work around it by hard-coding a scale down on the coordinate and size in Ranger's image display code. See overlays/default.nix in the commit.

I verified it works in all trivial cases. Although in some corner cases, the rendered image location/depth could be incorrect, such as when you create a new other window the changes the terminal size or switch focus from the terminal to other windows whose Z axis is on top the terminal.

Verified cases:

  • Full screen in a full size tmux pane: 20231022-010620
  • Split screen in a full size tmux pane: 20231022-010634
  • Split screen in a 1/4 size tmux pane: 20231022-010644

BTW I originally found this issue from the issues in yazi. I tried a similar hard coded scale down in their code. It turned out to only fix the case of "Full screen in a full size tmux pane". As long as the terminal window or tmux pane doesn't occupy the full screen, the image position is still incorrect. I guess the calculation doesn't mange those complicated cases well.

@15cm
Copy link

15cm commented Oct 22, 2023

Update: I manged to work around it in Yazi as well sxyazi/yazi#207 (comment). The patch I had applied to Yazi was different to Ranger, where I didn't downscale the size for the former.

@jstkdng
Copy link
Owner

jstkdng commented Nov 5, 2023

Ignore my previous comment.

A proper fix is in master, only working in sway for now, please do test.

Edit: only working with opencv due to a libvips bug.

@jstkdng
Copy link
Owner

jstkdng commented Feb 3, 2024

scaling is fixed for libvips too now on master, closing

@jstkdng jstkdng closed this as completed Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants