compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Linux hidpi scaling

Open audkar opened this issue 4 years ago • 26 comments

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

audkar avatar Dec 12 '20 11:12 audkar

Is there any workaround for now?

arkivanov avatar Feb 04 '21 17:02 arkivanov

Is there any workaround for now?

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

igordmn avatar Feb 04 '21 17:02 igordmn

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

arkivanov avatar Feb 04 '21 20:02 arkivanov

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 avatar Feb 04 '21 21:02 igordmn

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

floatingrain avatar Aug 01 '21 02:08 floatingrain

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 avatar Aug 03 '21 07:08 igordmn

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() { }

igordmn avatar Aug 03 '21 07:08 igordmn

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?

floatingrain avatar Aug 03 '21 09:08 floatingrain

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.

igordmn avatar Aug 03 '21 10:08 igordmn

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?

floatingrain avatar Aug 03 '21 10:08 floatingrain

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)

igordmn avatar Aug 03 '21 10:08 igordmn

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 avatar Aug 03 '21 10:08 floatingrain

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.

floatingrain avatar Aug 03 '21 10:08 floatingrain

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)

igordmn avatar Aug 03 '21 10:08 igordmn

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!

tom-pratt avatar Sep 27 '21 11:09 tom-pratt

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.

dsvi avatar Apr 26 '22 16:04 dsvi

GDK_SCALE=2 as an environment variable will help.

Burtan avatar Jul 19 '22 19:07 Burtan

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

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

dsvi avatar Jul 19 '22 20:07 dsvi

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

Burtan avatar Jul 20 '22 10:07 Burtan

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

bq-wrongway avatar Dec 23 '22 15:12 bq-wrongway

./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.

montanajava avatar Apr 16 '23 19:04 montanajava

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.

sschuberth avatar May 14 '23 16:05 sschuberth

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?

jj10133 avatar Aug 28 '23 02:08 jj10133