X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=simple_window.cc;h=cbb35062820d3a75d75a69a809a93d63b2d54933;hb=e9a44449a4002827894a51cdbb9072d423cba765;hp=ae981edb228ab2c689cb5f6d0ec5fdc5264a2e35;hpb=ea2a7fd04689794d3fb266e2b73bedb10953abb4;p=universe.git diff --git a/simple_window.cc b/simple_window.cc index ae981ed..cbb3506 100644 --- a/simple_window.cc +++ b/simple_window.cc @@ -77,6 +77,13 @@ SimpleWindow::SimpleWindow(const char *name, int x, int y, int w, int h) { XSetState(_display, _gc, 0, 0, GXcopy, AllPlanes); XFillRectangle(_display, _pixmap, _gc, 0, 0, _width, _height); XFlush(_display); + +#ifdef CAIRO_SUPPORT + _cairo_surface = cairo_xlib_surface_create(_display, _pixmap, _visual, _width, _height); + cairo_xlib_surface_set_size(_cairo_surface, _width, _height); + _cairo_context = cairo_create(_cairo_surface); +#endif + } else abort(); } @@ -85,6 +92,10 @@ SimpleWindow::~SimpleWindow() { XUnmapWindow(_display, _window); XDestroyWindow(_display, _window); XCloseDisplay(_display); +#ifdef CAIRO_SUPPORT + cairo_destroy(_cairo_context); + cairo_surface_destroy(_cairo_surface); +#endif } int SimpleWindow::width() { @@ -214,12 +225,6 @@ SimpleEvent SimpleWindow::event() { #ifdef CAIRO_SUPPORT cairo_t *SimpleWindow::get_cairo_context_resource() { - cairo_surface_t *surface; - - surface = cairo_xlib_surface_create(_display, _pixmap, _visual, _width, _height); - - cairo_xlib_surface_set_size(surface, _width, _height); - - return cairo_create(surface); + return _cairo_context; } #endif