*The Cheat cries*

This commit is contained in:
XANTRONIX Development 2019-05-28 00:41:54 -05:00
parent d7b6afbceb
commit 7c21f1ad16

View file

@ -12,6 +12,7 @@
#include <cairo-xlib.h> #include <cairo-xlib.h>
#include <hexagram/can.h> #include <hexagram/can.h>
#include <hexagram/window.h>
static void draw_needle(cairo_t *cr, static void draw_needle(cairo_t *cr,
double x, double x,
@ -228,69 +229,44 @@ static void update_gauge_cluster(cairo_t *cr,
int main(int argc, char **argv) { int main(int argc, char **argv) {
Display *display; Display *display;
Window win;
Pixmap bg; Pixmap bg;
XdbeBackBuffer buf;
GC gc;
fd_set rfds, rready; fd_set rfds, rready;
hexagram_can_if *can_if; hexagram_can_if *can_if;
hexagram_window *window;
int screen, fd, fd2, int screen, fd, fd2,
width = 1024, width = 1024,
height = 480; height = 480;
int major, minor;
XGCValues values = {
.foreground = 0x000000,
.background = 0xffffff,
.graphics_exposures = 0
};
XdbeSwapInfo swapinfo;
cairo_surface_t *sfc; cairo_surface_t *sfc;
cairo_t *cr; cairo_t *cr;
if ((can_if = hexagram_can_if_open("vcan0")) == NULL) if ((can_if = hexagram_can_if_open("vcan0")) == NULL)
exit(1); exit(1);
if ((display = XOpenDisplay(NULL)) == NULL) if ((window = hexagram_window_new_x11(NULL, width, height)) == NULL)
exit(1); exit(1);
if (XdbeQueryExtension(display, &major, &minor)) display = window->display;
printf("Xdbe %d.%d supported\n", major, minor); screen = window->screen;
else
exit(1);
fd = hexagram_can_if_fd(can_if); fd = hexagram_can_if_fd(can_if);
fd2 = ConnectionNumber(display); fd2 = hexagram_window_display_fd(window);
screen = DefaultScreen(display); bg = window->bg;
win = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, width, height, 0, 0, 0);
buf = XdbeAllocateBackBufferName(display, win, XdbeBackground);
swapinfo.swap_window = win;
swapinfo.swap_action = XdbeBackground;
gc = XCreateGC(display, win, GCForeground | GCBackground | GCGraphicsExposures, &values);
bg = XCreatePixmap(display, win, width, height, 24);
/* /*
* Draw the background layer * Draw the background layer
*/ */
draw_gauge_cluster_bg(bg, display, screen, width, height); draw_gauge_cluster_bg(bg, display, screen, width, height);
printf("XSelectInput %d\n", XSelectInput(display, win, ExposureMask | ButtonPressMask | KeyPressMask)); hexagram_window_show(window);
XMapWindow(display, win);
/* /*
* Set up the foreground surface * Set up the foreground surface
*/ */
sfc = cairo_xlib_surface_create(display, buf, DefaultVisual(display, screen), width, height); sfc = window->surface_fg;
cairo_xlib_surface_set_size(sfc, width, height);
cr = cairo_create(sfc); cr = cairo_create(sfc);
@ -314,13 +290,7 @@ int main(int argc, char **argv) {
case Expose: case Expose:
fprintf(stderr, "Event %d\n", e.type); fprintf(stderr, "Event %d\n", e.type);
XCopyArea(display, bg, win, gc, hexagram_window_refresh_bg(window);
e.xexpose.x,
e.xexpose.y,
e.xexpose.width,
e.xexpose.height,
e.xexpose.x,
e.xexpose.y);
break; break;
@ -345,13 +315,11 @@ int main(int argc, char **argv) {
hexagram_can_if_read(can_if, &frame); hexagram_can_if_read(can_if, &frame);
if (frame.can_id == 0x280) { if (frame.can_id == 0x280) {
XCopyArea(display, bg, buf, gc, 0, 0, hexagram_window_refresh_bg(window);
width, height,
0, 0);
update_gauge_cluster(cr, &frame, 0, 0, width, height); update_gauge_cluster(cr, &frame, 0, 0, width, height);
XdbeSwapBuffers(display, &swapinfo, 1); hexagram_window_swap_buffer(window);
} }
} }
} }