Interface NativeWindow
- All Superinterfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceNotified when the window moves to a monitor with a different content scale.static enumWhat a registered child window is, which decides whether a modal over the owner leaves it usable. -
Method Summary
Modifier and TypeMethodDescriptionbackend()default voidcaptureNextFrame(Path pngFile) Captures the next rendered frame to a PNG file, creating the parent directories if they are missing: the--screenshotpath.voidcaptureNextFrame(Consumer<Image> sink) Captures the next rendered frame (post-flush, pre-swap) and hands the pixels tosink: a per-window screenshot without touching the frame callback, and without a file.voidclose()Same asrequestClose(); actual destruction happens in the loop/backend.floatdefault floatcursorX()default floatcursorY()default Displaydisplay()default voidEnters exclusive fullscreen at the monitor's current resolution.voidenterFullscreen(int width, int height, int refreshRate) Enters exclusive (mode-setting) fullscreen on the monitor the window currently occupies.default voidenterFullscreen(Resolution mode) Enters exclusive fullscreen atmodeon the current display, the normalized form ofenterFullscreen(int, int, int)that reuses aResolution(e.g.voidRestores the previous windowed geometry (no-op if not fullscreen).voidfocus()Brings this window to the front and gives it input focus.intintvoidhide()booleanisClosed()booleanbooleanbooleanfloatfloatfloatvoidoverrideContentScale(float scale) Forces the rendering content scale, ignoring the monitor's.default PointerModedefault voidregisterChildPopup(NativeWindow child) Registers a child popup to be closed automatically when this window closes, so a combo/menu popup can never outlive its parent.voidregisterChildPopup(NativeWindow child, NativeWindow.PopupKind kind) Registers a child popup and says what it is; seeNativeWindow.PopupKind, which is the whole reason this overload exists.voidAsks the window to close (processed by the event loop).voidMarks the window dirty so the loop renders a frame for it.default voidCancels any in-progress IME composition held by the platform for this window.intscreenX()intscreenY()default voidsetAboveSystemChrome(boolean above) Raises this window above the OS chrome so it can cover the whole display.default voidsetCloseRequestHandler(BooleanSupplier handler) Consulted when the user asks to close the window (the OS close button, Alt-F4, Cmd-W): returnfalseto veto and keep the window open, e.g.voidRegisters a listener for runtime monitor/content-scale changes.default voidSets the mouse cursor shown while the pointer is over this window.default voidsetCursorPosition(float x, float y) Warps the pointer to (x,y) in logical points relative to this window's content area.voidsetFrameCallback(FrameCallback callback) Registers the per-frame render callback.default voidSets the window icon (title bar / taskbar) from one or more candidate sizes; the platform picks the closest (16–48px covers the common slots).default voidsetImageCursor(ImageCursor cursor) Shows a customImageCursorinstead of the current standardshape;nullclears it and restores the last shape.default voidsetImeEnabled(boolean enabled) Enables or disables the platform input method (IME) for this window.voidsetInput(WindowInput input) Registers the input sink (usually the scene).default voidsetMousePassthrough(boolean passthrough) Makes the window transparent to MOUSE input: clicks, wheel and hover pass through to whatever sits beneath it, for overlay/HUD windows whose empty (usually transparent) regions must not steal the desktop's mouse.default voidsetOpacity(float opacity) Sets the whole-window opacity in[0..1]at the compositor level, the fade primitive behindScene.fadeWindow(float, double, java.lang.Runnable).default voidsetPointerMode(PointerMode mode) Sets how this window treats the pointer: visibility, confinement, relative capture.default voidsetPreeditCaretRect(float x, float y, float width, float height) Positions the IME candidate/composition window at the caret, so it follows the text being edited.voidsetScreenPosition(int x, int y) Moves the window (native screen coordinates; seelogicalToScreenFactor()).voidsetSize(int width, int height) Resizes the window to the given size in logical points.default voidsetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) Constrains user resizing to the given bounds in logical points; pass<= 0for any bound to leave it unconstrained.voidSets the native title bar text.voidshow()default booleantitle()voidunregisterChildPopup(NativeWindow child) Unregisters a child popup that closed on its own.
-
Method Details
-
title
String title()- Returns:
- the current title
-
setTitle
Sets the native title bar text. -
logicalWidth
float logicalWidth()- Returns:
- width in logical points (framebuffer width ÷ content scale)
-
logicalHeight
float logicalHeight()- Returns:
- height in logical points (framebuffer height ÷ content scale)
-
framebufferWidth
int framebufferWidth()- Returns:
- framebuffer width in physical pixels
-
framebufferHeight
int framebufferHeight()- Returns:
- framebuffer height in physical pixels
-
contentScale
float contentScale()- Returns:
- the content scale in effect for this window: the monitor's, or the forced one. Fractional values (1.25, 1.5, 1.75) are first-class citizens, never assume integer
-
overrideContentScale
void overrideContentScale(float scale) Forces the rendering content scale, ignoring the monitor's. Screenshot scenes use it to validate 1.0/1.25/1.5/2.0 rendering on any monitor. Pass0to return to the monitor scale. -
setSize
void setSize(int width, int height) Resizes the window to the given size in logical points. -
setSizeLimits
default void setSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) Constrains user resizing to the given bounds in logical points; pass<= 0for any bound to leave it unconstrained. Only affects interactive resizes;setSize(int, int)is not clamped. The default implementation ignores it (headless/embedding). UI thread only. -
setIcon
Sets the window icon (title bar / taskbar) from one or more candidate sizes; the platform picks the closest (16–48px covers the common slots). No-op where the platform has no per-window icons (macOS uses the app bundle's icon; some Wayland compositors ignore it). The default implementation ignores it (headless/embedding). UI thread only. -
setCloseRequestHandler
Consulted when the user asks to close the window (the OS close button, Alt-F4, Cmd-W): returnfalseto veto and keep the window open, e.g. to show an "unsaved changes" dialog first, closing later viarequestClose(), which (like every programmatic close) bypasses the handler.nullclears. The default implementation ignores it (headless/embedding). UI thread only. -
show
void show() -
hide
void hide() -
setOpacity
default void setOpacity(float opacity) Sets the whole-window opacity in[0..1]at the compositor level, the fade primitive behindScene.fadeWindow(float, double, java.lang.Runnable). Affects the entire window uniformly, decorations included. A no-op where the platform's compositor does not support per-window opacity; the default implementation ignores it (headless/embedding). UI thread only. -
setCursor
Sets the mouse cursor shown while the pointer is over this window. The scene calls this as the hovered widget changes;nullorCursor.DEFAULTrestores the plain arrow. A shape the platform cannot provide falls back to the arrow. The default implementation ignores it (headless/embedding). UI thread only. -
focus
void focus()Brings this window to the front and gives it input focus. UI thread only. -
setImeEnabled
default void setImeEnabled(boolean enabled) Enables or disables the platform input method (IME) for this window. The scene turns it on while a text-editing widget holds focus and off otherwise, so composition keys never leak into non-text UI. A no-op where the platform has no IME control; the default implementation ignores it (headless/embedding). UI thread only. -
setPreeditCaretRect
default void setPreeditCaretRect(float x, float y, float width, float height) Positions the IME candidate/composition window at the caret, so it follows the text being edited.x/y/width/heightare in logical points relative to the window's content area (the scene feeds the focused widget'scaretRect). A no-op where unsupported; the default implementation ignores it (headless/embedding). UI thread only. -
resetPreedit
default void resetPreedit()Cancels any in-progress IME composition held by the platform for this window. The scene calls it when focus leaves a text-editing widget, so a composition started there can never commit into whatever is focused next. A no-op where unsupported or when nothing is being composed; the default implementation ignores it (headless/embedding). UI thread only. -
isVisible
boolean isVisible()- Returns:
- whether the window is currently visible on screen
-
isClosed
boolean isClosed()- Returns:
- whether this window has already been closed/destroyed
-
enterFullscreen
void enterFullscreen(int width, int height, int refreshRate) Enters exclusive (mode-setting) fullscreen on the monitor the window currently occupies. Passwidth/height≤ 0 to keep the monitor's current resolution (no mode switch); passrefreshRate≤ 0 for the monitor default. The previous windowed geometry is remembered forexitFullscreen(). UI thread only.- Parameters:
width- target width in physical pixels, or ≤ 0 for currentheight- target height in physical pixels, or ≤ 0 for currentrefreshRate- target refresh in Hz, or ≤ 0 for the default
-
enterFullscreen
default void enterFullscreen()Enters exclusive fullscreen at the monitor's current resolution. UI thread only. -
enterFullscreen
Enters exclusive fullscreen atmodeon the current display, the normalized form ofenterFullscreen(int, int, int)that reuses aResolution(e.g. one fromdisplay().availableResolutions()). UI thread only. -
exitFullscreen
void exitFullscreen()Restores the previous windowed geometry (no-op if not fullscreen). UI thread only. -
isFullscreen
boolean isFullscreen()- Returns:
- whether the window is currently in exclusive fullscreen
-
isModalBlocked
boolean isModalBlocked()- Returns:
- whether this window is currently locked by an active modal (its input is ignored); the scene dims it while true
-
registerChildPopup
Registers a child popup to be closed automatically when this window closes, so a combo/menu popup can never outlive its parent.Registers it as
NativeWindow.PopupKind.TRANSIENT, which is what a dropdown or a menu is. A window of its own has to say so: seeregisterChildPopup(NativeWindow, PopupKind). -
registerChildPopup
Registers a child popup and says what it is; seeNativeWindow.PopupKind, which is the whole reason this overload exists. -
unregisterChildPopup
Unregisters a child popup that closed on its own. -
setFrameCallback
Registers the per-frame render callback. -
setInput
Registers the input sink (usually the scene). SeeWindowInput. -
backend
Backend backend()- Returns:
- the backend that owns this window (popup creation, shutdown)
-
clipboard
Clipboard clipboard()- Returns:
- the system clipboard
-
screenX
int screenX()- Returns:
- window x in native screen coordinates
-
screenY
int screenY()- Returns:
- window y in native screen coordinates
-
setScreenPosition
void setScreenPosition(int x, int y) Moves the window (native screen coordinates; seelogicalToScreenFactor()). -
supportsAbsolutePositioning
default boolean supportsAbsolutePositioning()WhetherscreenX(),screenY()andsetScreenPosition(int, int)actually work on this platform. Whenfalsethe getters report a placeholder and the setter is ignored: a window is placed by the desktop and never learns where it went.Ask this before drawing anything outside a window that has to line up with something inside it: a dropdown's list, a menu cascade, a tooltip. Those are not windows in their own right; they are the owner's content, escaping the frame because most desktops offer no other way to overflow it. Where the answer is
falsethere is no such way, and the content has to be drawn in the scene instead, clipped to the owner.A window that is genuinely a window (a document, a dialog, a palette) needs no such check. It has no position to agree with, so letting the desktop place it is the right outcome rather than a fallback.
trueby default, because every platform Limn ran on before Wayland could do this and a backend that says nothing is one of those. Wayland is the first that cannot: absolute window position is absent from the protocol by design, not missing from an implementation, so this can never become universallytrueagain. -
setMousePassthrough
default void setMousePassthrough(boolean passthrough) Makes the window transparent to MOUSE input: clicks, wheel and hover pass through to whatever sits beneath it, for overlay/HUD windows whose empty (usually transparent) regions must not steal the desktop's mouse. While enabled this window receives no mouse events at all; pollcursorX()/cursorY()to decide when to turn it back off (e.g. the cursor entered one of the overlay's visible items). Keyboard focus is unaffected. No-op where the platform lacks support. -
cursorX
default float cursorX()- Returns:
- the cursor's current x in logical points relative to this
window's content area; polled, so it works while unfocused or
mouse-passthrough
(which mutes events).
NaNwhen unsupported. UI thread only.
-
cursorY
default float cursorY()- Returns:
- the cursor's current y; see
cursorX()
-
setPointerMode
Sets how this window treats the pointer: visibility, confinement, relative capture. See eachPointerModeconstant;nullmeansPointerMode.NORMAL. InPointerMode.RELATIVEthe window stops receivingWindowInput.mouseMoved(float, float)and receivesWindowInput.mouseDelta(float, float)instead. Interactions that capture from a widget must restoreNORMALwhen they end (release/EXIT/detach); the mode is window state and survives the widget. No-op where unsupported. UI thread only. -
pointerMode
- Returns:
- the current
PointerMode(defaultPointerMode.NORMAL)
-
setImageCursor
Shows a customImageCursorinstead of the current standardshape;nullclears it and restores the last shape. The scene drives this fromWidget.setImageCursor(limn.backend.ImageCursor)hover resolution; call it directly only in windowless/manual setups. UI thread only. -
setCursorPosition
default void setCursorPosition(float x, float y) Warps the pointer to (x,y) in logical points relative to this window's content area. No input event is synthesized; the next real mouse event reflects the new position. Useful withPointerMode.RELATIVEinteractions and edge-wrap schemes; may be restricted by the platform while the window is unfocused. UI thread only. -
setAboveSystemChrome
default void setAboveSystemChrome(boolean above) Raises this window above the OS chrome so it can cover the whole display. On macOS the menu bar and Dock draw at window levels above an ordinary always-on-top window, so a full-screen transparent overlay would otherwise be occluded by them. When enabled the window floats above that chrome (a cube can fly over the menu bar; transparent regions still show it through, and passthrough keeps it clickable); disabling restores the normal always-on-top level. No-op where the platform needs nothing extra to cover its chrome. UI thread only. -
logicalToScreenFactor
float logicalToScreenFactor()- Returns:
- multiplier from logical points to native screen coordinates (1.0 on macOS, the monitor scale on Windows/X11), for positioning popups relative to widget bounds
-
display
- Returns:
- the
Displaythis window currently sits on (the monitor containing the window's centre), ornullwhen headless/embedded. ItsDisplay.workArea()is what external popups clamp against to stay on screen. UI thread only.
-
captureNextFrame
Captures the next rendered frame (post-flush, pre-swap) and hands the pixels tosink: a per-window screenshot without touching the frame callback, and without a file. Requests a frame, so it works on an idle window.sinkruns on the UI thread inside that frame.The image is display-referred: it is what the composite produced, not scene-referred content awaiting a display transform. See
GpuRenderer.captureFramebuffer(java.util.function.Consumer). -
captureNextFrame
Captures the next rendered frame to a PNG file, creating the parent directories if they are missing: the--screenshotpath. -
setContentScaleListener
Registers a listener for runtime monitor/content-scale changes. -
requestFrame
void requestFrame()Marks the window dirty so the loop renders a frame for it. UI thread only: from a background thread, hop withUi.post(window::requestFrame). -
requestClose
void requestClose()Asks the window to close (processed by the event loop). Any-thread safe. -
close
void close()Same asrequestClose(); actual destruction happens in the loop/backend.- Specified by:
closein interfaceAutoCloseable
-