https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
z

zt

02/26/2024, 6:58 PM
I'm trying to get video playing in compose desktop by utilizing the mpv opengl rendering API. Theoretically I can render to a skia surface and display that in compose all without using SwingPanel are there any examples of interacting directly with opengl others could share? I'm aware of the lwjgl example which does help me but thats more like wrapping the entire compose app with lwjgi. I just need to somehow connect the skia surface to a compose component now
👀 1
k

Kirill Grouchnikov

02/26/2024, 7:34 PM
Probably somewhere around https://github.com/JetBrains/skiko/blob/master/skiko/src/commonMain/kotlin/org/jetbrains/skia/Surface.kt#L270 where opengl would be rendering into that frame buffer. You might end up reimplementing most if not all of the implementation of
SwingPanel
to get it all working. Is there a particular reason why you don’t want to use
SwingPanel
or the code in
lwjgl
? Do you have a working proof of concept that shows that these two can be cut out without borrowing much of their code?
l

Landry Norris

02/26/2024, 8:48 PM
When I worked on a video player in compose, I found writing to an ImageBitmap, and showing that to be surprisingly performant. The main gist was getting an ARGB byte array from my library (FFmpeg in my case) and using that to create an ImageBitmap. I forget the exact method name.
i

Ivan Matkov

02/26/2024, 8:54 PM
Please note that render something above that view via Compose might not be trivial. I'd suggest you to render it offscreen/to texture first to get predictable cross platform blending/overlapping
z

zt

02/27/2024, 4:33 AM
@Kirill Grouchnikov I'm avoiding SwingPanel since compose can't render on top of it which prevents making the control UI using compose
z

Zoff

02/27/2024, 7:30 AM
jpanel has the problem of hiding any compose stuff like tooltips. and has other issues.
@zt i would be very interested in something like this. i also am rendering YUV video frames with cpu into a jpanel. which is ok, but uses lots of CPU. can you link to your code repo? is it open source?
i

Ivan Matkov

02/27/2024, 8:52 AM
@Zoff - It was documented behaviour, but there are who related changes recently: • Drawing above interop - has some limitations, requires enabling offscreen rendering on linux • Optional showing Dialog/Popup as separate panel or even window - experimental, details will be on the page about 1.6.0 from our tech writers
m

Marcin Wisniowski

02/29/2024, 2:00 PM
@Ivan Matkov Where can I learn more about this “popup as separate panel or window” feature? The PR is light on details. Will this fix the issue that tooltips cannot extend past the edge of the window?
i

Ivan Matkov

02/29/2024, 2:04 PM
Where can I learn more about this “popup as separate panel or window” feature?
Docs are in process, it will be public soon. Let me find my draft
Will this fix the issue that tooltips cannot extend past the edge of the window?
yes, but please note that most of material built-in components has default logic to fit it to the size of the screen
Desktop - In EXPERIMENTAL stage and under the flag. It can be enabled by changing the
compose.layers.type
system property. The possible values are: 1.
COMPONENT
- for creating Popup/Dialog as a separate Swing component in the same window. It might work only with offscreen rendering. 2.
WINDOW
- for creating Popup/Dialog as a separate undecorated window. 3. any other value - the old behavior that draws everything in the initial canvas.
ComposePanel.windowContainer
- API for customizing parent container for Popup/Dialog. Used only with
COMPONENT
type.
m

Marcin Wisniowski

02/29/2024, 2:09 PM
I don’t use Material in my project, all my components are based on Foundation composables. But I had the issue with tooltips and dropdowns when near the edge of the window being forced back inside the window. This looks promising!
i

Ivan Matkov

02/29/2024, 2:09 PM
image.png
🤩 2
Please note that it's in experimental stage. Looking forward for your feedback
m

Marcin Wisniowski

02/29/2024, 2:11 PM
Is there some experimental release I can try in my project, or is it too early?
i

Ivan Matkov

02/29/2024, 2:12 PM
1.6.0
m

Marcin Wisniowski

02/29/2024, 2:12 PM
Oh so it’s just a matter of using the flag. I will give it a go!
👍 1
i

Ivan Matkov

02/29/2024, 2:13 PM
Also you might be interested in disabling built-in
Popup
clamping via
PopupProperties.clippingEnabled
flag
m

Marcin Wisniowski

03/06/2024, 2:51 AM
Unfortunately it doesn't seem to work correctly, at least on Linux. I used the
WINDOW
mode, but my context menus (Popups) don't render their content.
i

Ivan Matkov

03/06/2024, 3:59 AM
Please file an issue. Does manually created transparent undecorated window with Compose work for you?
m

Marcin Wisniowski

03/06/2024, 11:26 AM
Undecorated windows work fine, but transparent ones have issues on Linux (which I think got fixed in JDK 22, but I haven't tried it myself). Why are transparent windows needed here?
i

Ivan Matkov

03/06/2024, 11:28 AM
To respect round corners etc
m

Marcin Wisniowski

03/06/2024, 11:30 AM
Makes sense. Maybe it could be optional, with another
WINDOW_OPAQUE
mode? My non-Material tooltips and dropdowns don't have rounded corners anyway. Not sure if that's the actual issue though. I will experiment more and open an issue.
🤔 1
Would be useful to try without transparency to see if that's the issue or not.
8 Views