Window chrome
What chrome is, the three chrome styles isolen offers, and what the system gives a window in each.
What is chrome
The word comes from hacker slang, long before browsers borrowed it. The Jargon File defines it this way:
chrome: n. [from automotive slang via wargaming] Showy features added to attract users but contributing little or nothing to the power of a system. “The 3D icons in Motif are just chrome, but they certainly are pretty chrome!” Distinguished from bells and whistles by the fact that the latter are usually added to gratify developers' own desires for featurefulness. Often used as a term of contempt.
The jargon sense is about what surrounds the work rather than the work itself, like the chrome trim on a car that frames the body without moving it. Interface design kept that idea and dropped the contempt. Today chrome means the frame an app or the operating system puts around the content: the title bar, the window buttons (the traffic lights on macOS, minimize, maximize and close on Windows), the window border, the rounded corners and the shadow. The content is what you opened the window to see. The chrome is how you move, resize, stack and close it.
Good chrome still follows the old rule in its own way: it earns its place by doing a job, and it stays out of the content's way.
Chrome in isolen
An isolen window has one of three chrome styles, picked when the app opens:
- Native chrome, the default. The system keeps its own frame: the title bar area, the traffic lights on macOS, and on Windows 11 the caption buttons with snap layouts, plus the system corners and shadow. The kit title bar fills the title bar area around the system buttons.
- Drawn chrome. A borderless window where the kit draws the whole title bar, its own three buttons included.
- No chrome. A borderless window with no title bar at all. The view gets the whole window.
In both styles with a bar, the title bar lives completely apart from the app. The shell lays the window out as a column: the title bar strip at the top, then the page view that takes the rest. Your view declares into that page, so page content never lands in the title bar, never scrolls under it, and never zooms with it: a pinch zoom covers the page only. In full screen, and with no chrome, there is no bar and the page is the whole window.
Overlays stay out of the bar too. Menus, popovers, tooltips, dialogs, sheets, drawers and toasts draw in portals above the page, and every portal lives in the overlay area: the view less the title bar. Each frame the shell sets it to the page rect, the same rect pinch zoom covers, so a popover near the top flips or slides down instead of covering the bar, a scrim stops at the bar, and toasts centre in the area.
- Painting. Portals, their shadows and focus rings, and
paint_on_topfunctions are clipped to the overlay area. - The bar stays live under a modal. A press on the bar is never held by a modal, never counts as an outside press, and never moves focus, so an open dialog or menu stays as it is while you drag, minimize or close the window. This matches native apps, where the system takes title bar clicks.
- No bar. With chrome off, and in full screen, the overlay area is the whole view.
What the system gives a window
- Window buttons. The traffic lights on macOS. Minimize, maximize and close on Windows.
- The frame. Rounded corners, a thin border and the drop shadow that separates a window from the ones behind it.
- Behaviour. Snap layouts on the Windows maximize button, full screen in its own Space on macOS, dragging and double clicking the title bar, and a maximized window that leaves the taskbar visible.
Styles
Three fields of isolen_app_desc pick the style:
| Fields | What you get |
|---|---|
chrome on, the default | Native chrome. The system keeps its frame, corners and shadow, and the kit title bar sits in the title bar area around the system buttons. |
chrome and drawn_chrome on | A borderless window with the kit title bar and its own three buttons, the way every window worked before. --drawn-chrome sets it. |
chrome off | A borderless window with no title bar at all. The view gets the whole window. |
| Field | Meaning |
|---|---|
backdrop | An isolen_backdrop: Mica or Acrylic on Windows 11, a vibrancy material on macOS. isolen_backdrop_none by default. A backdrop makes the window transparent. Where the system has no backdrop the request fails and the log says so. It was a bool, see transparent windows. |
fullscreen | A frameless kiosk cover over the whole monitor from the start. Width and height are ignored. |
start_fullscreen | Opens windowed, then goes full screen the way isolen_set_fullscreen does. --start-fullscreen sets it. |
The log names the style at open, for example app chrome native, backdrop 0, transparent 0, shadow 0, start fullscreen 0.
#include "isolenui/app/app.h"
// native chrome is the default, the system keeps its buttons and the view
// runs up under the bar, drawn_chrome asks for the kit buttons everywhere
static isolen_app_desc native_window(void)
{
isolen_app_desc d = isolen_app_defaults();
d.title = "editor";
// mica on windows 11 and a vibrancy material on mac, a backdrop makes
// the window transparent so the frame shows it wherever it draws nothing
d.backdrop = isolen_backdrop_mica;
return d;
}
static isolen_app_desc drawn_window(void)
{
isolen_app_desc d = isolen_app_defaults();
d.drawn_chrome = true;
return d;
}
static isolen_app_desc bare_window(void)
{
isolen_app_desc d = isolen_app_defaults();
// no title bar at all, the view gets the whole window
d.chrome = false;
return d;
}
static isolen_app_desc kiosk(void)
{
isolen_app_desc d = isolen_app_defaults();
// a frameless cover over the monitor, width and height are ignored
d.fullscreen = true;
return d;
}
static isolen_app_desc opens_full_screen(void)
{
isolen_app_desc d = isolen_app_defaults();
// opens windowed, then goes full screen the way isolen_set_fullscreen does
d.start_fullscreen = true;
return d;
}Native chrome on macOS
- The real traffic lights, rounded corners and the system shadow. The system title is hidden and its bar is transparent, so the window surface runs up under it and the kit title bar fills that strip. The page view still starts below the bar.
- The green button enters full screen in its own Space, and Option click on it zooms, as in any mac app.
- A double click on the title bar area follows the system setting in Desktop and Dock: zoom, minimize or nothing.
- Dragging the title bar area moves the window. A Control click there is passed to the view.
- In full screen the menu bar and the empty toolbar that centres the traffic lights hide until the pointer reaches the top.
- The window's own background follows the theme's
bg, set at open and on everyisolen_set_theme, so a resize gap shows the theme colour before the next frame lands instead of the system grey.window_set_background(w, rgba)inisolenui/platform/window.hsets it, rgba with red in the low byte. A transparent window keeps it for when it turns opaque again. On Windows it does nothing.
Native chrome on Windows
- The system keeps the side and bottom frame and the resize edges. The kit paints the three caption buttons, and the system hit tests them, so hovering maximize on Windows 11 brings up snap layouts.
- Rounded corners on Windows 11. The frame follows the system light or dark app setting.
- Dragging the bar moves the window and snaps it, and a double click maximizes or restores, all handled by the system.
- A maximized window stops at the work area, so the taskbar stays visible. When the taskbar hides itself, the window leaves one pixel free at that edge so it can still come up.
- The smallest window is 360 by 240 units.
- On Windows 10 the corners stay square and there is no Mica or snap layouts flyout. The log says
corners square as the os has no preference.
The kit title bar
title_bar in isolenui/kit/chrome.h has a second overload that takes a ui::chrome_frame. The shell fills it every frame, so an app under isolen_run never calls it.
| Field | Meaning |
|---|---|
mode | chrome_drawn, the kit draws its own buttons. chrome_os_buttons, the mac traffic lights sit in the reserved side. chrome_kit_buttons, Windows, where the kit paints the buttons and the system hit tests them. |
left, right, bar_h | The room the system buttons take on each physical side and the bar height the system wants, in logical units. |
maximised, active | Draws the restore glyph, and dims the glyphs of an inactive window. |
hover, down | The chrome_button under the pointer and the one held, from the window. |
ui::chrome now also returns drag_box, min_box, max_box and close_box. Under native chrome the shell hands these to the window with window_set_caption, so the system knows where the title bar and the buttons are. The bar is at least the theme row height plus 10, or the system bar height plus 1, whichever is taller.
Insets and right to left
window_chrome_insets(w, &left, &right, &bar_h) in isolenui/platform/window.h gives the room in physical pixels. On macOS it is measured from the traffic lights. On Windows it is three 46 pixel buttons at 96 DPI on the right and a 32 pixel bar, scaled to the window's DPI. Both are zero in full screen and for a borderless window.
The insets are on physical sides, so a right to left ui leaves the system buttons where the system puts them. The strip that holds them always lays out left to right, while the title and status inside it follow the reading direction.
#include "isolenui/platform/window.h"
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"
// a host that owns its window and calls title_bar itself does what the shell
// does, it reads the insets, lays the bar out around the system buttons and
// hands the boxes back so the os can hit test them
static void native_bar(window* w, ui::ctx* u, float scale, gfx_svg min_icon,
gfx_svg max_icon, gfx_svg close_icon)
{
ui::chrome_frame f = {};
#if defined(_WIN32)
f.mode = ui::chrome_kit_buttons;
#else
f.mode = ui::chrome_os_buttons;
#endif
// physical pixels from the window, logical units for the bar
window_chrome_insets(w, &f.left, &f.right, &f.bar_h);
f.left /= scale;
f.right /= scale;
f.bar_h /= scale;
f.maximised = window_is_maximised(w);
f.active = w->active;
f.hover = ui::chrome_button(w->caption_hover);
f.down = ui::chrome_button(w->caption_down);
const ui::chrome c = ui::title_bar(u, "editor", "", f, min_icon, max_icon, close_icon);
const lay_box* boxes[4] = { &c.drag_box, &c.min_box, &c.max_box, &c.close_box };
window_caption cap = {};
float* outs[4] = { cap.drag, cap.min, cap.max, cap.close };
for (int i = 0; i < 4; ++i) {
outs[i][0] = boxes[i]->x * scale;
outs[i][1] = boxes[i]->y * scale;
outs[i][2] = boxes[i]->w * scale;
outs[i][3] = boxes[i]->h * scale;
}
window_set_caption(w, &cap);
}Full screen, maximize and minimize
| Call | Does |
|---|---|
void isolen_set_fullscreen(isolen_app* a, bool on) | macOS: native full screen in its own Space. Windows: a borderless cover over the whole monitor. |
bool isolen_fullscreen(const isolen_app* a) | Whether the window is full screen now. |
void isolen_set_maximized(isolen_app* a, bool on) | Maximizes to the work area, or restores. Ignored in full screen. |
bool isolen_maximized(const isolen_app* a) | Whether the window is maximized now. Never true in full screen. |
void isolen_minimize(isolen_app* a) | Minimizes to the taskbar or the Dock. |
void isolen_restore(isolen_app* a) | Undoes the one that applies: brings a minimized window back, else leaves full screen, else unmaximizes. |
A call made inside a frame lands on the next frame boundary, and one made outside a frame lands at once. Each frame then reports the state in isolen_frame:
fullscreenandmaximized, as the window is this frame.window_changed, true when either differs from the last frame, whoever changed it: your code, the green button, a double click or the keyboard.
They are different things. Maximize makes the window as large as the work area, keeps the frame and the taskbar, and is a state the user controls. Full screen covers the whole display with no chrome at all. In full screen the shell drops the title bar and hands the whole surface to the view, so a player draws its own controls.
- On Windows, leaving full screen puts back the style and the placement the window had, maximized or not. The window's border is turned off in full screen and back on after.
- On macOS the Space change is animated, and a call made while one is running is ignored with a log line. A request refused while the window is still coming up at launch is tried again, up to four times.
- On macOS a window with drawn chrome has no Space to go to, so
isolen_set_fullscreen(a, true)is refused with a warning. - A kiosk window opened with
fullscreenleaves its cover for a normal window at the width and height first asked for.
#include "isolenui/app/app.h"
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"
// a player that browses in a window and plays full screen, then goes back to
// whatever the window was, maximized or not, when playback ends
struct player {
bool playing;
bool was_maximized;
};
static void player_view(isolen_frame* f, void* user)
{
player* p = static_cast<player*>(user);
ui::ctx* u = f->ui;
// full screen hides the title bar, so the view draws its own controls
ui_box(u, ui::col().width(lay_pct(1.0f)).height(lay_grow(1.0f)).pad(16.0f).gap(12.0f))
{
ui::text(u, p->playing ? "now playing" : "library", ui::head(u));
if (!p->playing && ui::button(u, "play full screen")) {
p->was_maximized = f->maximized;
p->playing = true;
isolen_set_fullscreen(f->app, true);
}
if (p->playing && ui::button(u, "stop")) {
p->playing = false;
isolen_set_fullscreen(f->app, false);
if (p->was_maximized) {
isolen_set_maximized(f->app, true);
}
}
}
// escape or the system can also leave full screen, the frame says so
if (f->window_changed && !f->fullscreen && p->playing) {
p->playing = false;
}
}
int run_player(int argc, char** argv)
{
static player p = {};
isolen_app_desc d = isolen_app_defaults();
d.title = "player";
d.view = player_view;
d.user = &p;
return isolen_run(&d, argc, argv);
}app window now fullscreen 1 maximized 0 at 2560x1600 from the shell, and the platform lines such as window entered native fullscreen and window borderless fullscreen on. --chrome-test steps through maximize, restore, full screen and back on its own, for checking a machine.See the title bar for the drawn bar, and the app shell for the rest of the descriptor.