summaryrefslogtreecommitdiffstats
path: root/compton.h
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2013-03-01 12:41:16 +0800
committerRichard Grenville <[email protected]>2013-03-01 12:41:16 +0800
commit71fdda46e615df29ac1b2c8d3d1984a7be3b44fd (patch)
treefe7ce77c65bc09925a39b393078fa922baa0c5d5 /compton.h
parentd1fb8649a4e5d2ec165bd4226d53703043678eb2 (diff)
downloadtdebase-71fdda46e615df29ac1b2c8d3d1984a7be3b44fd.tar.gz
tdebase-71fdda46e615df29ac1b2c8d3d1984a7be3b44fd.zip
Bug fix #91: Using pkg-config to find drm.h & OpenGL changes
- #91: Use pkg-config to find drm.h to avoid issues on FreeBSD. Thanks to hun7err for pointing out and providing patch. - #89: Add default shadow exclusion rule for notify-osd. Thanks to DanielRS. - Check for abundant positional arguments. - Use paint target window (root window / overlay window) instead of ps->reg_win to create GLXContext. (May have negative effects on OpenGL VSync.) Add new OpenGL helpers functions, to prepare for the new OpenGL backend. - Dump more info of a PropertyNotify with DEBUG_EVENTS.
Diffstat (limited to 'compton.h')
-rw-r--r--compton.h76
1 files changed, 41 insertions, 35 deletions
diff --git a/compton.h b/compton.h
index b4f5bfd44..f0af56482 100644
--- a/compton.h
+++ b/compton.h
@@ -9,6 +9,7 @@
#include "common.h"
+#include <ctype.h>
#include <math.h>
#include <sys/select.h>
#include <limits.h>
@@ -22,7 +23,7 @@
// We references some definitions in drm.h, which could also be found in
// /usr/src/linux/include/drm/drm.h, but that path is probably even less
// reliable than libdrm
-#include <libdrm/drm.h>
+#include <drm.h>
#include <sys/ioctl.h>
#include <errno.h>
#endif
@@ -705,40 +706,7 @@ static void __attribute__ ((noreturn))
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
+register_cm(session_t *ps);
inline static void
ev_focus_in(session_t *ps, XFocusChangeEvent *ev);
@@ -920,6 +888,44 @@ static void
swopti_handle_timeout(session_t *ps, struct timeval *ptv);
static bool
+opengl_init(session_t *ps, bool need_render);
+
+static void
+opengl_destroy(session_t *ps);
+
+#ifdef CONFIG_VSYNC_OPENGL
+/**
+ * Check if a GLX extension exists.
+ */
+static inline bool
+opengl_hasext(session_t *ps, const char *ext) {
+ const char *glx_exts = glXQueryExtensionsString(ps->dpy, ps->scr);
+ const char *pos = strstr(glx_exts, ext);
+ // Make sure the extension string is matched as a whole word
+ if (!pos
+ || ((pos - glx_exts) && !isspace(*(pos - 1)))
+ || (strlen(pos) > strlen(ext) && !isspace(pos[strlen(ext)]))) {
+ printf_errf("(): Missing OpenGL extension %s.", ext);
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Ensure we have a GLX context.
+ */
+static inline bool
+ensure_glx_context(session_t *ps) {
+ // Create GLX context
+ if (!ps->glx_context)
+ opengl_init(ps, false);
+
+ return ps->glx_context;
+}
+#endif
+
+static bool
vsync_drm_init(session_t *ps);
#ifdef CONFIG_VSYNC_DRM