also looking at this
feat: add Linux and Windows named-window routing
#325
29 files
+2250
-200
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -28,7 +28,10 @@ WebKitGTK/WebView2 view; names select a target only after that sender is known. | ||
| 28 | 28 | Replies go back to the requesting view, and lifecycle events go to the changed |
| 29 | 29 | window plus its named handle's creator. Linux must register its `GtkApplication` |
| 30 | 30 | before constructing the first `GtkApplicationWindow`, because the CLI creates |
| 31 | that window before entering `g_application_run()`. | |
| 31 | that window before entering `g_application_run()`. On Windows, the controller | |
| 32 | passed to the asynchronous WebView2 completion callback is borrowed. Each live | |
| 33 | window retains its own controller reference until native destruction; otherwise | |
| 34 | WebView2 can close before the page bridge registers or navigation begins. | |
| 32 | 35 | |
| 33 | 36 | ## Per-window state |
| 34 | 37 | |
| @@ -567,6 +567,10 @@ const ControllerCompletedHandler = extern struct { | ||
| 567 | 567 | return perm_hr; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | // The callback only lends us the controller. Keep our own reference | |
| 571 | // past Invoke so WebView2 does not close before Window.create uses it. | |
| 572 | _ = controller.lpVtbl.AddRef(controller); | |
| 573 | ||
| 570 | 574 | // Store results |
| 571 | 575 | self.ctx.controller = controller; |
| 572 | 576 | self.ctx.webview = webview; |
| @@ -58,6 +58,9 @@ const mainPage = `<!doctype html><script> | ||
| 58 | 58 | await window.craft.window._call('close', {}, 'settings') |
| 59 | 59 | await closed |
| 60 | 60 | await report('closed') |
| 61 | const survivingMain = await window.craft.window._call('getBounds', {}, 'main') | |
| 62 | if (!(survivingMain.width > 0 && survivingMain.height > 0)) | |
| 63 | throw new Error('closing child invalidated main controller') | |
| 61 | 64 | let staleRejected = false |
| 62 | 65 | try { await window.craft.window._call('getBounds', {}, 'settings') } |
| 63 | 66 | catch (_) { staleRejected = true } |