aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-18 13:55:43 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-18 13:55:43 +0000
commite6b075339e5851f1684add48f74fcd772fa67bb8 (patch)
tree09b9d5312466da580cfc33cd5f308455affc30bc
parent82fb7d543e11b2dae290f5df59685e9dc6b2effc (diff)
Xdbe
-rw-r--r--Makefile2
-rw-r--r--Sgraph.c28
-rw-r--r--SgraphP.h1
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 <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
+#include <X11/extensions/Xdbe.h>
#include "SgraphP.h"
#include <err.h>
@@ -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;