mirror of
https://github.com/electron/electron.git
synced 2026-10-28 19:54:46 +08:00
* feat: add app shims on macOS An app shim is a small app, in a bundle of its own, that shows windows on behalf of a host Electron app. The host still creates each window, loads its page and handles its events, but the NSWindow belongs to the shim's process, so the Dock, the app switcher, Mission Control and Stage Manager attribute the window to the shim and not to the host. - `app.startAppShimServer()` / `app.stopAppShimServer()` and the `app-shim-connected` event, which hands over an `AppShimHost`. - A `BaseWindow` / `BrowserWindow` created with the `appShim` option has its native window made in that shim's process, through Chromium's remote_cocoa. Such a window is a new NativeWindow implementation that only goes through views::Widget; what remote_cocoa has no call for is a no-op (see docs/api/app-shim-host.md). - The shim's executable is `Helpers/app_shim_loader` from the framework bundle. It links nothing from Electron: it loads the host's framework and calls the new `ElectronAppShimMain` export, which runs an `app-shim` process that connects back to the host over a Mach bootstrap server. - Electron Framework gains an rpath to the folder it is in, so that it finds its sibling frameworks when an executable in another bundle loads it. Not available in Mac App Store builds. Co-Authored-By: Claude <noreply@anthropic.com> * feat: app shim menus, dialogs, window chrome and review fixes Follow-up to the first app shim commit. Fixes from review: - A window torn down from one of its own listeners (shim.quit() or win.destroy() in `show`) no longer frees the native host that is notifying. - The native close button no longer leaves the shim waiting on an answer that was dropped with the window. - Keys the page does not handle go back to the shim, whose menu they are shortcuts of, and not to the host's menu. - stopAppShimServer() drops shims that have connected and not said hello. - Quitting a shim asks the host without blocking and without cancelling a logout; quit-requested can now be answered with "no". - Size limits and useContentSize are in content sizes; restore() and unmaximize() each do one thing; webContents.isFocused() works. New: - shim.setMenu(): a menu bar of the shim's own, built in the shim from a description of the Menu, with clicks sent back. - Message boxes and open and save dialogs are sheets of the window in the shim's process. - titleBarStyle, traffic light position and visibility, vibrancy, tabs and Quick Look, applied in the shim to the NSWindow that remote_cocoa made. - A Chromium patch for what remote_cocoa has no call for: movable, closable, minimizable and fullscreenable, clearing an aspect ratio, and yielding activation to the hosting process by pid. - A shim that loaded another build of Electron than the running host tells the host and quits: app-shim-version-mismatch. The API is marked experimental in the docs. Co-Authored-By: Claude <noreply@anthropic.com> * fix: address review of app shims - A window in an app shim can't be given a parent, at construction or with setParentWindow(), as the docs say. - shim.setMenu() is now shim.setApplicationMenu(). - A message box that is showing under an id makes way for a new one with that id, whichever process shows it. - Mac App Store builds no longer export the shim's entry point; they already had no loader. - setProgressBar() and setHasShadow() are listed among what does nothing on a window in a shim. - The spec no longer asserts inside an event listener. Co-Authored-By: Claude <noreply@anthropic.com> * fix: clang-tidy findings in app shim code * docs: reword the app shim docs for clarity * chore: update patches Re-exported after rebasing onto Chromium 158.0.8105.0; only line offsets changed. Co-Authored-By: Claude <noreply@anthropic.com> * test: use vitest matchers in the app shim spec --------- Co-authored-by: Claude <noreply@anthropic.com>