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

Method switchToFullscreen

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

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

Source from the content-addressed store, hash-verified

1540
1541////////////////////////////////////////////////////////////
1542void WindowImplX11::switchToFullscreen()
1543{
1544 using namespace WindowImplX11Impl;
1545
1546 grabFocus();
1547
1548 if (isFeatureSupported("_NET_WM_STATE") && isFeatureSupported("_NET_WM_STATE_FULLSCREEN"))
1549 {
1550 static const auto netWmState = getAtom("_NET_WM_STATE");
1551 static const auto netWmStateFullscreen = getAtom("_NET_WM_STATE_FULLSCREEN");
1552
1553 if (!netWmState || !netWmStateFullscreen)
1554 {
1555 err() << "Setting fullscreen failed. Could not get required atoms" << std::endl;
1556 return;
1557 }
1558
1559 auto event = XEvent();
1560 event.type = ClientMessage;
1561 event.xclient.window = m_window;
1562 event.xclient.format = 32;
1563 event.xclient.message_type = netWmState;
1564 event.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
1565 event.xclient.data.l[1] = static_cast<long>(netWmStateFullscreen);
1566 event.xclient.data.l[2] = 0; // No second property
1567 event.xclient.data.l[3] = 1; // Normal window
1568
1569 const int result = XSendEvent(m_display.get(),
1570 DefaultRootWindow(m_display.get()),
1571 False,
1572 SubstructureNotifyMask | SubstructureRedirectMask,
1573 &event);
1574
1575 if (!result)
1576 err() << "Setting fullscreen failed, could not send \"_NET_WM_STATE\" event" << std::endl;
1577 }
1578}
1579
1580
1581////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 3

isFeatureSupportedFunction · 0.85
getAtomFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected