Skip to content

fix: set_primary_window no longer breaks other windows#2641

Merged
hoffstadt merged 1 commit intohoffstadt:masterfrom
v-ein:bugfix/1978-primary-window-flags
May 4, 2026
Merged

fix: set_primary_window no longer breaks other windows#2641
hoffstadt merged 1 commit intohoffstadt:masterfrom
v-ein:bugfix/1978-primary-window-flags

Conversation

@v-ein
Copy link
Copy Markdown
Collaborator

@v-ein v-ein commented Apr 27, 2026


name: Pull Request
about: Create a pull request to help us improve
title: fix: set_primary_window no longer breaks other windows
assignees: ''


Description:

With this PR, set_primary_window no longer modifies windows other than the window passed in and the previous primary window (if it was set). This fixes #1691, effectively changing window position only when the window switches between primary and regular state. No other windows, in particular, popups and modals, are affected (keep in mind that a modal that has a non-empty label still won't center properly - see #2323 which is not fixed yet).

The only change set_primary_window still does to every window is re-focusing them - this is necessary to place the primary window to the bottom of Z-order. There are no public functions in ImGui API to control Z order, so re-focusing is the only way to place them atop of the primary window (so that they are not hidden behind). As a result, all windows after this call are always reordered according to their creation order. This matches behavior that existed before this PR.

Another change in this PR is that set_primary_window keeps window flags that are not related to positioning it as a primary window, for example, horizontal_scrollbar. This fixes #1978.

Also, the 2nd argument of set_primary_window is now optional, which allows for a more intuitive call like set_primary_window(wnd) rather than set_primary_window(wnd, True) (you know, I always hated to type that True 😂).

Concerning Areas:
If ImGui ever provides API to conrol windows' Z-order, we'll need to make use of it in place of refocusing every window.

@v-ein v-ein requested a review from hoffstadt April 27, 2026 19:14
@hoffstadt hoffstadt merged commit e253945 into hoffstadt:master May 4, 2026
5 checks passed
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.

Can set_primary_window use horizontal_scrollbar feature normally? The popup appears in the wrong place on first use

2 participants