How to center GtkWindows in gtk4?

Positioning top level windows is not the toolkit’s job. In various windowing systems we don’t even have the concept of global/screen coordinates, so any toolkit cannot know how to “center” a window on the screen. At most, a toolkit can position a window relative to another one—i.e. you could position a popup at the center of its parent.

Even on windowing systems that have global coordinates and allow positioning top levels, this is highly discouraged; toolkits don’t have access to the whole stacking order and geometry of all the existing windows, and don’t have the logic to deal with screen-relative constraints. Plus, there are tiling window managers, where the concept of “centering a window on the screen” is pointless by design; and there are tools that control window positioning according to user-provided rules, like Devil’s Pie, which would render any decision an app developer might make pointless.

You should leave window positioning to the windowing system, where it belongs.