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

Function ewmhSupported

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

Check if Extended Window Manager Hints are supported

Source from the content-addressed store, hash-verified

215
216// Check if Extended Window Manager Hints are supported
217bool ewmhSupported()
218{
219 static bool checked = false;
220 static bool ewmhSupported = false;
221
222 if (checked)
223 return ewmhSupported;
224
225 checked = true;
226
227 const auto netSupportingWmCheck = sf::priv::getAtom("_NET_SUPPORTING_WM_CHECK");
228
229 if (!netSupportingWmCheck)
230 return false;
231
232 const auto display = sf::priv::openDisplay();
233 Atom actualType = 0;
234 int actualFormat = 0;
235 unsigned long numItems = 0;
236 unsigned long numBytes = 0;
237 unsigned char* data = nullptr;
238 sf::priv::X11Ptr<unsigned char> dataPtr;
239
240 int result = XGetWindowProperty(display.get(),
241 DefaultRootWindow(display.get()),
242 netSupportingWmCheck,
243 0,
244 1,
245 False,
246 XA_WINDOW,
247 &actualType,
248 &actualFormat,
249 &numItems,
250 &numBytes,
251 &data);
252
253 if (result == Success)
254 dataPtr.reset(data);
255
256 if (result != Success || actualType != XA_WINDOW || numItems != 1)
257 return false;
258
259#pragma GCC diagnostic push
260#pragma GCC diagnostic ignored "-Wcast-align"
261 const auto rootWindow = *reinterpret_cast<const ::Window*>(data);
262#pragma GCC diagnostic pop
263
264 if (!rootWindow)
265 return false;
266
267 result = XGetWindowProperty(display.get(),
268 rootWindow,
269 netSupportingWmCheck,
270 0,
271 1,
272 False,
273 XA_WINDOW,
274 &actualType,

Callers 2

isWMAbsolutePositionGoodFunction · 0.85
WindowImplX11Method · 0.85

Calls 5

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

Tested by

no test coverage detected