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

alexandre mommers

03/26/2024, 12:06 AM
Hello, is there any way to get the X11 Display ?
g

Garret Yoder

03/26/2024, 3:53 PM
What do you mean by get the display?
a

alexandre mommers

03/27/2024, 6:29 PM
On linux you need a X11 display to create a X11 window.
windowHandle
from
ComposeWindow
allow to get the native handler of the window but i dont find a method to get the display.
g

Garret Yoder

03/27/2024, 6:32 PM
Are you trying to interface with X11 directly? Because if you're just trying to make the main window or a second one, you can do that from platform agnostic code via compose.
If you want to interface with X11 directly, JNI would be the route you'd likely want to go, but I'm not sure why you'd want to interface with X - especially since it's rapidly getting deprecated on most linux systems.
a

alexandre mommers

03/27/2024, 6:34 PM
I'm working on a webgpu binding. to create a context on Linux and use it on the window created with compose API, i need the display.
g

Garret Yoder

03/27/2024, 6:37 PM
Yeah you're going to want to use JNI for that. I imagine compose's implementation of that is internal. Everything it's going to expose to you on the surface is going to be something platform agnostic because it's JVM in the background.
Ontop of that compose doesn't know what "x11" is, it's using Swing in the background for window management. I'm not even sure if Swing has X11-specific methods, it might. The point of the JVM was to avoid stuff like that usually. I'd go down the route of either a JNI interface, or see if you can do something via swing. You can access all the underlying Swing stuff from compose.
There also might be a ready-made Java WebGPU binding you could just use.
a

alexandre mommers

03/27/2024, 6:41 PM
Well like compose provide a method to get the native window pointer, i was hopping to also get the display. But i think i will create the windows myself, this will be more easier.
g

Garret Yoder

03/27/2024, 6:43 PM
Oh I see. Yeah you could likely use JNI and xlib to do that.
a

alexandre mommers

03/27/2024, 6:47 PM
I fact i already did it, I'm using Glfw. They is already a existing binding using JNA : https://github.com/ygdrasil-io/wgpu4k/blob/feature/initial-version-with-basic-example/examples/glfw/src/main/kotlin/GlfwMain.kt But using compose with it require a lot of boilerplate code and that not really documented, so, i was looking for a simpler solution.
g

Garret Yoder

03/27/2024, 6:50 PM
I'd try to search around if there's an easy way to do it from Swing, because then you can apply the same method to compose