rnd-20001127-1-src
[rocksndiamonds.git] / src / x11.c
index 5b97d5ec66fb18faccc4a0974ef799c54fa9b5d5..3c60b1539021d4686309b50b83dee84ada37bf2d 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
@@ -12,7 +12,7 @@
 *  x11.c                                                   *
 ***********************************************************/
 
-#ifdef USE_X11_LIBRARY
+#if defined(TARGET_X11)
 
 #include "main.h"
 #include "misc.h"
@@ -25,7 +25,7 @@ struct IconFileInfo
 
 static void X11InitDisplay()
 {
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
   XVisualInfo vinfo_template, *vinfo;
   int num_visuals;
 #endif
@@ -41,7 +41,7 @@ static void X11InitDisplay()
   depth  = DefaultDepth(display, screen);
   cmap   = DefaultColormap(display, screen);
 
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
   /* look for good enough visual */
   vinfo_template.screen = screen;
   vinfo_template.class = (depth == 8 ? PseudoColor : TrueColor);
@@ -66,15 +66,16 @@ static void X11InitDisplay()
     printf("Sorry, cannot get appropriate visual.\n");
     exit(-1);
   }
-#endif /* !MSDOS */
+#endif /* !PLATFORM_MSDOS */
 }
 
-static void X11InitWindow()
+static DrawWindow X11InitWindow()
 {
+  Window window;
   unsigned int border_width = 4;
   XGCValues gc_values;
   unsigned long gc_valuemask;
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
   XTextProperty windowName, iconName;
   Pixmap icon_pixmap, iconmask_pixmap;
   unsigned int icon_width, icon_height;
@@ -94,7 +95,7 @@ static void X11InitWindow()
   unsigned long pen_bg = BlackPixel(display,screen);
   const int width = WIN_XSIZE, height = WIN_YSIZE;
 
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
   static struct IconFileInfo icon_pic =
   {
     "rocks_icon.xbm",
@@ -112,7 +113,7 @@ static void X11InitWindow()
                               win_xpos, win_ypos, width, height, border_width,
                               pen_fg, pen_bg);
 
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
   proto_atom = XInternAtom(display, "WM_PROTOCOLS", FALSE);
   delete_atom = XInternAtom(display, "WM_DELETE_WINDOW", FALSE);
   if ((proto_atom != None) && (delete_atom != None))
@@ -185,17 +186,21 @@ static void X11InitWindow()
   gc_values.background = pen_bg;
   gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground;
   gc = XCreateGC(display, window, gc_valuemask, &gc_values);
+
+  return window;
 }
 
-inline void X11InitBufferedDisplay(DrawBuffer *unused1, DrawWindow *unused2)
+inline void X11InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window)
 {
   X11InitDisplay();
-  X11InitWindow();
+  *window = X11InitWindow();
 
-  XMapWindow(display, window);
+  XMapWindow(display, *window);
   FlushDisplay();
 
-  pix[PIX_DB_BACK] = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
+  /* create additional buffer for double-buffering */
+  *backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
+  pix[PIX_DB_BACK] = *backbuffer;      /* 'backbuffer' is off-screen buffer */
 }
 
-#endif /* USE_X11_LIBRARY */
+#endif /* TARGET_X11 */