fix window order on duplication

This commit is contained in:
HF 2021-07-25 00:07:28 +02:00
parent b35ca151d7
commit cc9d36e056

View File

@ -336,12 +336,14 @@ export default function windows(
} = action; } = action;
const win = state.windows.find((w) => w.windowId === windowId); const win = state.windows.find((w) => w.windowId === windowId);
const newWindowId = generateWindowId(state); const newWindowId = generateWindowId(state);
const newZMax = state.zMax + 1;
const { const {
innerWidth: width, innerWidth: width,
innerHeight: height, innerHeight: height,
} = window; } = window;
return { return sortWindows({
...state, ...state,
zMax: newZMax,
windows: [ windows: [
...state.windows, ...state.windows,
{ {
@ -349,6 +351,7 @@ export default function windows(
windowId: newWindowId, windowId: newWindowId,
xPos: Math.min(win.xPos + 15, width - SCREEN_MARGIN_EW), xPos: Math.min(win.xPos + 15, width - SCREEN_MARGIN_EW),
yPos: Math.min(win.yPos + 15, height - SCREEN_MARGIN_S), yPos: Math.min(win.yPos + 15, height - SCREEN_MARGIN_S),
z: newZMax,
}, },
], ],
args: { args: {
@ -357,7 +360,7 @@ export default function windows(
...state.args[windowId], ...state.args[windowId],
}, },
}, },
}; });
} }
case 'CHANGE_WINDOW_TYPE': { case 'CHANGE_WINDOW_TYPE': {