Get the Frame Extents from EWMH WMs that support it.
| 361 | |
| 362 | // Get the Frame Extents from EWMH WMs that support it. |
| 363 | bool getEWMHFrameExtents(::Display* disp, ::Window win, long& xFrameExtent, long& yFrameExtent) |
| 364 | { |
| 365 | static const auto supported = isFeatureSupported("_NET_FRAME_EXTENTS"); |
| 366 | |
| 367 | if (!supported) |
| 368 | return false; |
| 369 | |
| 370 | static const auto frameExtents = sf::priv::getAtom("_NET_FRAME_EXTENTS"); |
| 371 | |
| 372 | if (frameExtents == None) |
| 373 | return false; |
| 374 | |
| 375 | bool gotFrameExtents = false; |
| 376 | Atom actualType = 0; |
| 377 | int actualFormat = 0; |
| 378 | unsigned long numItems = 0; |
| 379 | unsigned long numBytesLeft = 0; |
| 380 | unsigned char* data = nullptr; |
| 381 | |
| 382 | const int result = XGetWindowProperty(disp, |
| 383 | win, |
| 384 | frameExtents, |
| 385 | 0, |
| 386 | 4, |
| 387 | False, |
| 388 | XA_CARDINAL, |
| 389 | &actualType, |
| 390 | &actualFormat, |
| 391 | &numItems, |
| 392 | &numBytesLeft, |
| 393 | &data); |
| 394 | |
| 395 | if ((result == Success) && (actualType == XA_CARDINAL) && (actualFormat == 32) && (numItems == 4) && |
| 396 | (numBytesLeft == 0) && (data != nullptr)) |
| 397 | { |
| 398 | gotFrameExtents = true; |
| 399 | |
| 400 | #pragma GCC diagnostic push |
| 401 | #pragma GCC diagnostic ignored "-Wcast-align" |
| 402 | long* extents = reinterpret_cast<long*>(data); |
| 403 | #pragma GCC diagnostic pop |
| 404 | |
| 405 | xFrameExtent = extents[0]; // Left. |
| 406 | yFrameExtent = extents[2]; // Top. |
| 407 | } |
| 408 | |
| 409 | // Always free data. |
| 410 | if (data != nullptr) |
| 411 | XFree(data); |
| 412 | |
| 413 | return gotFrameExtents; |
| 414 | } |
| 415 | |
| 416 | // Check if the current WM is in the list of good WMs that provide |
| 417 | // a correct absolute position for the window when queried. |
no test coverage detected