summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1996-09-03 08:25:04 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1996-09-03 08:25:04 +0000
commit7fb9cd28d0cfbca9c91a96fefe5a730cab3d4804 (patch)
tree4dc85ae13f3092b0348f905f7f1f99f1341bee49
parent245aadbb3704f87afb09489ffbb0bf1e827fa07a (diff)
* Ne pas fermer la connexion au display a chaque close_graph(), car
certains pixmaps peuvent etre encore vivants et ca fait n'importe quoi quand le GC les libere plus tard, alors qu'une nouvelle connexion a ete ouverte. * Ajout de quelques includes manquants. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@950 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-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;