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

Linux hidpi scaling #188

Open
audkar opened this issue Dec 12, 2020 · 26 comments
Open

Linux hidpi scaling #188

audkar opened this issue Dec 12, 2020 · 26 comments
Assignees
Labels
desktop linux rendering Low level rendering ui glitch Visual glitch in UI, usually not blocking normal usage
Projects

Comments

@audkar
Copy link

audkar commented Dec 12, 2020

UI is not upscaled properly on some Linux desktops. Would be useful if compose-jb could use same logic as Intellij uses (ref)

Linux
jvm 14
Gnome 3.38 wayland

Intellij show hidpi info content:

Per-monitor DPI-aware : enabled
Monitor resolution : 1920x1080
Monitor scale : 2.0
User (IDE) scale : 1.0
Xft.DPI : 192
GSettings scale factor : undefined
GDK_SCALE : undefined
GDK_DPI_SCALE : undefined

@olonho olonho added this to To do in Compose Dec 17, 2020
@arkivanov
Copy link
Contributor

Is there any workaround for now?

@igordmn
Copy link
Collaborator

igordmn commented Feb 4, 2021

Is there any workaround for now?

Only manually set system parameter -Dsun.java2d.uiScale=2.0

@arkivanov
Copy link
Contributor

Tried specifying "-Dsun.java2d.uiScale=2.0" in IDEA Run Configurations VM options, does not work.

@igordmn
Copy link
Collaborator

igordmn commented Feb 4, 2021

System properties which are set by IDEA Run Configuration are visible only to gradle.

If they should be visible to application, we need to define them in build.gradle.kts:

