|
@@ -371,8 +371,6 @@ void initX(int argc, char * argv[], XInfo & xInfo)
|
|
|
*/
|
|
|
int i = 0;
|
|
|
xInfo.gc[i] = XCreateGC(xInfo.display, xInfo.window, 0, 0);
|
|
|
- XSetForeground(xInfo.display, xInfo.gc[i], BlackPixel(xInfo.display, xInfo.screen));
|
|
|
- XSetBackground(xInfo.display, xInfo.gc[i], WhitePixel(xInfo.display, xInfo.screen));
|
|
|
XSetFillStyle(xInfo.display, xInfo.gc[i], FillSolid);
|
|
|
XSetLineAttributes(xInfo.display, xInfo.gc[i],
|
|
|
1, LineSolid, CapButt, JoinRound);
|
|
@@ -380,8 +378,7 @@ void initX(int argc, char * argv[], XInfo & xInfo)
|
|
|
XSelectInput(xInfo.display, xInfo.window,
|
|
|
ButtonPressMask | KeyPressMask |
|
|
|
PointerMotionMask |
|
|
|
- EnterWindowMask | LeaveWindowMask |
|
|
|
- StructureNotifyMask); // for resize events
|
|
|
+ EnterWindowMask | LeaveWindowMask); // for resize events
|
|
|
|
|
|
/*
|
|
|
* Put the window on the screen.
|
|
@@ -404,8 +401,6 @@ void repaint(XInfo & xinfo)
|
|
|
unsigned int height = windowInfo.height;
|
|
|
unsigned int width = windowInfo.width;
|
|
|
|
|
|
- // big black rectangle to clear background
|
|
|
-
|
|
|
// draw display list
|
|
|
while (begin != end)
|
|
|
{
|
|
@@ -413,7 +408,6 @@ void repaint(XInfo & xinfo)
|
|
|
d->paint(xinfo);
|
|
|
begin++;
|
|
|
}
|
|
|
- XFlush(xinfo.display);
|
|
|
}
|
|
|
|
|
|
void handleKeyPress(XInfo & xinfo, XEvent & event)
|
|
@@ -484,14 +478,11 @@ void eventLoop(XInfo & xinfo)
|
|
|
// Add stuff to paint to the display list
|
|
|
dList.push_front(&snake);
|
|
|
dList.push_front(&fruity);
|
|
|
-
|
|
|
XEvent event;
|
|
|
-
|
|
|
unsigned long lastRepaint = 0;
|
|
|
int inside = 0;
|
|
|
XWindowAttributes w;
|
|
|
XGetWindowAttributes(xinfo.display, xinfo.window, &w);
|
|
|
-
|
|
|
int depth = DefaultDepth(xinfo.display, DefaultScreen(xinfo.display));
|
|
|
// represents thing to draw
|
|
|
Pixmap buffer = XCreatePixmap(xinfo.display, xinfo.window, w.width, w.height, depth);
|
|
@@ -515,6 +506,7 @@ void eventLoop(XInfo & xinfo)
|
|
|
inside = 0;
|
|
|
break;
|
|
|
}
|
|
|
+ usebuffer = !usebuffer;
|
|
|
}
|
|
|
|
|
|
unsigned long end = now();
|
|
@@ -536,9 +528,10 @@ void eventLoop(XInfo & xinfo)
|
|
|
XClearWindow(xinfo.display, pixmap);
|
|
|
}
|
|
|
|
|
|
- //XSetForeground(xinfo.display, xinfo.gc[0], BlackPixel(xinfo.display, xinfo.screen));
|
|
|
- //XSetBackground(xinfo.display, xinfo.gc[0], WhitePixel(xinfo.display, xinfo.screen));
|
|
|
+ XSetForeground(xinfo.display, xinfo.gc[0], BlackPixel(xinfo.display, xinfo.screen));
|
|
|
+ XSetBackground(xinfo.display, xinfo.gc[0], WhitePixel(xinfo.display, xinfo.screen));
|
|
|
handleAnimation(xinfo, inside);
|
|
|
+ repaint(xinfo);
|
|
|
if (usebuffer)
|
|
|
{
|
|
|
XCopyArea(xinfo.display, pixmap, xinfo.window, xinfo.gc[0], 0, 0 , w.width, w.height, 0, 0);
|