Skip to content

Add an AWT toolkit and a sound mixer for Haiku - #61

Draft
duncanmcqueen wants to merge 3 commits into
ingelabs:masterfrom
duncanmcqueen:haiku-peer
Draft

duncanmcqueen wants to merge 3 commits into
ingelabs:masterfrom
duncanmcqueen:haiku-peer

Conversation

@duncanmcqueen

@duncanmcqueen duncanmcqueen commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request adds an AWT toolkit and a sound mixer for Haiku. It needs the Haiku host fix #74 (#73 and #75 are merged). This branch is on the current master and contains the commit of #74 first, so that it builds on Haiku. When #74 is merged, I will rebase it, and only the two Haiku peer commits will stay.

  • gnu.java.awt.peer.haiku: an AWT toolkit. Windows, menus, file panels, cursors, the clipboard (text, pictures, files and other MIME data), drag and drop, printing (through the Haiku print server), input methods, minimize and zoom, modal and always-on-top windows are native Haiku parts. The other widgets use the Swing peers (gnu.java.awt.peer.swing). Haiku's font engine measures and draws the text, so the text looks like the text of other Haiku applications.
  • gnu.javax.sound.sampled.haiku: a javax.sound.sampled mixer. It has Clip and SourceDataLine lines that play through the Haiku media server.
  • native/jni/haiku-peer: libhaikupeer (C++, links with -lbe -ltracker -lmedia -ltranslation). include/Makefile.am makes its JNI headers.
  • configure: --enable-haiku-peer. It is on by default when the host is Haiku. Then HaikuToolkit is the default toolkit and the Haiku mixer is in the MixerProvider list. On other hosts nothing changes.

Some parts work fully only with the fixes in the related pull requests: drag and drop (#69, #70, #71, #72; with #72, the peer limits the drop action to the target actions), Frame.setState() (#66), PrinterJob (#67; for Haiku printing, give -Djava.awt.printerjob=gnu.java.awt.peer.haiku.HaikuPrinterJob), canDisplay() (#68), and the build fixes (#62, #63, #64). With Kaffe, a Kaffe fix is necessary for any program to start: Kaffe must make the main Thread object with the Thread(VMThread, String, int, boolean) constructor (see #65; the fix is in duncanmcqueen/kaffe and in BeKaffe patches/kaffe/0004).

Tests

On Haiku R1/beta6 x86_64 with Kaffe 1.1.10 (interpreter): AWT widget tests, Swing, the JDK 1.0/1.1 demo applets, the clipboard in both directions with other applications, drag and drop with the file manager and a text editor, printing to the Haiku "Preview" printer, simulated input method sessions, sound clips and streams (timing checked), and modal dialogs. I built this branch alone on Haiku; it builds. I tested the programs above with all five pull requests together.

The project page has screenshots: https://duncanmcqueen.github.io/bekaffe/

AI assistance

An AI model (Claude Code, by Anthropic) wrote these changes and this text. The repository owner directed the work. Please review the changes as you review other contributions.

The commits have a Signed-off-by line from the owner.

🤖 Generated with Claude Code

@duncanmcqueen

Copy link
Copy Markdown
Contributor Author

I added a commit: Haiku peer: draw shapes and images with native code.

On Kaffe's interpreter, per-pixel Java code is very slow. The new file native/jni/haiku-peer/gnu_java_awt_peer_haiku_HaikuRaster.cpp draws the usual cases directly in the int[] pixels of the image: rectangles, 1-pixel lines, paths (with or without anti-aliasing), thin outlines, solid colours and linear gradients, images through any affine transform, and copyArea. Other cases (clips that are not rectangles, texture paints, other composite rules) use the Java code of AbstractGraphics2D as before.

Measured on Haiku with Kaffe (microseconds per operation, before / after):

Operation Before After
fillRect 100x100 1065 30
fillOval 100x100 7350 530
line, width 4 42100 310
gradient fill 160600 250
translucent image 100x100 16730 170
scaled image 327720 560
rotated image 2965950 200
copyArea 200x100 207620 60

The full build passes check_jni_methods.sh. The widget tests and the JDK 1.0/1.1 demo applets show correct output. This commit does not have a Signed-off-by line yet; the owner will add it.

🤖 Generated with Claude Code

On Haiku, gethostbyname_r() is in libnetwork but no header declares
it, so configure finds the function but not the number of arguments,
and cpnet.c stops with #error. Use gethostbyname() in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
duncanmcqueen and others added 2 commits October 22, 2026 08:25
gnu.java.awt.peer.haiku is an AWT toolkit for Haiku. Windows, menus,
file panels, cursors, the clipboard, drag and drop, printing (through
the print server) and input methods are native Haiku parts. The other
widgets use the Swing peers. Haiku's font engine measures and draws
the text.

gnu.javax.sound.sampled.haiku is a javax.sound.sampled mixer with Clip
and SourceDataLine lines that play through the Haiku media server.

Both use libhaikupeer (native/jni/haiku-peer, -lbe -ltracker -lmedia
-ltranslation). configure --enable-haiku-peer builds them; it is on by
default when the host is Haiku, and it then makes HaikuToolkit the
default toolkit and registers the mixer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
On Kaffe's interpreter, per-pixel Java code is very slow. Draw the
common cases natively, directly in the int[] pixels of the image:
rectangles, 1-pixel lines, any path (curves flattened, both winding
rules, with or without anti-aliasing), thin outlines as 1-pixel lines,
solid colours and linear gradients, images through any affine transform
(nearest neighbour or bilinear), and copyArea. Other cases (clips that
are not rectangles, texture paints, other composite rules) use the Java
code of AbstractGraphics2D as before.

Measured on Kaffe (microseconds per operation, before / after):
fillRect 100x100 1065 / 30, fillOval 7350 / 650, line of width 4
42100 / 310, gradient fill 160600 / 250, translucent image 16730 / 170,
scaled image 327720 / 580, rotated image 2965950 / 200,
copyArea 207620 / 60.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
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