Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ docs/apidocs
/macos/cmake-build-debug

# jvm crash logs
hs_err_*.log
hs_err_*.log

# Gradle
.gradle
18 changes: 14 additions & 4 deletions examples/dashboard/java/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.stream.*;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -78,17 +79,26 @@ public Example() {
case 4 -> window.setWindowPosition(bounds.getLeft() + bounds.getWidth() / 2, bounds.getTop() + bounds.getHeight() / 2);
}

var classLoader = getClass().getClassLoader();
switch (Platform.CURRENT) {
case WINDOWS -> {
window.setIcon(new File("examples/dashboard/resources/windows.ico"));
try {
window.setIcon(new File(classLoader.getResource("windows.ico").toURI()));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
case MACOS -> {
window.setIcon(new File("examples/dashboard/resources/macos.icns"));
try {
window.setIcon(new File(classLoader.getResource("macos.icns").toURI()));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
case X11 -> {
((WindowX11) window).setClassHint("jwm-dashboard-example"); // allows OS-wide identification of the window (e.g. icon themes, .desktop files)
try {
Bitmap i = Bitmap.makeFromImage(Image.makeDeferredFromEncodedBytes(Files.readAllBytes(Path.of("examples/dashboard/resources/linux/icon_48x48.png"))));
try (var in = classLoader.getResourceAsStream("linux/icon_48x48.png")) {
Bitmap i = Bitmap.makeFromImage(Image.makeDeferredFromEncodedBytes(in.readAllBytes()));
ImageInfo info = i.getImageInfo();

((WindowX11) window).setIconData(info.getWidth(), info.getHeight(), i.readPixels());
Expand Down
6 changes: 5 additions & 1 deletion examples/empty/java/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public Example() {
window = App.makeWindow();
window.setEventListener(this);
window.setTitle("Empty");
window.setLayer(new LayerGLSkija());
try {
window.setLayer(new LayerGLSkija());
} catch (Throwable e) {
window.setLayer(new LayerRasterSkija());
}

var screen = App.getPrimaryScreen();
var scale = screen.getScale();
Expand Down
5 changes: 5 additions & 0 deletions script/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def main():
classpath += [
build_utils.fetch_maven('io.github.humbleui', skija_native, args.skija_version),
]
if args.example == 'dashboard':
# add dashboard resources to the classpath
classpath += [
'examples/dashboard/resources'
]
sources = build_utils.files(f'examples/{args.example}/java/**/*.java')
build_utils.javac(sources, f'examples/{args.example}/target/classes', classpath = classpath, release='16')

Expand Down
Loading