summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-09-12 13:00:37 -0400
committerDavid Robillard <d@drobilla.net>2015-09-12 13:00:37 -0400
commitae2153511097fc0cc34c0456ebbb13fd4f5c79ec (patch)
tree152f3e4264ab906b28ffa38ecd8f0ee243ffd07b
parentdc90b4f5d902218b4e1ccfa5a2b3c1a0b24a7995 (diff)
Fix resizing with cairo context.
-rw-r--r--pugl/pugl_x11.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index a48edde..bd85b37 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -43,17 +43,18 @@
#include "pugl/pugl_internal.h"
struct PuglInternalsImpl {
- Display* display;
- int screen;
- Window win;
- XIM xim;
- XIC xic;
+ Display* display;
+ int screen;
+ Window win;
+ XIM xim;
+ XIC xic;
#ifdef PUGL_HAVE_CAIRO
- cairo_t* cr;
+ cairo_surface_t* surface;
+ cairo_t* cr;
#endif
#ifdef PUGL_HAVE_GL
- GLXContext ctx;
- Bool doubleBuffered;
+ GLXContext ctx;
+ Bool doubleBuffered;
#endif
};
@@ -118,9 +119,9 @@ createContext(PuglView* view, XVisualInfo* vi)
#endif
#ifdef PUGL_HAVE_CAIRO
if (view->ctx_type == PUGL_CAIRO) {
- cairo_surface_t* surface = cairo_xlib_surface_create(
+ view->impl->surface = cairo_xlib_surface_create(
impl->display, impl->win, vi->visual, view->width, view->height);
- if (!(impl->cr = cairo_create(surface))) {
+ if (!(impl->cr = cairo_create(view->impl->surface))) {
fprintf(stderr, "failed to create cairo context\n");
}
}
@@ -486,6 +487,7 @@ PuglStatus
puglProcessEvents(PuglView* view)
{
XEvent xevent;
+ bool resized = false;
while (XPending(view->impl->display) > 0) {
XNextEvent(view->impl->display, &xevent);
bool ignore = false;
@@ -516,6 +518,8 @@ puglProcessEvents(PuglView* view)
XSetICFocus(view->impl->xic);
} else if (xevent.type == FocusOut) {
XUnsetICFocus(view->impl->xic);
+ } else if (xevent.type == ConfigureNotify) {
+ resized = true;
}
if (!ignore) {
@@ -525,6 +529,15 @@ puglProcessEvents(PuglView* view)
}
}
+ if (resized) {
+#ifdef PUGL_HAVE_CAIRO
+ if (view->ctx_type == PUGL_CAIRO) {
+ cairo_xlib_surface_set_size(
+ view->impl->surface, view->width, view->height);
+ }
+#endif
+ }
+
if (view->redisplay) {
const PuglEventExpose expose = {
PUGL_EXPOSE, view, true, 0, 0, view->width, view->height, 0