microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.28k stars 310 forks source link

WSLg does not seem to support fractional scaling #23

Open EndPositive opened 3 years ago

EndPositive commented 3 years ago

Environment

Microsoft Windows [Version 10.0.21364.1] 
kali-linux 2021.1
1.0.17.1]

Steps to reproduce

Set display scaling to 150%. Open a graphical application on that monitor (or move it to that monitor).

Expected behavior

The application scales according to the windows display scaling settings.

Actual behavior

wslg only seems to support 100% and 200% as display scales.

hideyukn88 commented 3 years ago

@EndPositive, this is currently disabled by default, it can be enabled by WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false. This is disabled due to scaling quality in RDP client software.

r3dlobst3r commented 3 years ago

I am also having this issue on my surface go 2 at 150% scale. I attempted to use WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false under [wsl2] in my WSL config file and it did not work. I did restart wsl.

hideyukn88 commented 3 years ago

Sorry, I should have put more clearly, please create a file named .wslgconfig at c:\ProgramData\Microsoft\WSL (or /mnt/c/ProgramData/Microsoft/WSL/.wslgconfig from Linux) with contents of below, and restart WSL with wsl --shutdown or wsl --terminate [distro name].

[system-distro-env] WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false

ayalon commented 3 years ago

Is there already a plan when fractional scaling is supported? Almost all new monitors are 4K or more and some text scaling in Windows is very common.

iongion commented 3 years ago

With both .wslconfig options turned off, there is this strange behavior.

On a 4K monitor - Firefox / Chrome have proper scaling and they look good, even the mouse cursor image

But gtk 3 apps such as gedit are double the size and the mouse cursor is huge image

Maybe this reporting helps, thanks, wslg is awesome!

ghost commented 3 years ago

It seems that if I am at 150% then the Linux app automatically goes to 100%, I want the opposite. Is there any way workaround to have a 150% and obtain a 200% result on the Linux apps?

hideyukn88 commented 3 years ago

@adelicato, currently that's not possible, unless building custom version of system-distro. If you are interested in, you can modify below line of code, which currently drops fractional part by casting to int, but it can be changed to round it up. Thanks!

https://github.com/microsoft/weston-mirror/blob/working/libweston/backend-rdp/rdpdisp.c#L85

user9931 commented 3 years ago

Any hope that Windows scaling 150% -> wsl 200% will be implemented any time? with option, for example... because WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false gives very blurry fonts

ayalon commented 3 years ago

I have the same issue.

hjgarcia1 commented 2 years ago

same here.

ThalusA commented 2 years ago

Any updates? This is still going from the start of WSLG, and no one ever thinks about fixing this problem at all? Having good quality for graphical desktop inside WSL should be mandatory when you are releasing a product like that, not optional.

PSzczepanski1996 commented 2 years ago

Any updates? This is still going from the start of WSLG, and no one ever thinks about fixing this problem at all? Having good quality for graphical desktop inside WSL should be mandatory when you are releasing a product like that, not optional.

It still can depends on Linux side, because Linux since years doesn't support Mixed DPI or has great DPI support in general, and I am not sure if Microsoft can do anything about that anyway. But I still have an hope.

craigloewen-msft commented 2 years ago

Hi folks, we've made an update in the latest version of WSLg that is available with WSL in the Microsoft Store to change the behaviour where 150% Windows scaling will now go up to 200% WSLg scaling. Please try it out and give us any feedback that you have!

sandain commented 2 years ago

@craiglowewn-msft: Is there anyway to make 150% Windows scaling = 150 WSLg scaling? 200% makes gnome programs (e.g., gedit) and the mouse cursor huge! As noted above, WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false makes the windows and cursor the proper size, but gives very blurry fonts.

sandain commented 2 years ago

It looks like fractional scaling doesn't actually work. I found that setting WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=150 either does nothing, or gets rounded to 200%. WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=100 gives me the 100% scaling that I expect (without the blurry fonts the WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING options does). Of course I would rather have 150% scaling, but I'll take 100% over 200% any day.

PR #53 should be reverted since it doesn't fix the real problem, and makes things arguable worse.

khuongduybui commented 2 years ago

All due respect @sandain I believe we are trying to solve the opposite problem. The default experience used to be 150% => 100%, which makes thing too hard to read, so in the latest build they are trying to switch the default to 150% => 200%. Now you are complaining that it's too big haha. I guess we will simply need to wait until non-blurry fractional become a thing.

