I got frustrated by Compose Desktop being X11 only...
# feed
s
I got frustrated by Compose Desktop being X11 only on Linux, not supporting fractional scaling, and janky window resizing, so I built a new JVM Compose host that runs Compose UI in a GLFW window instead of the default AWT/Swing desktop host. I've just released v0.2.0. Usage guide and demo in the repo: https://github.com/sargunv/compose-glfw or see the API Reference It supports: • Linux (Wayland and X11), macOS, and Windows, all on arm64 and x64 • Dark and light theme detection on all platforms • Fractional scaling on all platforms • Exposed GPU render context for advanced rendering integrations (like integrating a map, game, or video) • Single and multi window state and app composition • All the basic input (mouse, scroll, keyboard, text, and clipboard) ◦ not yet IME, touch, and stylus • Miscellanea: native file pickers, custom cursors, file drops Usage is easy, in most cases you can just replace
application { }
with
glfwApplication { }
and you're done. The main missing features compared to standard Compose Desktop are screen reader support, native menus, and the system tray. Still, it's quite a nice experience; I was shocked how much nicer my app felt on desktop just by changing out the Compose host. I'm aiming to gradually fill out the feature matrix, prioritizing IME and screen reader parity first and foremost, then niceties like touch, system tray, etc.
🙌 11
🙌🏾 1
👀 13
🚀 3
a
I promise to try this and see the difference
s
main
branch now has IME support, improvements to scrolling responsiveness, and improved macos fullscreen
f
Awesome! 😄 🎉
a
this is awesome. I really eventually want full native targets for CMP. Just give me an exe i can run!
s
Glfw should be usable with cinterop, I bet an llm could port this to Kotlin Native with mostly equivalent feature parity, just swapping lwjgl for cinterop Main gap is I think compose/skiko are apple only on native, so if you want cross platform you gotta port those first
(also if I did it again, I'd probably go with SDL over GLFW, they provide a lot more of the basics without dipping into extensions or direct platform SDKs)
a
there's also this official jetbrains effort that might do the trick? https://github.com/JetBrains/kotlin-desktop-toolkit
I wounder what they're using on MacOS 🤔
s
looks like the native os sdks, via rust their feature matrix is interesting, they've got file drop working on wayland (I'm missing it) but no clipboard or file drop on windows (I have that) that said, they're building a whole desktop abstraction layer (like sdl/glfw), while I'm just bridging existing low level abstractions (glfw) or os apis directly to compose
a
ya sounds like they are planning a near full replacement for AWT, which is super impressive if they bring it all the way to production!
Nucleus also has something, that is maybe slightly higher level than what you're doing here, using JNI to bind native windowing: https://nucleusframework.dev/runtime/decorated-window/#decorated-window-jni-nucleus-native-implementation
👍 1
it's clearly a huge need in the CMP ecosystem, AWT is just not cutting it.
s
yup, and I'm sure mine will be obsolete as soon as theirs ships to prod
I spent like, all of about an hour getting mine to PoC, and two days to the mostly fleshed out state it's in now, so I'm happy shipping something decent today rather than waiting for the official solution someday. needs another round of effort to bridge accessibility trees before serious apps can use it, but so far it's all been surprisingly easy (with a few frustrating platform quirks along the way). I already had a ton of sample windowing and rendering code from all the examples in my github.com/maplibre/maplibre-native-ffi project, so it was mostly a matter of translating that and bridging to compose. Giving an ai agent access to Windows and Linux VMs on my Mac was super useful for a single agent to iron out quirks across three operating systems and four windowing systems
a
ya thats awesome, and it's nice to have something working today
s
@אליהו הדס made Nucleus. I think he will be interested in this discussion. 🙂