MCPcopy Create free account
hub / github.com/SFML/SFML / setWindowGroupIds

Method setWindowGroupIds

src/SFML/Window/Unix/WindowImplX11.cpp:2306–2352  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

2304
2305////////////////////////////////////////////////////////////
2306void WindowImplX11::setWindowGroupIds()
2307{
2308 using namespace WindowImplX11Impl;
2309
2310 // Nothing to do if there are no windows left
2311 if (allWindows.empty())
2312 return;
2313
2314 const auto display = sf::priv::openDisplay();
2315
2316 // Set window group IDs for all windows
2317 // Setting the window group ID lets the window manager
2318 // know that all our windows belong to the same group
2319 // The window manager can use this information to treat
2320 // multiple windows as a group instead of individual windows
2321 // What effect this has in practice depends on how each window
2322 // manager is implemented and whether it cares about groups
2323 // We use the the first window in our list as the group leader
2324 const auto groupLeader = allWindows.front()->m_window;
2325
2326 // Prepare the atom necessary to set the WM_CLIENT_LEADER property
2327 static const auto wmClientLeaderAtom = getAtom("WM_CLIENT_LEADER");
2328
2329 for (const auto* window : allWindows)
2330 {
2331 // Update the WM_HINTS group ID
2332 auto hints = X11Ptr<XWMHints>(XGetWMHints(display.get(), window->m_window));
2333 if (hints == nullptr)
2334 hints.reset(XAllocWMHints());
2335 hints->flags |= WindowGroupHint;
2336 hints->window_group = groupLeader;
2337 XSetWMHints(display.get(), window->m_window, hints.get());
2338
2339 // Set the WM_CLIENT_LEADER property
2340 if (wmClientLeaderAtom)
2341 {
2342 XChangeProperty(display.get(),
2343 window->m_window,
2344 wmClientLeaderAtom,
2345 XA_WINDOW,
2346 32,
2347 PropModeReplace,
2348 reinterpret_cast<const unsigned char*>(&groupLeader),
2349 1);
2350 }
2351 }
2352}
2353
2354} // namespace sf::priv

Callers

nothing calls this directly

Calls 4

openDisplayFunction · 0.85
getAtomFunction · 0.85
getMethod · 0.80
resetMethod · 0.80

Tested by

no test coverage detected