khuongduybui commented 2 years ago

Also @EndPositive I saw that you both thumbed up and thumbed down on Craig's post above? lol

EndPositive commented 2 years ago

Whoops, corrected. As you said, a simple round up/down won't suffice in most cases.

sandain commented 2 years ago

@khuongduybui: It seems the goal should be 150%=>150% or 125%=>125%. Rounding up or down is not ideal. At least with rounding down, as it was, it is easy to increase font sizes. With rounding up by default, window decorations take up a ridiculous amount of screen real estate, and I don't know an easy way to work around that on the Linux end of things.

Requiring the use of a poorly documented debugging option (that doesn't actually give you what you ask for) to work around your "fix" (#53) is the opposite of user friendly.

eggcaker commented 2 years ago

is any hack way to make the gui app smaller for this moment? after set WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false still looks very big , even the mouse cursor is very big too

sandain commented 2 years ago

@eggcaker Add WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=100 to c:\Users\[your user name]\.wslgconfig

ryantheleach commented 2 years ago

I know this is unrelated to fractional scaling, but I have a Surface Book 3. It's recommended scaling is 200%.

Apps are still super blurry, I thought with integer scaling everything should be fine?

hideyukn88 commented 2 years ago

@ryantheleach, unfortunately no, please refer https://github.com/microsoft/wslg/issues/3, whenever there is post scaling, the quality of scaling is not ideal currently.

Skaldebane commented 2 years ago

I guess it would be better off to add an option to make 150% Windows scaling set WSLg scaling to 100% for those who need it. I have a 1080x1920p display and 200% looks too big (just unusable, big portions of the UI out of the screen).

Note that setting WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=100 doesn't work for me.

hideyukn88 commented 2 years ago

@Skaldebane, we reverted the change to round up the scaling factor. And "WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=100" should work, how do you configure it? Please refer https://github.com/microsoft/wslg/wiki/WSLg-Configuration-Options-for-Debugging.

b-hayes commented 2 years ago

FYI I ended up here trying to fix the "problem" that 150% => 200%. Applications are HUGE! I'd rather have a little bit of blur than a giant app with no room to move. I am using 150% because I NEED the screen real estate. If I wanted 200% id already be using that in windows. And if the blur is a problem then Id rather 100% over the giants any day of the week because naturally, I am using a large 4k screen not a tiny 4k screen.

So are we actually trying to use fractional scaling here or argue over what nonfractional scaling is better?

How can I actually enable fractional scaling? can we talk about a hack for that instead? (I don't care if its blurry just want to see it for myself)

abarisain commented 2 years ago

try

WESTON_RDP_DISABLE_HI_DPI_SCALING=false
WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false

WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=150

However, this results in ugly pixelated scaling rather than blurry. This is probably why it's disabled by default

b-hayes commented 2 years ago

@abarisain thanks for the suggestion but doesn't appear to do anything.

try


WESTON_RDP_DISABLE_HI_DPI_SCALING=false
WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false
WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=150

This doesn't do anything. I get 200% scaling with HIDPI matter what. I'm guessing this needs to be in user/.wslconfig under a [system-distro-env] heading yeah? Please let me know how to use those settings.

However, this results in ugly pixelated scaling rather than blurry. This is probably why it's disabled by default I guess so. It will only replicate 100% scaling on a 1440p screen tho shouldn't be as bad as giant 200% UI.

@craigloewen-msft

150% Windows scaling will now go up to 200% WSLg scaling

So you just removed fractional scaling entirely instead of fixing it? Can you at least add an option to enable it again so I don't have to have this back n forth in GitHub trying to hack get it?

Rather have a less than perfect version of fractional scaling than to have it removed. The pixelated version is probably better than a blurry one too as that will just replicate looking at a 1440p screen with 100% scaling. Can't be that bad.

Could a better solution be to use 200% and then scale the rendered result down to 150% to make it sharper?

At any rate, Id answer this ticket with:

  1. keep the 150% -> 200% as default but add an option to enable fractional scaling.
  2. latter address the blury/pixely complaint that will no doubt come in another github issue.
  3. try to fix the blurry factional scaling issue or state that its not possible.
abarisain commented 2 years ago

No, this goes in .wslgconfig. Note that I'm also running the windows store WSL version.

It's promising. Once the scaling algorithm gets fixed, it will already be better. Then, we need to run at 200% and downscale rather than the opposite.

The pixelated version is super bad in my opinion. It looks worse than looking at a 1440p screen of the same size for two reasons:

Honestly I've had the best experience downgrading back to a Xorg server and setting Xft.dpi: 144 in ~/.Xresources (this has no effect on wslg). GTK apps don't care, but it makes Intellij, Sublime merge and anything QT work. Good enough for me in the meantime.

I can't wait to go back to wslg, but it's a hard thing to solve: wayland only knows 2x scaling, but compositors downscale to 1.5 (making things look a bit blurry but it's fine. I guess that's the next step for RDP? I'm sure it's in the works), only X can try to do 150%. Linux's hdpi support isn't the best even on a pure linux env: Xwayland can't deal with HDPI either. That's another hurdle wslg will have to overcome: there are PRs in the Linux world to fix Xwayland/HDPI but they've been stuck for years. Sometime a new approach come up, but we're nowhere near a fix.

Note: Both IntelliJ and Sublime Text/Merge allow you to override the scale, which can make 150% work. Unfortunately this still cause issues with some UI elements that don't show up with the Xorg technique.

Could just using 200% and then scaling the rendered result down to 150% to make it sharper be a better solution?

I think that's the plan, they just need time to work on it.

b-hayes commented 2 years ago

@abarisain thanks for the detail. I might give Xorg a shot later.

No, this goes in .wslgconfig. Note that I'm also running the windows store WSL version.

I did, and me too. I shutdown wsl too. I must be missing something.

Linux's hdpi support isn't the best even on a pure linux env

Actually, when I tried native Ubuntu it was perfect. No blurring at all. I could even position a window halfway between 2 screens using different DPI's and both rendered at the correct size. Maybe this is a new development and it was bad before, but its currently better than windows.

Might be worth looking into how they are doing it.

abarisain commented 2 years ago

Oh it's also worth noting that I'm running Insider Fast releases of W11. You need to run "wsl --shutdown" after tweaking the settings.

Anyway, is your ubuntu running Xorg or Wayland?

Native ubuntu on Xorg scales the whole screen which comes with a performance cost: your computer renders stuff at a higher (2x) resolution and downscales to 1.5x. macOS works like that too. As Xorg doesn't support mixed dpi screens (as opposed to macos), even a 1440p screen would be rendered at 2x (5k) and then downscaled back to 1440p.
Stuff looks great but it comes with a performance penalty that weak computers struggle with. It also has a huge drawback if you're playing games: they will see the virtual resolution (macOS has games that care about this and show the panel resolution, linux does not) and will be scaled. So you can't run them at your screen's native resolution and will have to deal with scaling and its performance loss.

Using a KDE based distribution works way differently: KDE tries to run everything at the native resolution and ask apps to scale to 150%. This makes stuff a bit wonky in some apps (1px borders in browsers for example), especially GTK ones as they don't support fractional scaling, but it's faster and crispier. It's also how Microsoft went and handled scaling on Windows.

Wayland doesn't work like that, and this is based on wayland. Xwayland has zero hdpi support even on linux.

TLDR: 150% scaling is a stopgap until we all can get 2x screens and it kinda sucks due to the various hacks required to make it work. MacBooks recently switched to higher density screens and it's much better. Fractional scaling is a hard problem to solve even if Apple made it look painless.

b-hayes commented 2 years ago

Insider Fast releases of W11

I am still on windows 10.

is your ubuntu running Xorg or Wayland?

Whatever the default was for Ubuntu LTS 20 || 20.04. It had problems with Zoom screen sharing so I went back to windows.

downscales to 1.5x. macOS works like that too KDE tries to run everything at the native

Yeah, that's interesting. I noticed windows was much faster and crisper than MacOS even when running on the same MacBook internal display Macos seemed a bit fuzzy all the time. This was years ago tho. Ubuntu seemed very sharp tho but that was more recent. Hopefully, Apple is sharper nowadays as I'll be getting one again soon.

this is based on wayland. Xwayland has zero hdpi support

Probably wasn't a good choice for a windows application then was it. 😅 maybe they need to switch to Xorg.

Again thanks for the detail abarisain I love it.

b-hayes commented 2 years ago

OMG The option I am after is right here! image

stedwick commented 2 years ago

@b-hayes Where is that setting that you screenshotted?

b-hayes commented 2 years ago

@stedwick RIght click on the WLG icon in the system tray. (I think... I don't have wslg anymore).

jason-unsworth commented 2 years ago

I believe that, technically, b-hayes was using GWSL at the time, rather than WSLg. 🙂

n3dst4 commented 2 years ago

This conversation (about WSLg) has got muddied with discussion about GWSL, which is a completely separate project. They are vagualy linked by being graphics systems for WSL but that's it.

b-hayes commented 2 years ago

Oops sorry about that.

nidhoggr-nil commented 2 years ago

To keep it short, because I'm confused, but:

  1. Is there ANY way to get a higher scaling of apps without making everything blurry? Do I have to incant a specific combo of software to hit the scaling just right?

  2. Fractional scaling is NOT supported, and with that out of the way, the status of supporting it seems to be "whenever the linux ecosystem supports it"?

iamalinaji commented 2 years ago

Sorry, I should have put more clearly, please create a file named .wslgconfig at c:\ProgramData\Microsoft\WSL (or /mnt/c/ProgramData/Microsoft/WSL/.wslgconfig from Linux) with contents of below, and restart WSL with wsl --shutdown or wsl --terminate [distro name].

[system-distro-env] WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false

I really appreciate if you help me. Even after applying these settings still the scale is same as before and I don't why ?

hideyukn88 commented 2 years ago

@alinajimahalleh, if you are on the latest WSL release, please try WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true, thanks!

TaChao commented 2 years ago

@alinajimahalleh, if you are on the latest WSL release, please try WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true, thanks!

still blurry

SPiCa-P commented 2 years ago

@alinajimahalleh, if you are on the latest WSL release, please try WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true, thanks!

The 150% scaled window is blurry:(

vincentzz commented 1 year ago

Hi, I tried the solution provided above, but seems WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true is not taking any effect. I am setting up new laptop on Win11 with WSLg so I got wsl2, Ubuntu update to the lastest version. After went through this thread, I have my .wslconfig like below:

[wsl2]
memory=8GB

[system-distro-env]
WESTON_RDP_DEBUG_LEVEL=5
WESTON_RDP_HI_DPI_SCALING=true
WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true
WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=175

The entry memory=8GB is taking effective, but all WESTON related entries are not.

I got my /mnt/wslg/weston.log I can see the debug level is still 3 disrepecting I have put 5 in the configuration file. All other high DPI scaling related setting were ignored as well.

[11:02:18.358] RDP backend: WESTON_RDP_DEBUG_LEVEL: 3

My I know if any recent changed broke it or I have miss-configured anything. Thank you.

nkrepo commented 1 year ago

It may has to do that not all prerequisites are not in place. I am not sure if it is related but recently fractional scaling support was added to Wayland protocol:

wp-fractional-scale-v1: New protocol for fractional scaling

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/143/diffs#14e16f084bc9d75c513182b6e98f505d14ac3477

abannachGrafana commented 1 year ago

I'll chip in that from following the bouncing ball here, I was able to get my IntelliJ IDEA to scale, but the image is pixelated (not terrible, but noticeable).

System info:

WSL version: 1.0.3.0
Kernel version: 5.15.79.1
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1335 # Windows 11

Desktop resolution: 3840x2160
Scale: 150%

C:/users/<username>/.wslgconfig

[system-distro-env]
WESTON_RDP_HI_DPI_SCALING=true
WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true
WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=150

Scaled:

image

Unscaled:

image
yohihoy commented 1 year ago

@abannachGrafana Thank you, you saved my night. I changed only: WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR=100

and added to bashrc: export GDK_SCALE=2.5

Thats all, no thick borders and caption, looks very nice. Thank you

soroushabt commented 1 year ago

@craigloewen-msft I will appreciate if you do something about this problem. this is so annoying

Laess3r commented 1 year ago

Did I understand correct that there is still no "out of the box" solution for this standard issue? 😢 Fractional scaling is de-facto for everyone using 4k monitors.

Setting a fixed scaling is no solution when using a laptop with different displays (eg 4k at office 150%, fhd at home 100%)

hideyukn88 commented 1 year ago

@Laess3r, thanks for being patient on this issue, I think HI-DPI is a bit more complicated in Linux GUI space since its solution is largely dependent on each application framework, such as GTK and Qt, rather than window manager or UI compositor. Thus,, legacy framework such as Xt/Motif has no support for that, and often those applications won't be scaled at all on most of native Linux desktop, while WSLg does the best effort to scale them (but with limitation of scaling quality). For fractional scaling, even Ubuntu Desktop 20.04 LTS does not enable fractional scaling by default. Also, for newer Wayland, its output scaling protocol is still integer base. We will need more time to evaluate the solution, thanks!