aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-27 17:16:47 +0000
committerDavid Robillard <d@drobilla.net>2014-01-27 17:16:47 +0000
commit69be0a7d6ed810faf6d5090c826df72c58b874f3 (patch)
treea6b1522181e79f9957e023d7c96f6bff018c4b5c
parenta983550a464d14ec2a79fa93021b2f02b64d20fa (diff)
Require PUGL_VERBOSE to be defined for logging.
Add X focus grab hack from Robin Gareus.
-rw-r--r--pugl/pugl_internal.h15
-rw-r--r--pugl/pugl_x11.c21
2 files changed, 31 insertions, 5 deletions
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index 88f59f2..74aae55 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -20,10 +20,25 @@
Note this file contains function definitions, so it must be compiled into
the final binary exactly once. Each platform specific implementation file
including it once should achieve this.
+
+ If you are copying the pugl code into your source tree, the following
+ symbols can be defined to tweak pugl behaviour:
+
+ PUGL_GRAB_FOCUS: Work around reparent keyboard issues by grabbing focus.
+ PUGL_VERBOSE: Print GL information to console.
*/
#include "pugl.h"
+#ifdef PUGL_VERBOSE
+# include <stdio.h>
+# define PUGL_LOG(str) fprintf(stderr, "pugl: " str)
+# define PUGL_LOGF(fmt, ...) fprintf(stderr, "pugl: " fmt, __VA_ARGS__)
+#else
+# define PUGL_LOG(str)
+# define PUGL_LOGF(fmt, ...)
+#endif
+
void puglDefaultReshape(PuglView* view, int width, int height);
typedef struct PuglInternalsImpl PuglInternals;
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index c25b273..8e1de69 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -90,15 +90,15 @@ puglCreate(PuglNativeWindow parent,
if (!vi) {
vi = glXChooseVisual(impl->display, impl->screen, attrListSgl);
impl->doubleBuffered = False;
- printf("singlebuffered rendering will be used, no doublebuffering available\n");
+ PUGL_LOG("No double buffering available\n");
} else {
impl->doubleBuffered = True;
- printf("doublebuffered rendering available\n");
+ PUGL_LOG("Double buffered rendering enabled\n");
}
int glxMajor, glxMinor;
glXQueryVersion(impl->display, &glxMajor, &glxMinor);
- printf("GLX-Version %d.%d\n", glxMajor, glxMinor);
+ PUGL_LOGF("GLX Version %d.%d\n", glxMajor, glxMinor);
impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE);
@@ -116,6 +116,9 @@ puglCreate(PuglNativeWindow parent,
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask
| ButtonPressMask | ButtonReleaseMask
+#ifdef XKEYFOCUSGRAB
+ | EnterWindowMask
+#endif
| PointerMotionMask | StructureNotifyMask;
impl->win = XCreateWindow(
@@ -148,9 +151,9 @@ puglCreate(PuglNativeWindow parent,
}
if (glXIsDirect(impl->display, impl->ctx)) {
- printf("DRI enabled\n");
+ PUGL_LOG("DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1\n");
} else {
- printf("No DRI available\n");
+ PUGL_LOG("No DRI available\n");
}
XFree(vi);
@@ -361,6 +364,14 @@ puglProcessEvents(PuglView* view)
}
}
break;
+#ifdef PUGL_GRAB_FOCUS
+ case EnterNotify:
+ XSetInputFocus(view->impl->display,
+ view->impl->win,
+ RevertToPointerRoot,
+ CurrentTime);
+ break;
+#endif
default:
break;
}