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
app_owns_titlebar_drag: true — the second one stops AppKit from
dragging the window and from delaying titlebar clicks while it waits to
see a double-click.
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§
Enums§
- Caption
Side - Which end of the bar a caption cluster sits at.
Functions§
- controls
- The caption buttons, for a window whose system caption is gone —
appears_transparenton Windows,Decorations::Clienton 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.
- titlebar
- The strip: full width,
Theme::TITLEBAR_HEIGHTtall, and inert. What it holds is the caller’s, includinggrip, without which the window has no handle off macOS.