compose.desktop {
    application {
        jvmArgs("-Dsun.java2d.uiScale=2.0")

@igordmn igordmn added ui glitch Visual glitch in UI, usually not blocking normal usage linux rendering Low level rendering labels Mar 11, 2021
@floatingrain
Copy link

floatingrain commented Aug 1, 2021

System properties which are set by IDEA Run Configuration are visible only to gradle.

If they should be visible to application, we need to define them in build.gradle.kts:

compose.desktop {
    application {
        jvmArgs("-Dsun.java2d.uiScale=2.0")

Still don't work on Linux

@igordmn
Copy link
Collaborator

igordmn commented Aug 3, 2021

Still don't work on Linux

We fixed DPI on some Linux'es some versions ago. But it seems that doesn't help in Fedora, probably in KDE-based distro's, and probably in Wayland

@igordmn
Copy link
Collaborator

igordmn commented Aug 3, 2021

By the way, don't call any java.swing.*, java.awt.* functions before calling application or the old Window.

Otherwise DPI will not be set.

If you call these kind of functions, you should call configureSwingGlobalsForCompose() explicitly before any code, in the beginning of the fun main() { }

@floatingrain
Copy link

floatingrain commented Aug 3, 2021

Still don't work on Linux

We fixed DPI on some Linux'es some versions ago. But it seems that doesn't help in Fedora, probably in KDE-based distro's, and probably in Wayland

I'm using Ubuntu with Gnome, all latest, I tried the simplest app created by IDEA, the "Hello, Desktop" button is so small in both Wayland and X11. And I added "jvmArgs("-Dsun.java2d.uiScale=2.0")" like you said, then noting happened. Might be something wrong? And I tried your example app "todoapp", it scaled correctly, but I can't find any code about hidpi in the project, even jvmArgs, why?

@igordmn
Copy link
Collaborator

igordmn commented Aug 3, 2021

I tried the simplest app created by IDEA
And I tried your example app "todoapp", it scaled correctly

IDEA uses the old version 0.4.0, and todoapp uses 1.0.0-alpha1-rc3.

@floatingrain
Copy link

I tried the simplest app created by IDEA
And I tried your example app "todoapp", it scaled correctly

IDEA uses the old version 0.4.0, and todoapp uses 1.0.0-alpha1-rc3.

Now we find the problem. How could I update the version?

@igordmn
Copy link
Collaborator

igordmn commented Aug 3, 2021

Now we find the problem. How could I update the version?

Change it as described here for desktop-only project or here for MPP project.

(don't add COMPOSE_TEMPLATE_COMPOSE_VERSION, it is only for our CI)

@floatingrain
Copy link

I tried the simplest app created by IDEA
And I tried your example app "todoapp", it scaled correctly

IDEA uses the old version 0.4.0, and todoapp uses 1.0.0-alpha1-rc3.

Now we find the problem. How could I update the version?

I found it, in build.gradle.kts->plugins. Maybe I should update my IDEA to preview version for always getting default latest compose version.

@floatingrain
Copy link

Now we find the problem. How could I update the version?

Change it as described here for desktop-only project or here for MPP project.

(don't add COMPOSE_TEMPLATE_COMPOSE_VERSION, it is only for our CI)

Thank you very much.

@igordmn
Copy link
Collaborator

igordmn commented Aug 3, 2021

Maybe I should update my IDEA to preview version for always getting default latest compose version.

IDEA will be always behind the latest version of Compose, even Preview version (but it gets the updated version faster, we usually change it after releasing the stable version of Compose)

@tom-pratt
Copy link

I can't get it to scale on Ubuntu 21.04. I've tried the todo app and some of the suggestions here. It always looks tiny!

@dsvi
Copy link

dsvi commented Apr 26, 2022

The IDEA itself looks fine though.
Why simply reading the output of xrdb -q | grep Xft.dpi and setting the scale accordingly is not an option anymore?
At least until some better option arrive.

@Burtan
Copy link

Burtan commented Jul 19, 2022

GDK_SCALE=2 as an environment variable will help.

@dsvi
Copy link

dsvi commented Jul 19, 2022

Nah it doesn't. Maybe because im under KDE.

BTW with wayland scaling is ok out of the box.
That was Kubuntu 22.04

@Burtan
Copy link

Burtan commented Jul 20, 2022

Ok, for me it helped under debian testing (bookworm) wayland Gnome

@bq-wrongway
Copy link

This is an issue only when running in debugging mode for me, when i run this in release mode it works properly
ie :

./gradlew runRelease == works properly.

This was on PopOs with wayland

@montanajava
Copy link

./gradlew runRelease == works properly.

This was on PopOs with wayland

Ditto for me on Fedora 37 Wayland. The normal interactive run button in IntelliJ renders an application very small.

@sschuberth
Copy link

FYI, I believe scaling used to be ok in Jetbrains Toolbox (which is written with Compose itself) until a few versions ago, but now the toolbox fonts render ridiculously small compared to other windows on a 2560x1440 pixel display. I'm also on Fedora 38 on Wayland.

@warmachinesocial
Copy link

Hi everyone, I was facing the same issue whenever I'm switch from my monitors to laptop screen. Having read the above comment, running with gradlew runRelease works for me. So my plan is work on this issue and make a PR however no clue as to where to begin from like I have no clue on compose nor much on wayland, could somebody help me out with references if they have worked on this similar issue?

@kravemir
Copy link

kravemir commented May 5, 2024

It would be great, if Wayland's Fractional scale protocol was supported.

Nowadays, monitors come with quite odd PPI's, that integer HiDPI scaling isn't particularly usable anymore. The 2x makes everything too big, but 1x makes everything too small.

Besides the odd PPI of modern displays, fractional scaling helps with accessibility - some people scale normal DPI displays to 125%.

@cromefire
Copy link
Contributor

cromefire commented May 5, 2024

One thing I haven't tested, but might help, is trying the jbr (jetbrains runtime) as a JDK/JRE, as I believe it contains certain fixes/improvement for the Java display stuff (explicitly listing HiDPI) and that's what the toolbox (I believe yes it is) and idea use.

@sschuberth
Copy link

One thing I haven't tested, but might help, is trying the jbr (jetbrains runtime) as a JDK/JRE

Given that JetBrains ToolBox (which AFAIK runs on JBR) has the same issues, I doubt that's going to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop linux rendering Low level rendering ui glitch Visual glitch in UI, usually not blocking normal usage
Projects
Compose
To do
Development

No branches or pull requests