*The Cheat cries*
This commit is contained in:
parent
d7b6afbceb
commit
7c21f1ad16
1 changed files with 12 additions and 44 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <cairo-xlib.h>
|
||||
|
||||
#include <hexagram/can.h>
|
||||
#include <hexagram/window.h>
|
||||
|
||||
static void draw_needle(cairo_t *cr,
|
||||
double x,
|
||||
|
@ -228,69 +229,44 @@ static void update_gauge_cluster(cairo_t *cr,
|
|||
|
||||
int main(int argc, char **argv) {
|
||||
Display *display;
|
||||
Window win;
|
||||
Pixmap bg;
|
||||
XdbeBackBuffer buf;
|
||||
GC gc;
|
||||
fd_set rfds, rready;
|
||||
|
||||
hexagram_can_if *can_if;
|
||||
hexagram_window *window;
|
||||
|
||||
int screen, fd, fd2,
|
||||
width = 1024,
|
||||
height = 480;
|
||||
|
||||
int major, minor;
|
||||
|
||||
XGCValues values = {
|
||||
.foreground = 0x000000,
|
||||
.background = 0xffffff,
|
||||
.graphics_exposures = 0
|
||||
};
|
||||
|
||||
XdbeSwapInfo swapinfo;
|
||||
|
||||
cairo_surface_t *sfc;
|
||||
cairo_t *cr;
|
||||
|
||||
if ((can_if = hexagram_can_if_open("vcan0")) == NULL)
|
||||
exit(1);
|
||||
|
||||
if ((display = XOpenDisplay(NULL)) == NULL)
|
||||
if ((window = hexagram_window_new_x11(NULL, width, height)) == NULL)
|
||||
exit(1);
|
||||
|
||||
if (XdbeQueryExtension(display, &major, &minor))
|
||||
printf("Xdbe %d.%d supported\n", major, minor);
|
||||
else
|
||||
exit(1);
|
||||
display = window->display;
|
||||
screen = window->screen;
|
||||
|
||||
fd = hexagram_can_if_fd(can_if);
|
||||
fd2 = ConnectionNumber(display);
|
||||
fd2 = hexagram_window_display_fd(window);
|
||||
|
||||
screen = DefaultScreen(display);
|
||||
|
||||
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);
|
||||
bg = window->bg;
|
||||
|
||||
/*
|
||||
* Draw the background layer
|
||||
*/
|
||||
draw_gauge_cluster_bg(bg, display, screen, width, height);
|
||||
|
||||
printf("XSelectInput %d\n", XSelectInput(display, win, ExposureMask | ButtonPressMask | KeyPressMask));
|
||||
XMapWindow(display, win);
|
||||
hexagram_window_show(window);
|
||||
|
||||
/*
|
||||
* Set up the foreground surface
|
||||
*/
|
||||
sfc = cairo_xlib_surface_create(display, buf, DefaultVisual(display, screen), width, height);
|
||||
cairo_xlib_surface_set_size(sfc, width, height);
|
||||
sfc = window->surface_fg;
|
||||
|
||||
cr = cairo_create(sfc);
|
||||
|
||||
|
@ -314,13 +290,7 @@ int main(int argc, char **argv) {
|
|||
case Expose:
|
||||
fprintf(stderr, "Event %d\n", e.type);
|
||||
|
||||
XCopyArea(display, bg, win, gc,
|
||||
e.xexpose.x,
|
||||
e.xexpose.y,
|
||||
e.xexpose.width,
|
||||
e.xexpose.height,
|
||||
e.xexpose.x,
|
||||
e.xexpose.y);
|
||||
hexagram_window_refresh_bg(window);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -345,13 +315,11 @@ int main(int argc, char **argv) {
|
|||
hexagram_can_if_read(can_if, &frame);
|
||||
|
||||
if (frame.can_id == 0x280) {
|
||||
XCopyArea(display, bg, buf, gc, 0, 0,
|
||||
width, height,
|
||||
0, 0);
|
||||
hexagram_window_refresh_bg(window);
|
||||
|
||||
update_gauge_cluster(cr, &frame, 0, 0, width, height);
|
||||
|
||||
XdbeSwapBuffers(display, &swapinfo, 1);
|
||||
hexagram_window_swap_buffer(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue