Index: src/views/unix/SkOSWindow_Unix.cpp |
diff --git a/src/views/unix/SkOSWindow_Unix.cpp b/src/views/unix/SkOSWindow_Unix.cpp |
index e22377a2643a04d05b51f8e2b1c9ac6f33ad2c83..ea2d60b0f3323809ade3fbc43d175b38d49aefe7 100644 |
--- a/src/views/unix/SkOSWindow_Unix.cpp |
+++ b/src/views/unix/SkOSWindow_Unix.cpp |
@@ -326,6 +326,29 @@ void SkOSWindow::mapWindowAndWait() { |
} |
+//////////////////////////////////////////////// |
+ |
+// Some helper code to load the correct version of glXSwapInterval |
+#define GLX_GET_PROC_ADDR(name) glXGetProcAddress(reinterpret_cast<const GLubyte*>((name))) |
+#define EXT_WRANGLE(name, type, ...) \ |
+ if (GLX_GET_PROC_ADDR(#name)) { \ |
+ static type k##name; \ |
+ if (!k##name) { \ |
+ k##name = (type) GLX_GET_PROC_ADDR(#name); \ |
+ } \ |
+ k##name(__VA_ARGS__); \ |
+ SkDebugf("using %s\n", #name); \ |
+ return; \ |
+ } |
+ |
+static void glXSwapInterval(Display* dsp, GLXDrawable drawable, int interval) { |
+ EXT_WRANGLE(glXSwapIntervalEXT, PFNGLXSWAPINTERVALEXTPROC, dsp, drawable, interval); |
+ EXT_WRANGLE(glXSwapIntervalMESA, PFNGLXSWAPINTERVALMESAPROC, interval); |
+ EXT_WRANGLE(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC, interval); |
+} |
+ |
+///////////////////////////////////////////////////////////////////////// |
+ |
bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* info) { |
this->initWindow(msaaSampleCount, info); |
@@ -427,6 +450,44 @@ void SkOSWindow::doPaint() { |
width, height); |
} |
+enum { |
+ _NET_WM_STATE_REMOVE =0, |
+ _NET_WM_STATE_ADD = 1, |
+ _NET_WM_STATE_TOGGLE =2 |
+}; |
+ |
+void SkOSWindow::setFullscreen(bool setFullscreen) { |
+ Display* dsp = fUnixWindow.fDisplay; |
+ if (NULL == dsp) { |
+ return; |
+ } |
+ Window win = fUnixWindow.fWin; |
+ |
+ // Full screen |
+ Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False); |
+ Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False); |
+ |
+ XEvent evt; |
+ sk_bzero(&evt, sizeof(evt)); |
+ evt.type = ClientMessage; |
+ evt.xclient.window = win; |
+ evt.xclient.message_type = wm_state; |
+ evt.xclient.format = 32; |
+ evt.xclient.data.l[0] = setFullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; |
+ evt.xclient.data.l[1] = fullscreen; |
+ evt.xclient.data.l[2] = 0; |
+ |
+ XSendEvent(dsp, DefaultRootWindow(dsp), False, |
+ SubstructureRedirectMask | SubstructureNotifyMask, &evt); |
+} |
+ |
+void SkOSWindow::setVsync(bool vsync) { |
+ if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) { |
+ int swapInterval = vsync ? 1 : 0; |
+ glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval); |
+ } |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
void SkEvent::SignalNonEmptyQueue() { |