Skip to main content

Module titlebar

Module titlebar 

Source
Expand description

titlebar — the strip a window with no system titlebar moves itself by.

The strip does not move the window. A grip in it does, and everything else in the bar is an ordinary element.

That split is forced by how the platform asks. Windows answers WM_NCHITTEST out of a flat list of control areas and takes the first one the pointer falls in, parent before child — so a bar that is itself one drag area turns every control in it into a window handle, unless each control blocks the mouse, and blocking the mouse also takes the scroll wheel from everything behind it. Naming the drag surface instead is what AppKit does with a drag gesture on a view, and it costs no control anything.

Three platforms, three mechanisms, all of them on the grip: AppKit drags by itself, Linux is told to with start_window_move on the first motion after a press rather than on the press, and Windows implements neither and reads WindowControlArea::Drag back out of the hit test.

The macOS traffic lights need Theme::TRAFFIC_LIGHT_INSET of leading room, which is nothing until the window goes full screen and AppKit takes them away. Off macOS the buttons are the app’s to paint: controls is the cluster, and the frame around it — border, corners, shadow, resize edges — is crate::window::frame.

The window it belongs to opens with appears_transparent: true, and on Linux asks for WindowDecorations::Client. On macOS AppKit still drags the window by its transparent titlebar, and a grip there is redundant.

ⓘ
titlebar::titlebar("titlebar", true, window)
    .px(px(8.0))
    .child(/* … */)
    .child(titlebar::grip("titlebar-grip", &self.drag, window))
    .child(titlebar::controls(CaptionSide::Right, window, cx))

Structs§

DragState
Whether the press on a grip is still a candidate for a window move.

Enums§

CaptionSide
Which end of the bar a caption cluster sits at.
CaptionStyle
Appearance of app-drawn caption buttons; native window actions stay the same.

Constants§

LIGHTS_WIDTH
Full left strip for three lights, including the space around their discs. Targets keep the platform caption width and reach the left edge without padding.

Functions§

controls
The caption buttons, for a window whose system caption is gone — appears_transparent on Windows, Decorations::Client on Linux.
grip
The bare stretch of a titlebar that drags its window, zooms it on a double click and opens the desktop’s window menu on a right press.
lights_width
Width occupied by left-side lights for this window, accounting for permissions and fullscreen. Reserve it only when positioning controls as an overlay; controls already occupies this space in normal layout.
titlebar
The strip: full width, Theme::TITLEBAR_HEIGHT tall, and inert. What it holds is the caller’s, including grip, without which the window has no handle off macOS.