2

I am wondering about the window visibility priority system that allows some windows to stay overtop of some other windows. For example:

  • when we use 'Picture in picture' mode in Chrome, we can force a video feed to be overlaid on top of most other program windows.

  • when we use a script, like this AutoHotKey script: ^SPACE:: Winset, Alwaysontop, , A we can force most program windows to stay overlaid on top of most other program windows.

  • When a program is set to full screen mode (like a game or media player) it's window visibility will take priority over most programs.

I am interested in understanding the system that assigns the hierarchies of the program window visibility, and how Windows manages these hierarchies.

For example, why is the 'Picture in picture' mode in Chrome allowed to overlay everything except a full screen game? I thought perhaps all full screen programs took priority, however when SMPlayer is in full screen mode, the 'Picture in picture' mode in Chrome still takes priority.

So my question is this; what system is used to prioritize window visibility, and how are the hierarchies assigned to each program and their different modes?

1 Answer 1

1

What system is used to prioritize window visibility

Windows have a Z-Order, which is set when they are created:

The z-order of a window indicates the window's position in a stack of overlapping windows. This window stack is oriented along an imaginary axis, the z-axis, extending outward from the screen. The window at the top of the z-order overlaps all other windows. The window at the bottom of the z-order is overlapped by all other windows.

The system maintains the z-order in a single list. It adds windows to the z-order based on whether they are topmost windows, top-level windows, or child windows. A topmost window overlaps all other non-topmost windows, regardless of whether it is the active or foreground window. A topmost window has the WS_EX_TOPMOST style. All topmost windows appear in the z-order before any non-topmost windows. A child window is grouped with its parent in z-order.

When an application creates a window, the system puts it at the top of the z-order for windows of the same type. You can use the BringWindowToTop function to bring a window to the top of the z-order for windows of the same type. You can rearrange the z-order by using the SetWindowPos and DeferWindowPos functions.

The user changes the z-order by activating a different window. The system positions the active window at the top of the z-order for windows of the same type. When a window comes to the top of z-order, so do its child windows. You can use the GetTopWindow function to search all child windows of a parent window and return a handle to the child window that is highest in z-order. The GetNextWindow function retrieves a handle to the next or previous window in z-order.

Source: Window Features - Win32 apps | Microsoft Learn

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .