Skip to content

Add experimental Kotlin/Native Linux backend (X11)#1139

Draft
kdroidFilter wants to merge 4 commits intoJetBrains:masterfrom
kdroidFilter:feature/native-linux-x11
Draft

Add experimental Kotlin/Native Linux backend (X11)#1139
kdroidFilter wants to merge 4 commits intoJetBrains:masterfrom
kdroidFilter:feature/native-linux-x11

Conversation

@kdroidFilter
Copy link
Copy Markdown

@kdroidFilter kdroidFilter commented Dec 15, 2025

Description

This PR introduces an experimental Kotlin/Native Linux backend based on X11, allowing Skiko to run natively on Linux without relying on AWT or the JVM.

The main goal is to establish a minimal, maintainable native Linux foundation aligned with Skiko’s existing architecture, serving as a solid base for future Linux backends such as Wayland or EGL.


What’s Included

X11 Window Host

  • X11SkikoWindow

    • Native event loop
    • Resize handling
    • Basic pointer and keyboard input
    • Cursor support
    • Window manager close handling

Linux SkiaLayer Implementation

  • Attach and detach lifecycle for native windows
  • needRender and redraw integration
  • Picture recording in update() and replay in draw()

Native Rendering Backends with Automatic Fallback

  • OpenGL via GLX as the primary GPU rendering path
  • Software rendering via XPutImage as a fallback

Build and Toolchain Wiring

  • X11 and GLX cinterop for linuxX64 and linuxArm64
  • Linux native enablement set to auto on Linux hosts
  • Linux linker adjustments (-ldl)
  • __libc_single_threaded stub to unblock Kotlin/Native toolchain compatibility

Linux Platform Utilities

  • Best-effort open-URI implementation
  • Clipboard support using Wayland and X11 tools
  • System theme detection for GNOME, KDE, XFCE, and others
  • Minimal test to ensure theme detection does not crash

Sample Updates

  • Native Linux executable configuration
  • runNative Gradle task
  • Documentation updates
  • SKIKO_RENDER_API selection for testing

How to Test (Linux)

Dependencies (Debian / Ubuntu)

sudo apt-get install libx11-dev libxrandr-dev libgl1-mesa-dev

Run

cd samples/SkiaMultiplatformSample
./gradlew runNative

Notes / Scope

  • This backend currently targets X11 only.
  • OpenGL via GLX is the primary and intended GPU rendering path.
  • Software rendering is provided as a fallback for unsupported environments.

Roadmap (Out of Scope for This PR)

  • Wayland backend based on EGL for modern Linux environments and true zero-copy rendering
  • Additional native GPU backends as follow-up work

- Add OpenGL (GLX), Vulkan (X11 presenter) and software redrawers with fallbacks
- Wire X11 cinterop/linker opts and enable native Linux by default on Linux hosts
- Add Linux system theme detection + clipboard/URI best-effort
- Update SkiaMultiplatformSample to run as native Linux executable
@kdroidFilter kdroidFilter changed the title Native Linux X11 backend (OpenGL/Vulkan/software) Add experimental Kotlin/Native Linux backend (X11) Dec 16, 2025
@kdroidFilter kdroidFilter marked this pull request as draft December 16, 2025 10:45
@kdroidFilter kdroidFilter marked this pull request as ready for review December 16, 2025 13:13
@kdroidFilter kdroidFilter marked this pull request as draft December 17, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant