if (_display) {
- Visual *v = XDefaultVisual(_display, DefaultScreen(_display));
+ _screen = DefaultScreen(_display);
+ _visual = XDefaultVisual(_display, _screen);
- _blue_mask = v->blue_mask;
- _green_mask = v->green_mask;
- _red_mask = v->red_mask;
+ _blue_mask = _visual->blue_mask;
+ _green_mask = _visual->green_mask;
+ _red_mask = _visual->red_mask;
- if(_blue_mask == 0 || _green_mask == 0 || _red_mask == 0) {
- cerr << "Can not deal with the colors on that display.\n";
- }
+ if(_blue_mask == 0 || _green_mask == 0 || _red_mask == 0) {
+ cerr << "Can not deal with the colors on that display.\n";
+ }
- _red_shift = 1;
- while(!(_red_mask & 1)) {
- _red_mask = _red_mask >> 1;
- _red_shift = _red_shift << 1;
- }
+ _red_shift = 1;
+ while(!(_red_mask & 1)) {
+ _red_mask = _red_mask >> 1;
+ _red_shift = _red_shift << 1;
+ }
- _green_shift = 1;
- while(!(_green_mask & 1)) {
- _green_mask = _green_mask >> 1;
- _green_shift = _green_shift << 1;
- }
+ _green_shift = 1;
+ while(!(_green_mask & 1)) {
+ _green_mask = _green_mask >> 1;
+ _green_shift = _green_shift << 1;
+ }
- _blue_shift = 1;
- while(!(_blue_mask & 1)) {
- _blue_mask = _blue_mask >> 1;
- _blue_shift = _blue_shift << 1;
- }
+ _blue_shift = 1;
+ while(!(_blue_mask & 1)) {
+ _blue_mask = _blue_mask >> 1;
+ _blue_shift = _blue_shift << 1;
+ }
- _gc = DefaultGC(_display, DefaultScreen(_display));
+ _gc = DefaultGC(_display, DefaultScreen(_display));
- XSetWindowAttributes xswa;
+ XSetWindowAttributes xswa;
- _pixmap = XCreatePixmap(_display, DefaultRootWindow(_display),
- _width, _height, DisplayPlanes(_display, DefaultScreen(_display)));
+ _pixmap = XCreatePixmap(_display, DefaultRootWindow(_display),
+ _width, _height, DisplayPlanes(_display, DefaultScreen(_display)));
- xswa.background_pixmap = _pixmap;
- xswa.event_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | KeyPressMask | KeyReleaseMask;
- xswa.backing_store = Always;
+ xswa.background_pixmap = _pixmap;
+ xswa.event_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | KeyPressMask | KeyReleaseMask;
+ xswa.backing_store = Always;
- _window = XCreateWindow(_display, DefaultRootWindow(_display), x, y, _width, _height,
- 0, 0, InputOutput, CopyFromParent,
- CWBackPixmap | CWEventMask | CWBackingStore,
- &xswa);
+ _window = XCreateWindow(_display, DefaultRootWindow(_display), x, y, _width, _height,
+ 0, 0, InputOutput, CopyFromParent,
+ CWBackPixmap | CWEventMask | CWBackingStore,
+ &xswa);
- XSizeHints size_hints;
- size_hints.flags = PMinSize | PMaxSize | USPosition;
- size_hints.x = x; // These two lines do not seem to be required
- size_hints.y = y; // ...
- size_hints.min_width = _width;
- size_hints.min_height = _height;
- size_hints.max_width = _width;
- size_hints.max_height = _height;
- XSetNormalHints(_display, _window, &size_hints);
+ XSizeHints size_hints;
+ size_hints.flags = PMinSize | PMaxSize | USPosition;
+ size_hints.x = x; // These two lines do not seem to be required
+ size_hints.y = y; // ...
+ size_hints.min_width = _width;
+ size_hints.min_height = _height;
+ size_hints.max_width = _width;
+ size_hints.max_height = _height;
+ XSetNormalHints(_display, _window, &size_hints);
- XStoreName(_display, _window, name);
+ XStoreName(_display, _window, name);
- XSetState(_display, _gc, 0, 0, GXcopy, AllPlanes);
- XFillRectangle(_display, _pixmap, _gc, 0, 0, _width, _height);
- XFlush(_display);
- } else abort();
+ XSetState(_display, _gc, 0, 0, GXcopy, AllPlanes);
+ XFillRectangle(_display, _pixmap, _gc, 0, 0, _width, _height);
+ XFlush(_display);
+ } else abort();
}
} else se.type = SimpleEvent::NO_EVENT;
return se;
}
+
+#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);
+}
+#endif