summaryrefslogtreecommitdiffstats
path: root/compton.h
diff options
context:
space:
mode:
Diffstat (limited to 'compton.h')
-rw-r--r--compton.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/compton.h b/compton.h
index ddc17044f..b4f5bfd44 100644
--- a/compton.h
+++ b/compton.h
@@ -707,6 +707,39 @@ usage(void);
static bool
register_cm(session_t *ps, bool glx);
+#ifdef CONFIG_VSYNC_OPENGL
+/**
+ * Ensure we have a GLX context.
+ */
+static inline bool
+ensure_glx_context(session_t *ps) {
+ if (ps->glx_context)
+ return true;
+
+ // Check for GLX extension
+ if (!ps->glx_exists) {
+ if (glXQueryExtension(ps->dpy, &ps->glx_event, &ps->glx_error))
+ ps->glx_exists = true;
+ else {
+ printf_errf("(): No GLX extension.");
+ return false;
+ }
+ }
+
+ // Create GLX context
+ if (ps->reg_win) {
+ XDestroyWindow(ps->dpy, ps->reg_win);
+ ps->reg_win = None;
+ }
+ if (!register_cm(ps, true) || !ps->glx_context) {
+ printf_errf("(): Failed to acquire GLX context.");
+ return false;
+ }
+
+ return true;
+}
+#endif
+
inline static void
ev_focus_in(session_t *ps, XFocusChangeEvent *ev);