@next2d/builder 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/electron/index.js +24 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/builder",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Multi-platform builder for Next2d Framework, supporting export to various platforms such as macOS, Windows, iOS, Android and Web(HTML)",
|
|
5
5
|
"author": "Toshiyuki Ienaga <ienaga@next2d.app>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,6 +51,21 @@ const overlayBounds = () => {
|
|
|
51
51
|
const placeOverlay = () => {
|
|
52
52
|
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.setBounds(overlayBounds());
|
|
53
53
|
};
|
|
54
|
+
// The overlay never takes focus, so Windows does not raise it when another topmost window (the taskbar, another
|
|
55
|
+
// always-on-top app) is activated, nor after the display is turned off and on. Put it back on top.
|
|
56
|
+
const keepOnTop = () => {
|
|
57
|
+
if (!mainWindow || mainWindow.isDestroyed()) return;
|
|
58
|
+
mainWindow.setAlwaysOnTop(true, "floating");
|
|
59
|
+
mainWindow.moveTop();
|
|
60
|
+
};
|
|
61
|
+
// Windows forwards mouse moves to a click-through window with a system mouse hook, and Electron installs it only
|
|
62
|
+
// when forwarding switches on. After sleep (closing the lid) the hook can be gone while Electron still thinks it is
|
|
63
|
+
// installed, so the page never sees the pointer. Switching forwarding off and on again installs a fresh hook.
|
|
64
|
+
const refreshForwarding = () => {
|
|
65
|
+
if (!overlayIgnore || !mainWindow || mainWindow.isDestroyed()) return;
|
|
66
|
+
mainWindow.setIgnoreMouseEvents(false);
|
|
67
|
+
mainWindow.setIgnoreMouseEvents(true, { forward: true });
|
|
68
|
+
};
|
|
54
69
|
const createWindow = async () => {
|
|
55
70
|
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
|
56
71
|
// The preload reads these flags; each API is exposed only when its feature is configured.
|
|
@@ -89,10 +104,16 @@ const createWindow = async () => {
|
|
|
89
104
|
mainWindow.setIgnoreMouseEvents(true, { forward: true });
|
|
90
105
|
}
|
|
91
106
|
const events = ["display-metrics-changed", "display-added", "display-removed"];
|
|
92
|
-
|
|
107
|
+
const onDisplayChange = () => { placeOverlay(); keepOnTop(); };
|
|
108
|
+
for (const name of events) screen.on(name, onDisplayChange);
|
|
93
109
|
mainWindow.once("closed", () => {
|
|
94
|
-
for (const name of events) screen.removeListener(name,
|
|
110
|
+
for (const name of events) screen.removeListener(name, onDisplayChange);
|
|
95
111
|
});
|
|
112
|
+
if (process.platform === "win32") {
|
|
113
|
+
const timer = setInterval(() => { keepOnTop(); refreshForwarding(); }, 3000);
|
|
114
|
+
timer.unref?.();
|
|
115
|
+
mainWindow.once("closed", () => clearInterval(timer));
|
|
116
|
+
}
|
|
96
117
|
}
|
|
97
118
|
mainWindow.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
|
|
98
119
|
mainWindow.webContents.on("will-navigate", (event, url) => {
|
|
@@ -180,7 +201,7 @@ app.whenReady().then(async () => {
|
|
|
180
201
|
// z-order/bounds. Apply the overlay state again and tell the page so it can recover too.
|
|
181
202
|
const recoverOverlay = () => {
|
|
182
203
|
if (!mainWindow || mainWindow.isDestroyed()) return;
|
|
183
|
-
|
|
204
|
+
keepOnTop();
|
|
184
205
|
placeOverlay();
|
|
185
206
|
mainWindow.setIgnoreMouseEvents(false);
|
|
186
207
|
mainWindow.setIgnoreMouseEvents(overlayIgnore, overlayIgnore ? { forward: true } : undefined);
|