Fullscreen fix

This commit is contained in:
Phillip Stephens 2015-10-30 23:39:11 -07:00
parent 9160423fe8
commit 5fe40276a0
2 changed files with 21 additions and 14 deletions

View File

@ -519,10 +519,13 @@ public:
bool isFullscreen() const
{
unsigned long nitems;
Atom actualType;
int actualFormat;
unsigned long bytes;
Atom* vals = nullptr;
bool fullscreen = false;
if (XGetWindowProperty(m_xDisp, m_windowId, S_ATOMS->m_netwmState, 0, 65536, False,
XA_ATOM, nullptr, nullptr, &nitems, nullptr, (unsigned char**)&vals))
if (XGetWindowProperty(m_xDisp, m_windowId, XInternAtom(m_xDisp, "_NET_WM_STATE", True), 0, ~0l, False,
XA_ATOM, &actualType, &actualFormat, &nitems, &bytes, (unsigned char**)&vals) == Success)
{
for (int i=0 ; i<nitems ; ++i)
{
@ -540,18 +543,14 @@ public:
void setFullscreen(bool fs)
{
XClientMessageEvent fsEvent =
{
ClientMessage,
0,
True,
m_xDisp,
m_windowId,
S_ATOMS->m_netwmState,
32
};
fsEvent.data.l[0] = fs ? S_ATOMS->m_netwmStateAdd : S_ATOMS->m_netwmStateRemove;
fsEvent.data.l[1] = S_ATOMS->m_netwmStateFullscreen;
XEvent fsEvent;
fsEvent.type = ClientMessage;
fsEvent.xclient.window = m_windowId;
fsEvent.xclient.message_type = XInternAtom(m_xDisp, "_NET_WM_STATE", False);
fsEvent.xclient.format = 32;
fsEvent.xclient.data.l[0] = fs;
fsEvent.xclient.data.l[1] = XInternAtom(m_xDisp, "_NET_WM_STATE_FULLSCREEN", False);
fsEvent.xclient.data.l[2] = 0;
XSendEvent(m_xDisp, m_windowId, False,
StructureNotifyMask | SubstructureRedirectMask, (XEvent*)&fsEvent);
}

View File

@ -278,12 +278,14 @@ struct TestApplicationCallback : IApplicationCallback
mainWindow = app->newWindow(_S("YAY!"));
mainWindow->setCallback(&windowCallback);
mainWindow->showWindow();
mainWindow->setFullscreen(true);
devFinder.startScanning();
IGraphicsCommandQueue* gfxQ = mainWindow->getCommandQueue();
std::thread loaderThread(LoaderProc, this);
size_t frameIdx = 0;
size_t lastCheck = 0;
while (running)
{
mainWindow->waitForRetrace();
@ -300,6 +302,12 @@ struct TestApplicationCallback : IApplicationCallback
gfxQ->execute();
fprintf(stderr, "%zu\n", frameIdx++);
if ((frameIdx - lastCheck) > 100)
{
lastCheck = frameIdx;
mainWindow->setFullscreen(!mainWindow->isFullscreen());
}
}
m_cv.notify_one();