* 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
master
Xavier Leroy 1996-09-03 08:25:04 +00:00
parent 245aadbb37
commit 7fb9cd28d0
5 changed files with 20 additions and 10 deletions

View File

@ -13,6 +13,7 @@
#include "libgraph.h"
#include "image.h"
#include <alloc.h>
#include <memory.h>
static value gr_alloc_int_vect(size)

View File

@ -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();

View File

@ -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 */

View File

@ -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;
}

View File

@ -12,6 +12,8 @@
/* $Id$ */
#include "libgraph.h"
#include <alloc.h>
#include <str.h>
XFontStruct * grfont = NULL;