aboutsummaryrefslogtreecommitdiff
path: root/Sgraph.c
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 /Sgraph.c
parent82fb7d543e11b2dae290f5df59685e9dc6b2effc (diff)
Xdbe
Diffstat (limited to 'Sgraph.c')
-rw-r--r--Sgraph.c28
1 files changed, 20 insertions, 8 deletions
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