Restore state checking for fullscreen toggle

This commit is contained in:
Phillip Stephens 2015-11-04 20:52:33 -08:00
parent ea922183cc
commit 86491e5585

View File

@ -367,7 +367,7 @@ public:
}; };
struct WindowXlib : IWindow class WindowXlib : public IWindow
{ {
Display* m_xDisp; Display* m_xDisp;
IWindowCallback* m_callback; IWindowCallback* m_callback;
@ -389,6 +389,7 @@ struct WindowXlib : IWindow
/* Cached window rectangle (to avoid repeated X queries) */ /* Cached window rectangle (to avoid repeated X queries) */
int m_wx, m_wy, m_ww, m_wh; int m_wx, m_wy, m_ww, m_wh;
float m_pixelFactor; float m_pixelFactor;
bool m_inFs = false;
public: public:
@ -593,12 +594,16 @@ public:
XFree(vals); XFree(vals);
return fullscreen; return fullscreen;
} }
return false; return false;
} }
void setFullscreen(bool fs) void setFullscreen(bool fs)
{ {
XEvent fsEvent; if (fs == m_inFs)
return;
XEvent fsEvent = {0};
fsEvent.xclient.type = ClientMessage; fsEvent.xclient.type = ClientMessage;
fsEvent.xclient.window = m_windowId; fsEvent.xclient.window = m_windowId;
fsEvent.xclient.message_type = XInternAtom(m_xDisp, "_NET_WM_STATE", False); fsEvent.xclient.message_type = XInternAtom(m_xDisp, "_NET_WM_STATE", False);
@ -608,6 +613,7 @@ public:
fsEvent.xclient.data.l[2] = 0; fsEvent.xclient.data.l[2] = 0;
XSendEvent(m_xDisp, DefaultRootWindow(m_xDisp), False, XSendEvent(m_xDisp, DefaultRootWindow(m_xDisp), False,
StructureNotifyMask | SubstructureRedirectMask, (XEvent*)&fsEvent); StructureNotifyMask | SubstructureRedirectMask, (XEvent*)&fsEvent);
m_inFs = fs;
} }
void waitForRetrace() void waitForRetrace()