Skip to content

Commit

Permalink
add onclose event to anura windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Dec 24, 2023
1 parent 81ff787 commit 29d4ba9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AliceWM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class WMWindow {

onfocus: () => void;
onresize: (w: number, h: number) => void;
onclose: () => void;

justresized = false;

Expand Down Expand Up @@ -371,6 +372,8 @@ class WMWindow {
this.element.remove();
// TODO, Remove this and make it an event
anura.removeStaleApps();

if (this.onclose) this.onclose();
}
togglemaximize() {
if (!this.maximized) {
Expand Down
4 changes: 4 additions & 0 deletions src/api/WmApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class WMAPI {
info: object,
onfocus: (() => void) | null = null,
onresize: ((w: number, h: number) => void) | null = null,
onclose: (() => void) | null = null,
): WMWindow {
const win = AliceWM.create(info as unknown as any);

Expand All @@ -21,6 +22,9 @@ class WMAPI {
win.onresize = (width: number, height: number) => {
if (onresize) onresize(width, height);
};
win.onclose = () => {
if (onclose) onclose();
};
ctx.windows.push(win);
this.windows.push(new WeakRef(win));

Expand Down

0 comments on commit 29d4ba9

Please sign in to comment.