Skip to content

feat(window): Window.titlebar gives the bar's strip to the image - #2377

Open
isabellaherman wants to merge 1 commit into
bendlang:mainfrom
isabellaherman:window-titlebar
Open

isabellaherman wants to merge 1 commit into
bendlang:mainfrom
isabellaherman:window-titlebar

Conversation

@isabellaherman

Copy link
Copy Markdown
Contributor

A window made by Window.open always has the system's title bar above its
image. A program that draws its own top strip (a sidebar that runs to the
top edge, tabs where the bar was) has no way to take it.

This adds one effect, in the style of Window.grab and Window.scale:

def Window.titlebar(window: Window, on: Bool) -> IO(Window)

Off, the bar draws nothing but its close, minimize and zoom buttons, and
the image takes the whole window, under them. On, as Window.open makes
it. Nothing changes for a program that never calls it.

  • macOS: the window takes NSWindowStyleMaskFullSizeContentView, a
    transparent bar and a hidden title. The frame then shrinks to the image's
    points from its top left corner, so the image keeps its size and its place
    on screen and the window gets shorter by the bar (32 points on macOS 26).
  • The strip the bar took still drags the window, and its presses still
    reach the program. After a drag from the strip the program also gets the
    Press pair, and the release's position is not reliable (seen once at the
    press's point, once offset by the drag).
  • Fullscreen: a fullscreen window has no bar to change, so the call only
    updates the style it will leave with (full_style); fullDone then sizes
    the frame to the image again, from the same top left corner.
  • X11 leaves the bar to the window manager, so the call does nothing there.
    The JS lane returns the window (it opens none).

Tested: tests/gfx/window_titlebar.bend (two foreign probes read the
frame's height over the content view's, and the frame's top edge) prints
True/True natively on macOS 26, interpreted, and under bun on the path where
Window.open answers ENOTSUP. A manual probe on a 480x320 window went
off -> fullscreen -> back, fullscreen -> off inside -> back, and
fullscreen -> on inside -> back: the bar read 0 or 32 as asked, the content
320 points and the top edge the same each time. With a real pointer, drags
from y=11 and y=24 moved the window, a drag from y=45 did not, and all
three printed their presses. The close button closes.

Not tested: X11, the mini cluster gate, ASan, gates/repo.ts (no ttok
here; the new files match the allow list and no touched file has a cap),
the minimize and zoom buttons, more than one display.

The other window tests do not name the effect, so its code is compiled out
of them.

A window made by `Window.open` always has the system's title bar above its
image. A program that draws its own top strip (a sidebar that runs to the
top edge, tabs where the bar was) has no way to take it.

This adds one effect, in the style of `Window.grab` and `Window.scale`:

    def Window.titlebar(window: Window, on: Bool) -> IO(Window)

Off, the bar draws nothing but its close, minimize and zoom buttons, and
the image takes the whole window, under them. On, as `Window.open` makes
it. Nothing changes for a program that never calls it.

- macOS: the window takes NSWindowStyleMaskFullSizeContentView, a
  transparent bar and a hidden title. The frame then shrinks to the image's
  points from its top left corner, so the image keeps its size and its place
  on screen and the window gets shorter by the bar (32 points on macOS 26).
- The strip the bar took still drags the window, and its presses still
  reach the program. After a drag from the strip the program also gets the
  Press pair, and the release's position is not reliable (seen once at the
  press's point, once offset by the drag).
- Fullscreen: a fullscreen window has no bar to change, so the call only
  updates the style it will leave with (`full_style`); `fullDone` then sizes
  the frame to the image again, from the same top left corner.
- X11 leaves the bar to the window manager, so the call does nothing there.
  The JS lane returns the window (it opens none).

Tested: `tests/gfx/window_titlebar.bend` (two foreign probes read the
frame's height over the content view's, and the frame's top edge) prints
True/True natively on macOS 26, interpreted, and under bun on the path where
`Window.open` answers ENOTSUP. A manual probe on a 480x320 window went
off -> fullscreen -> back, fullscreen -> off inside -> back, and
fullscreen -> on inside -> back: the bar read 0 or 32 as asked, the content
320 points and the top edge the same each time. With a real pointer, drags
from y=11 and y=24 moved the window, a drag from y=45 did not, and all
three printed their presses. The close button closes.

Not tested: X11, the mini cluster gate, ASan, `gates/repo.ts` (no ttok
here; the new files match the allow list and no touched file has a cap),
the minimize and zoom buttons, more than one display.

The other window tests do not name the effect, so its code is compiled out
of them.
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.

1 participant