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

Dragging window to another display makes Icon show up incorrectly #677

Closed
denis-ismailaj opened this issue May 19, 2021 · 1 comment
Closed
Assignees
Labels
rendering Low level rendering

Comments

@denis-ismailaj
Copy link

When I drag the window from my main display (2560x1600) to my secondary one (2560 x 1440), the Icon composable is duplicated and is shown at another size. It looks fine when I drag it back to the first screen though.

Image

I'm on Compose version 0.4.0-build190.

MInimal repro code:

fun main() = Window {
    Icon(
        imageVector = Icons.Default.Refresh,
        contentDescription = null
    )
}
@olonho olonho added the rendering Low level rendering label May 20, 2021
copybara-service bot pushed a commit to androidx/androidx that referenced this issue May 25, 2021
(or other any component that uses DrawCache)

Fixes JetBrains/compose-multiplatform#677

When density changes - the current size changes
(for example, `previousDrawSize` is 200 and `size` is 100)
and `drawCachedImage` calls.

And when we call `drawCachedImage` - we call `clear` with this
new passed size (100) instead of the size of bitmap (200).
So the bitmap draws with the previous drawn content.

Now we draw only part of the bitmap - with the passed to cache size.

```
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import kotlinx.coroutines.delay

@composable
fun App() {
    var density by remember { mutableStateOf(2f) }
    LaunchedEffect(Unit) {
        delay(1000)
        density = 1f
    }
    Box(Modifier.fillMaxSize()) {
        CompositionLocalProvider(LocalDensity provides Density(density)) {
            Icon(
                imageVector = Icons.Default.Refresh,
                contentDescription = null
            )
        }
    }
}
```

Test: manual (see code above)
Test: ./gradlew buildOnServer
Change-Id: Ib4a1ec9037eefd355c27ffb871a0bd7ca0693b6b
@igordmn
Copy link
Collaborator

igordmn commented May 28, 2021

Fixed in 0.4.0-build212

@igordmn igordmn closed this as completed May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rendering Low level rendering
Projects
None yet
Development

No branches or pull requests

4 participants