summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/graph/dump_img.c1
-rw-r--r--otherlibs/graph/libgraph.h3
-rw-r--r--otherlibs/graph/make_img.c2
-rw-r--r--otherlibs/graph/open.c22
-rw-r--r--otherlibs/graph/text.c2
5 files changed, 20 insertions, 10 deletions
diff --git a/otherlibs/graph/dump_img.c b/otherlibs/graph/dump_img.c
index 7f0ba680e..19076a6d0 100644
--- a/otherlibs/graph/dump_img.c
+++ b/otherlibs/graph/dump_img.c
@@ -13,6 +13,7 @@
#include "libgraph.h"
#include "image.h"
+#include <alloc.h>
#include <memory.h>
static value gr_alloc_int_vect(size)
diff --git a/otherlibs/graph/libgraph.h b/otherlibs/graph/libgraph.h
index 6ec1e6720..fb3584f5e 100644
--- a/otherlibs/graph/libgraph.h
+++ b/otherlibs/graph/libgraph.h
@@ -22,7 +22,7 @@ struct canvas {
GC gc; /* The associated graphics context */
};
-Display * grdisplay; /* The display connection */
+extern Display * grdisplay; /* The display connection */
int grscreen; /* The screen number */
Colormap grcolormap; /* The color map */
struct canvas grwindow; /* The graphics window */
@@ -68,3 +68,4 @@ unsigned long gr_pixel_rgb();
int gr_rgb_pixel();
void gr_handle_simple_event();
void gr_enqueue_char();
+void gr_init_color_cache();
diff --git a/otherlibs/graph/make_img.c b/otherlibs/graph/make_img.c
index 91bcd2694..f17d63419 100644
--- a/otherlibs/graph/make_img.c
+++ b/otherlibs/graph/make_img.c
@@ -71,6 +71,8 @@ value gr_make_image(m)
XPutPixel(imask, j, i, rgb != Transparent);
}
}
+ } else {
+ imask = NULL;
}
/* Allocate the image and store the XImages into the Pixmaps */
diff --git a/otherlibs/graph/open.c b/otherlibs/graph/open.c
index 5f9eed064..b3cdb4f07 100644
--- a/otherlibs/graph/open.c
+++ b/otherlibs/graph/open.c
@@ -21,9 +21,12 @@
#include <sys/time.h>
#endif
+Display * grdisplay = NULL;
+
static Bool gr_initialized = False;
-static int gr_error_handler(), gr_ioerror_handler();
+static int gr_error_handler();
+static int gr_ioerror_handler();
value gr_clear_graph();
value gr_open_graph(arg)
@@ -51,13 +54,15 @@ value gr_open_graph(arg)
*q = 0;
/* Open the display */
- grdisplay = XOpenDisplay(display_name);
- if (grdisplay == NULL)
- gr_fail("Cannot open display %s", XDisplayName(display_name));
- grscreen = DefaultScreen(grdisplay);
- grblack = BlackPixel(grdisplay, grscreen);
- grwhite = WhitePixel(grdisplay, grscreen);
- grcolormap = DefaultColormap(grdisplay, grscreen);
+ if (grdisplay == NULL) {
+ grdisplay = XOpenDisplay(display_name);
+ if (grdisplay == NULL)
+ gr_fail("Cannot open display %s", XDisplayName(display_name));
+ grscreen = DefaultScreen(grdisplay);
+ grblack = BlackPixel(grdisplay, grscreen);
+ grwhite = WhitePixel(grdisplay, grscreen);
+ grcolormap = DefaultColormap(grdisplay, grscreen);
+ }
/* Set up the error handlers */
XSetErrorHandler(gr_error_handler);
@@ -186,7 +191,6 @@ value gr_close_graph()
XDestroyWindow(grdisplay, grwindow.win);
XFreeGC(grdisplay, grbstore.gc);
XFreePixmap(grdisplay, grbstore.win);
- XCloseDisplay(grdisplay);
}
return Val_unit;
}
diff --git a/otherlibs/graph/text.c b/otherlibs/graph/text.c
index e9e2df057..ced7ad033 100644
--- a/otherlibs/graph/text.c
+++ b/otherlibs/graph/text.c
@@ -12,6 +12,8 @@
/* $Id$ */
#include "libgraph.h"
+#include <alloc.h>
+#include <str.h>
XFontStruct * grfont = NULL;