Skip to content

Commit

Permalink
X11: use setClassHint and setIconData in dashboard example
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaima authored and tonsky committed Sep 27, 2024
1 parent 3e5990c commit 8eb2c71
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/dashboard/java/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import java.util.function.*;
import java.util.stream.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class Example implements Consumer<Event> {
public static int PADDING = 10;
Expand Down Expand Up @@ -82,6 +85,17 @@ public Example() {
case MACOS -> {
window.setIcon(new File("examples/dashboard/resources/macos.icns"));
}
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"))));
ImageInfo info = i.getImageInfo();

((WindowX11) window).setIconData(info.getWidth(), info.getHeight(), i.readPixels());
} catch (IOException e) {
e.printStackTrace();
}
}
}

window.setVisible(true);
Expand Down

0 comments on commit 8eb2c71

Please sign in to comment.