-
Notifications
You must be signed in to change notification settings - Fork 10
Window API
The window API is used to create new windows, including child windows. See the API documentation for more information.
- You can obtain the initially opened window via Application.getWindow()
- Windows are created via
fin.desktop.Window, with various options passed - You can obtain the parent via Window.getParentWindow, and access parent context, getParentWindow().getNativeWindow()
- You can obtain all other applications windows via Application.getChildWindows()
- OpenFin does not maintain any sort of window hierarchy, getParentWindow() always returns the window created via app.json, and all others appear in the Application.getChildWindows() array, no matter which window was the 'opener'
- All windows are within the same process
- doesn't have the concept of child windows, instead you use alwaysOnTop (although this doesn't minimize together with the parent)
Using window.open
- Creates a new OpenFin window with a UUID for the name, and autoShow set to true (with new fin.desltop.Window this defaults to false)
- window.opener returns the native parent, i.e. the same as getParentWindow().getNativeWindow()
- window.opener behaves differently from getParentWindow() in that it always references the native window that it was opened from, rather than the window constructed via app.json
- New windows opened via window.open
- Has the same behaviour as above, same process, and able to access same context
- Windows are created via new BrowserWindow, within the main process.
- Windows can be created in the renderer process using the 'remote' interface, although this is just a proxy interface, with the window still being created and managed by the main process
- Each new window is in a different process
- You can obtain all the windows via the static BrowserWindow.getAllWindows() method
- You can set a window as a parent on construction, in order to create a child window. You can navigate this relationship via getParentWindow / getChildWindow
Using window.open
- Creates a window via BrowserWindow, but returns a proxy, BrowserWindowProxy
- window.opener returns a BrowserWindowProxy, with a restrictive API
- The parent / child are different processes, so you can only postMessage
Using window.open with the sandbox turned on via --enable-sandbox
- Works as per the Chrome browser, creating a new window in the same process.
The initial attempt to create windows was by using window.open(). However, this implementation was inconsistent between Electron, OpenFin and the browser:
-
Electron - Created a new window and returned a
BrowserWindowProxyobject which gave limited control over the new window. The new window was completely independent of the original window. - OpenFin - Created a new window that was a child of the parent window (i.e. closed when the parent did).
- Browser - Opened a new tab or window, depending on the user's preferences.
-
Electron - Sends a synchronous
ipccall, which returns the new window object as an independent window. Can be passedchild: truein the options to create the new window as a child of the main window. -
OpenFin - Creates a new application via
fin.desktop.Applicationby default, which runs completely independently from the main window. Ifchild: trueis specified in options, a new window is created viafin.desktop.Windowwhich creates a new window as a child of the current window. - Browser - Still uses window.open (as there is no concept of a child window in the browser). Ignores any child option passed to it.
All of the window implementations support blur, focus and close, as well as Electron and OpenFin supporting show and hide. The browser does not have any way of showing or hiding a window, even one that was created by the current window.
The window object also has static methods getCurrentWindowId() and getCurrentWindow().
Currently the shared options between Electron and OpenFin are implemented using the Electron names. Browser however, overrides most options sent to it using the users options so it only appears that width and height work.
A table of supported options and methods can be found here. It also shows what methods they use from Electron and OpenFin.