Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/electron-chrome-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ See [Electron's Notification tutorial](https://www.electronjs.org/docs/tutorial/
- [x] chrome.windows.onCreated
- [x] chrome.windows.onRemoved
- [x] chrome.windows.onFocusChanged
- [ ] chrome.windows.onBoundsChanged
- [x] chrome.windows.onBoundsChanged
</details>

## Limitations
Expand Down
11 changes: 11 additions & 0 deletions packages/electron-chrome-extensions/src/browser/api/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export class WindowsAPI {
this.onFocusChanged(windowId)
})

window.on('resized', () => {
this.onBoundsChanged(windowId)
})

window.once('closed', () => {
this.ctx.store.windowDetailsCache.delete(windowId)
this.ctx.store.removeWindow(window)
Expand Down Expand Up @@ -164,4 +168,11 @@ export class WindowsAPI {
this.ctx.store.lastFocusedWindowId = windowId
this.ctx.router.broadcastEvent('windows.onFocusChanged', windowId)
}

onBoundsChanged(windowId: number) {
const window = this.ctx.store.getWindowById(windowId)
if (!window) return
const windowDetails = this.createWindowDetails(window)
this.ctx.router.broadcastEvent('windows.onBoundsChanged', windowDetails)
}
}
1 change: 1 addition & 0 deletions packages/electron-chrome-extensions/src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ export const injectExtensionAPIs = () => {
onCreated: new ExtensionEvent('windows.onCreated'),
onRemoved: new ExtensionEvent('windows.onRemoved'),
onFocusChanged: new ExtensionEvent('windows.onFocusChanged'),
onBoundsChanged: new ExtensionEvent('windows.onBoundsChanged'),
}
},
},
Expand Down