zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.59k stars 2.64k forks source link

Zed does not scale 2x on HiDPI X11 Linux system #14537

Open wezm opened 1 month ago

wezm commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I use the Awesome window manager on Arch Linux and have two 4K 24-inch screens running with 2x scaling. Zed renders 1x unlike everything else I run. I do not have Xft.dpi set, which is what Zed appears to use to determine the scale:

https://github.com/zed-industries/zed/blob/e68d9f4625016783f8f030dfe99dfa4df4535149/crates/gpui/src/platform/linux/x11/client.rs#L283-L288

I do have these two settings in my .xprofile that take care of scaling for everything else:

xrandr --dpi 192
export GDK_SCALE=2

Now you may be wondering why I dont just add Xft.dpi: 192 to ~/.Xresources, the reason is that this causes some applications (in particular Firefox) to render at 4x. Since Zed is the odd one out I think it should work as-is.

Environment

Zed: v0.143.7 (Zed) OS: Linux X11 arch unknown Memory: 62.5 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

I'm aware that all the possible combinations of desktop environments on Linux make getting this right hard. I would suggest exposing the ui_scale to the settings so that if the automatic detection doesn't work the user is able to override it in their configuration. Alternatively supporting a environment variable like ZED_UI_SCALE=2 could be an option.

If applicable, attach your Zed.log file to this issue.

No response

l-7-l commented 1 month ago

same on wayland

jansol commented 1 month ago

@l-7-l Zed scales perfectly correctly on my Wayland (Plasma 6) setup with one screen set to 200% and one to 100%. If it doesn't do that on your setup, please open a separate issue for that and mention what DE/compositor you are using.

jansol commented 1 month ago

I would suggest exposing the ui_scale to the settings

There is "ui_font_size", which effectively scales everything. Not an ideal solution, but on X11 there will be no such thing anyway. It should be usable as a workaround for the time being, though.

wezm commented 1 month ago

There is "ui_font_size", which effectively scales everything. Not an ideal solution

Yeah not ideal. For now I'm building a patched version of the Arch Linux package that replaces the X resources code with a hard coded value of 2.0.

jansol commented 1 month ago

FWIW, looks like winit queries the monitor properties directly from the X server. This is probably a better approach than looking at Xresources...