Skip to content

Commit 08bfb30

Browse files
committed
fix(stage-tamagotchi): restrict to sender matched calls when dispatching events for electron window related api
1 parent 7c28122 commit 08bfb30

File tree

4 files changed

+270
-129
lines changed

4 files changed

+270
-129
lines changed

apps/stage-tamagotchi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@tresjs/cientos": "^5.1.0",
5050
"@tresjs/core": "^5.1.0",
5151
"@types/audioworklet": "^0.0.87",
52-
"@unbird/eventa": "^0.2.0",
52+
"@unbird/eventa": "^0.2.1",
5353
"@vueuse/core": "^13.9.0",
5454
"@vueuse/shared": "^13.9.0",
5555
"@xsai-ext/providers-cloud": "catalog:",

apps/stage-tamagotchi/src/main/services/electron/window.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ export function createWindowService(params: { context: ReturnType<typeof createC
2323
onAppBeforeQuit(() => stop())
2424
defineInvokeHandler(params.context, startLoopGetBounds, () => start())
2525

26-
defineInvokeHandler(params.context, electron.window.getBounds, () => params.window.getBounds())
27-
defineInvokeHandler(params.context, electron.window.setIgnoreMouseEvents, invokeOpts => params.window.setIgnoreMouseEvents(invokeOpts[0], invokeOpts[1]))
26+
defineInvokeHandler(params.context, electron.window.getBounds, (_, options) => {
27+
if (params.window.webContents.id === options?.raw.ipcMainEvent.sender.id) {
28+
return params.window.getBounds()
29+
}
30+
31+
return {
32+
x: 0,
33+
y: 0,
34+
width: 0,
35+
height: 0,
36+
}
37+
})
38+
defineInvokeHandler(params.context, electron.window.setIgnoreMouseEvents, (opts, options) => {
39+
if (params.window.webContents.id === options?.raw.ipcMainEvent.sender.id) {
40+
params.window.setIgnoreMouseEvents(...opts)
41+
}
42+
})
2843
}

apps/stage-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@stdlib/string-base-kebabcase": "^0.2.2",
3939
"@tresjs/cientos": "^5.1.0",
4040
"@tresjs/core": "^5.1.0",
41-
"@unbird/eventa": "^0.1.5",
41+
"@unbird/eventa": "^0.2.1",
4242
"@valibot/to-json-schema": "1.0.0-rc.0",
4343
"@vueuse/core": "^13.9.0",
4444
"@vueuse/shared": "^13.9.0",

0 commit comments

Comments
 (0)