Skip to content

Commit

Permalink
Add z-index to window state recovery #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Z Király authored and Lev Z Király committed Nov 22, 2023
1 parent 2195738 commit e26ad5e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stores/use-windows-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type WindowArrangement = keyof typeof arrangements;
const WindowState = z.object({
x: z.number(),
y: z.number(),
z: z.number(),
width: z.number(),
height: z.number(),
kind: z.string(),
Expand Down Expand Up @@ -158,6 +159,7 @@ export const useWindowsStore = defineStore("windows", () => {
params: w.params,
x: String(w.x) + "%",
y: String(w.y) + "%",
zIndex: w.z,
height: String(w.height) + "%",
width: String(w.width) + "%",
});
Expand All @@ -181,6 +183,7 @@ export const useWindowsStore = defineStore("windows", () => {
y?: number | string;
width?: number | string;
height?: number | string;
zIndex?: number;
}) {
const rootElement = document.getElementById(windowRootId);
if (rootElement == null) return;
Expand All @@ -201,10 +204,14 @@ export const useWindowsStore = defineStore("windows", () => {
const winbox = new WinBox({
id,
title,
index: params.zIndex ? params.zIndex : undefined,
x: params.x ? params.x : "center",
y: params.y ? params.y : "center",
width: params.width,
height: params.height,
onfocus() {
updateUrl();
},
onresize() {
updateUrl();
},
Expand Down Expand Up @@ -286,6 +293,7 @@ export const useWindowsStore = defineStore("windows", () => {
windowStates.push({
x: viewportPercentageWith2DigitPrecision(w.winbox.x as number, "width"),
y: viewportPercentageWith2DigitPrecision(w.winbox.y as number, "height"),
z: w.winbox.index,
width: viewportPercentageWith2DigitPrecision(w.winbox.width as number, "width"),
height: viewportPercentageWith2DigitPrecision(w.winbox.height as number, "height"),
kind: w.kind,
Expand Down

0 comments on commit e26ad5e

Please sign in to comment.