summaryrefslogtreecommitdiffstats
path: root/otherlibs/graph/open.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2003-04-25 12:25:21 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2003-04-25 12:25:21 +0000
commit00e105ce490f8d7afd16b7c941fdf9d06ff347a6 (patch)
tree140dd5bd411f63482aaf890b7f949316fe39f91a /otherlibs/graph/open.c
parentbf29669d3c60647880afa87097a34765f1f28afd (diff)
Pouvoir changer le nom de la fenetre avant de l'ouvrir
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5509 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/graph/open.c')
-rw-r--r--otherlibs/graph/open.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/otherlibs/graph/open.c b/otherlibs/graph/open.c
index 96c36d649..3bc034ec3 100644
--- a/otherlibs/graph/open.c
+++ b/otherlibs/graph/open.c
@@ -13,6 +13,7 @@
/* $Id$ */
+#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include "libgraph.h"
@@ -40,6 +41,7 @@ int grcolor;
extern XFontStruct * grfont;
long grselected_events;
static Bool gr_initialized = False;
+static char * window_name = NULL;
static int gr_error_handler(Display *display, XErrorEvent *error);
static int gr_ioerror_handler(Display *display);
@@ -111,7 +113,9 @@ value gr_open_graph(value arg)
XCreateSimpleWindow(grdisplay, DefaultRootWindow(grdisplay),
hints.x, hints.y, hints.width, hints.height,
BORDER_WIDTH, grblack, grbackground);
- XSetStandardProperties(grdisplay, grwindow.win, WINDOW_NAME, ICON_NAME,
+ p = window_name;
+ if (p == NULL) p = DEFAULT_WINDOW_NAME;
+ XSetStandardProperties(grdisplay, grwindow.win, p, p,
None, NULL, 0, &hints);
grwindow.gc = XCreateGC(grdisplay, grwindow.win, 0, NULL);
XSetBackground(grdisplay, grwindow.gc, grbackground);
@@ -233,12 +237,14 @@ value gr_window_id(void)
value gr_set_window_title(value n)
{
- char *s = String_val(n);
- gr_check_open();
- XStoreName(grdisplay, grwindow.win, s);
- XSetIconName(grdisplay, grwindow.win, s);
-
- XFlush(grdisplay);
+ if (window_name != NULL) stat_free(window_name);
+ window_name = stat_alloc(strlen(String_val(n)));
+ strcpy(window_name, String_val(n));
+ if (gr_initialized) {
+ XStoreName(grdisplay, grwindow.win, window_name);
+ XSetIconName(grdisplay, grwindow.win, window_name);
+ XFlush(grdisplay);
+ }
return Val_unit;
}