From e6b075339e5851f1684add48f74fcd772fa67bb8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 18 Sep 2014 13:55:43 +0000 Subject: Xdbe --- Sgraph.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'Sgraph.c') diff --git a/Sgraph.c b/Sgraph.c index a6941d9..a5a4c99 100644 --- a/Sgraph.c +++ b/Sgraph.c @@ -18,6 +18,7 @@ #include #include +#include #include "SgraphP.h" #include @@ -166,7 +167,11 @@ Initialize(Widget request, Widget w, ArgList args, Cardinal *nargs) static void Realize(Widget w, XtValueMask *mask, XSetWindowAttributes *attr) { + SgraphWidget sw = (SgraphWidget)w; + XtCreateWindow(w, InputOutput, CopyFromParent, *mask, attr); + sw->sgraph.backBuf = XdbeAllocateBackBufferName(XtDisplay(w), + XtWindow(w), XdbeBackground); Resize(w); } @@ -209,8 +214,8 @@ Redisplay(Widget w, XEvent *event, Region r) SgraphWidget sw = (SgraphWidget)w; Dimension width = winwidth / 2; Dimension height = winheight / 4; - Dimension x, y; - static Dimension n; + Dimension x, yl, yr; + XdbeSwapInfo swap; if (!XtIsRealized(w)) return; @@ -228,18 +233,25 @@ Redisplay(Widget w, XEvent *event, Region r) //warnx("%lf : %lf" , sw->sgraph.leftData[0], sw->sgraph.rightData[0]); + /* XFillRectangle(XtDisplay(sw), sw->sgraph.bg, sw->sgraph.backGC, 0, 0, width, height); + */ for (x = 0; x < sw->sgraph.size; x++) { - y = sw->sgraph.leftData[x] / (2 * height) + height / 2; - XDrawPoint(XtDisplay(sw), sw->sgraph.bg, sw->sgraph.foreGC, - x, y); + yl = sw->sgraph.leftData[x] / (2 * height) + height / 2; + yr = sw->sgraph.leftData[x] / (2 * height) + height / 2 + + height; + XDrawPoint(XtDisplay(sw), sw->sgraph.backBuf, + sw->sgraph.foreGC, x, yl); + XDrawPoint(XtDisplay(sw), sw->sgraph.backBuf, + sw->sgraph.foreGC, x, yr); } - //XClearWindow(XtDisplay(sw), XtWindow(sw)); - XCopyArea(XtDisplay(sw), sw->sgraph.bg, XtWindow(sw), sw->sgraph.foreGC, - 0, 0, width, height, BORDER, BORDER); + swap.swap_window = XtWindow(sw); + swap.swap_action = XdbeBackground; + + XdbeSwapBuffers(XtDisplay(sw), &swap, 1); } static Boolean -- cgit v1.2.3