Skip to content

Conversation

@J3n5en
Copy link

@J3n5en J3n5en commented Dec 9, 2025

Summary

  • Add alwaysOnTop option to BrowserWindow constructor
  • Add setAlwaysOnTop(boolean) method for runtime toggling
  • Add alwaysOnTop getter to check current state

Changes

  • macOS: Use NSFloatingWindowLevel / NSNormalWindowLevel
  • Linux: Use gtk_window_set_keep_above (GTK) or
    _NET_WM_STATE_ABOVE (X11)
  • Windows: Use SetWindowPos with HWND_TOPMOST /
    HWND_NOTOPMOST

Usage

// Set on creation
const win = new BrowserWindow({
  alwaysOnTop: true,
  // ...
});

// Toggle at runtime
win.setAlwaysOnTop(true);
win.setAlwaysOnTop(false);

// Check state
console.log(win.alwaysOnTop);

Test Plan

  • Run bun run:playground and test Always on Top checkbox in Window
    Demo
  • Run bun test and execute the "Window Always on Top" test case
  • Verify window stays on top when other windows are focused
  • Verify toggling off allows window to go behind others

- Add setWindowAlwaysOnTop native function for macOS, Linux, and Windows
- Add FFI binding for setWindowAlwaysOnTop in native.ts
- Add alwaysOnTop option to WindowOptionsType
- Add setAlwaysOnTop() method and alwaysOnTop getter to BrowserWindow
- Enable Always on Top in interactive-playground demo
- Add window-always-on-top test case
Change alwaysOnTop from public property to private _alwaysOnTop
with a readonly getter. Users should use setAlwaysOnTop() method
to modify the value.
}

setAlwaysOnTop(alwaysOnTop: boolean) {
this._alwaysOnTop = alwaysOnTop;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: only do this if alwaysOnTop != this._alwaysOnTop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants