Skip to content

docs: Gtk2 JavaFX-backed implementation plan#655

Merged
fglock merged 2 commits intomasterfrom
docs/gtk2-javafx-plan
May 1, 2026
Merged

docs: Gtk2 JavaFX-backed implementation plan#655
fglock merged 2 commits intomasterfrom
docs/gtk2-javafx-plan

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented May 1, 2026

Summary

Adds dev/modules/gtk2.md — a detailed implementation plan for supporting
./jcpan -t Gtk2 on PerlOnJava using a JavaFX-backed shim instead of
native GTK2 C bindings.

Key decisions

  • JavaFX as backend (org.openjfx:javafx-*:21 from Maven Central), following
    the same pattern as XML::Parser (Java SAX replaces libexpat) and GD (Java AWT
    replaces libgd). No GTK2 system installation required.
  • Event loop model: Perl main thread + JavaFX Application Thread communicate
    via CompletableFuture + a callback drain queue. Gtk2->main() drains Perl
    callbacks while blocking; all FX operations go through runOnFXThread().
  • Headless CI: JavaFX Monocle (-Dglass.platform=Monocle) enables test runs
    without a display server.
  • Phased scope:
    • Phase 1 (~80 functions): core widgets (Window, Button, Label, Entry,
      CheckButton, ComboBox, VBox/HBox), event loop, signals
    • Phase 2 (~120 functions): menus, dialogs, TextView, ProgressBar, Image
    • Phase 3 (~80 functions): TreeView / ListStore / CellRenderer
    • Phase 4: full upstream t/ test suite parity
  • Minimal Glib.pm stub documented as prerequisite.
  • Widget/JavaFX mapping table for ~40 widget types.
  • build.gradle changes: org.openjfx.javafxplugin + javafx.controls/graphics/base.
  • Risk analysis covering event loop threading, TreeView complexity, Cairo/Pango gap, optional JavaFX dependency.

Files changed

  • dev/modules/gtk2.md (new, 827 lines)

Test plan

  • No production code changed; CI should pass as-is
  • make passes (doc-only commit)

Generated with Devin

fglock and others added 2 commits May 1, 2026 22:24
Add dev/modules/gtk2.md describing a four-phase plan to support
`./jcpan -t Gtk2` using a JavaFX shim instead of native GTK2 bindings.

Key design decisions documented:
- JavaFX (Maven Central org.openjfx) as backend instead of FFM/libgtk2
- Event loop threading model: Perl main thread + JavaFX Application Thread
  communicate via CompletableFuture + callback drain queue
- Synchronous widget dispatch via runOnFXThread() helper
- GLib signal -> JavaFX event handler mapping
- Headless CI support via Monocle (-Dglass.platform=Monocle)
- Widget/JavaFX mapping table for ~40 widget types
- ~80-function Phase 1 scope covering core widgets
- 4-phase roadmap up to full upstream test suite parity
- build.gradle changes: org.openjfx.javafxplugin + javafx.controls/graphics/base
- Minimal Glib.pm stub required as prerequisite

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Three issues corrected in the Gtk2 JavaFX plan:

1. Apple Silicon classifier: replace bare "mac" with conditional
   "mac-aarch64" for aarch64 (M1/M2/M3) vs "mac" for Intel.
   The javafxplugin detects this automatically; the manual snippet
   now includes the os.arch check.

2. shadowJar conflict: JavaFX JPMS modules cannot be merged into a
   fat JAR (duplicate module-info.class, broken native-lib extraction).
   Switch to compileOnly + separate javafxRuntime configuration that
   copies JARs to lib/javafx/ at build time. Add jperl-gtk / jperl-gtk.bat
   wrapper scripts that add --module-path lib/javafx at launch.

3. Linux runtime dependencies: document that the JavaFX GTK3 native
   peer requires libgtk-3.so / libpango / libfreetype / libXtst at
   runtime on Linux. Server deployments without these should fall back
   to Monocle headless; Gtk2.java must catch UnsatisfiedLinkError and
   degrade gracefully.

Also replace the already-answered "shadowJar size" and "macOS Quartz vs
Monocle" open questions with the remaining real open questions:
jperl auto-reexec, jcpan distroprefs for Gtk2, and Linux graceful
degradation on missing system libs.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 6b2bdfa into master May 1, 2026
2 checks passed
@fglock fglock deleted the docs/gtk2-javafx-plan branch May 1, 2026 20:44
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