0

I just started a desktop project with Intellij, built with the default generated code, ran it on Linux, and it worked. Then I added a counter variable for the button text (shown as follows), it also ran as before. But when I click on the button, the change of text on reaction to the click takes as long as 10 seconds. Wonder what can be wrong.

I am running Xubuntu 22.04.

@Composable
@Preview
fun App() {
    var text by remember { mutableStateOf("Hello, World!") }
    var ic by remember { mutableStateOf(0) }
    MaterialTheme {
        Button(onClick = {
            ic++
            text = "Hello, Desktop! $ic"
        }) {
            Text(text)
        }
    }
}

fun main() = application {
    Window(onCloseRequest = ::exitApplication) {
        App()
    }
}

My build.gradle:

import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.6.10"
    id("org.jetbrains.compose") version "1.1.1"
}

group = "me.xxxx"
version = "1.0"

repositories {
    google()
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

dependencies {
    implementation(compose.desktop.currentOs)
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "11"
}

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "Test"
            packageVersion = "1.0.0"
        }
    }
}
LXJ
  • 1,180
  • 6
  • 18
  • From Compose point of view, you are doing everything right. When you encounter a failure of such basic behavior, especially when you can see that it works fine on other platforms, it is better to [report](https://github.com/JetBrains/compose-jb/issues/new) it. – Phil Dukhov Apr 12 '22 at 19:49

1 Answers1

0

Well, it turns out a VirtualBox setting issue. I run Xubuntu on VirtualBox hosted by MacBook Pro. I need to set graphics controller to VMSVGA on VirtualBox. So now it's responsive.

LXJ
  • 1,180
  • 6
  • 18