From e6b075339e5851f1684add48f74fcd772fa67bb8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 18 Sep 2014 13:55:43 +0000 Subject: Xdbe --- Makefile | 2 +- Sgraph.c | 28 ++++++++++++++++++++-------- SgraphP.h | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 661319d..d9bdd24 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VERSION=3.0 PROG= spectrogram SRCS= spectrogram.c fft.c cms.c aux.c widget.c Sgraph.c -LIBS= fftw3 xt +LIBS= fftw3 xt xext BINDIR= /usr/local/bin UNAME!= uname 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 diff --git a/SgraphP.h b/SgraphP.h index b9597d5..4f4b6bc 100644 --- a/SgraphP.h +++ b/SgraphP.h @@ -46,6 +46,7 @@ typedef struct { int size; int samples; + XdbeBackBuffer backBuf; GC foreGC; GC backGC; GC maskGC; -- cgit v1.2.3