Dialog
A dialog window, realized as a JDialog: it shows content, holds its geometry in state, blocks input to the top-level windows in its modality's scope of blocking, and reports the user's attempt to close it to onCloseRequest.
The close gesture is controlled: it invokes onCloseRequest and closes nothing, so the dialog stays on screen - and a modal one goes on blocking - until the caller answers, by declaring visible false or by stopping declaring the dialog at all.
The declarative control surface mirrors Window (visible + onCloseRequest, no imperative handle), adding owner resolution and AWT modality. The dialog is owned by owner, which defaults to the nearest enclosing Window read from LocalWindow. The owner is one of the windows a modal dialog blocks, and the one a WindowPosition.CenteredOnOwner position centers the dialog on. A dialog with no owner under a bare application { } scope, which creates no window, is ownerless: an ownerless document-modal dialog is its own document root, so its scope of blocking is empty and it behaves as a modeless one, while application- and toolkit-modal blocking does not depend on an owner. Centering on the owner then resolves against the screen.
The dialog content runs as part of the enclosing (application or window) composition: state from that scope and any androidx.compose.runtime.CompositionLocal provided above the dialog flow into content. Descendants of the dialog read it as their LocalWindow. A shown dialog keeps recomposing while it is visible.
content receives the dialog as its WindowScope: what the dialog carries besides its content - its MenuBar - is declared on that scope.
The title, modality, visible, resizable, alwaysOnTop, iconImage and minimumSize arguments are reactive: changing any of them in a recomposition updates the realized dialog accordingly. A modality change may have no effect on a dialog that is already showing until it is hidden and shown again. Geometry is driven by state, which is two-way: assigning to DialogState.position/DialogState.size repositions or resizes the dialog, and a user dragging or resizing the dialog writes the new geometry back into state.
undecorated and the owning window are reactive too, at a higher price: a dialog takes its owner at construction and AWT only accepts decorations on a dialog that is not yet realized, so declaring another owner or another decoration releases the dialog peer and builds a replacement. The content is re-hosted in the new peer - its composition, and any state remembered in it, starts over - while the geometry held in state and the declared visibility are re-applied to the replacement. A look and feel that draws the dialog decorations itself (see JDialog.setDefaultLookAndFeelDecorated) draws them on the replacement too, whatever undecorated declares.
Parameters
callback to be called when the user attempts to close the dialog
the hoistable, observable geometry (position and size) of the dialog; by default one this dialog keeps to itself, which leaves the placement to the platform and sizes the dialog to its content
the window that owns the dialog, or null to take the nearest enclosing Window from LocalWindow
the title of the dialog, empty by default, matching a freshly constructed JDialog
the AWT modality of the dialog, defaulting to Dialog.ModalityType.MODELESS (the JDialog default), which blocks nothing; each other type names its own scope of blocking, which never covers the dialog's own child hierarchy, and a modality type the toolkit does not support leaves the dialog modeless
whether the dialog should be visible; true by default, so declaring a dialog shows it, and false hides the dialog while keeping its content composed
whether the dialog can be resized; true by default, matching a freshly constructed JDialog
whether the dialog stays above other windows; ignored on platforms that do not support an always-on-top window, and false by default, so the dialog takes its turn in the platform's stacking order
the image shown as the dialog's icon, or null for the platform default; the windowing system may show it in several places at sizes of its own, or show none at all
the smallest size the dialog can take, or null to leave the floor to the dialog's layout; a declared size below the floor is raised to it, while holding the user's own resizing to the floor is platform-dependent
whether the dialog is shown without its platform decorations (title bar and border); false by default, so the dialog is shown with them
the composable content of the dialog, receiving the dialog as its WindowScope