[teklib-general] changeset in /hg/teklib/current: Now maintains an individual XOp...

Timm S. Mueller tmueller at neoscientists.org
Mon Nov 26 16:22:13 CET 2007


changeset b16fc54c855e in /hg/teklib/current
details: http://teklib.org:8001/hg/teklib/current?cmd=changeset;node=b16fc54c855e
description:
	Now maintains an individual XOpenDisplay() per visual again

diffs (170 lines):

diff -r 1ba5d8f0030a -r b16fc54c855e src/visual/posix/visual_host.c
--- a/src/visual/posix/visual_host.c	Sun Sep 02 22:06:24 2007 +0200
+++ b/src/visual/posix/visual_host.c	Sun Sep 02 23:07:05 2007 +0200
@@ -45,7 +45,7 @@ vis_hostopenfont(TMOD_VIS *mod, TTAGITEM
 	TSTRPTR fquery = TNULL;
 	struct FontNode *fn;
 	TAPTR exec = TGetExecBase(mod);
-	
+
 	/* fetch user specified attributes */
 	fname = (TSTRPTR) TGetTag(tags, TVisual_FontName, (TTAG) FNT_DEFNAME);
 	fpxsize = (TINT) TGetTag(tags, TVisual_FontPxSize, (TTAG) FNT_DEFPXSIZE);
@@ -89,7 +89,7 @@ vis_hostopenfont(TMOD_VIS *mod, TTAGITEM
 				font = g->fm.deffont;
 				g->fm.defref++;
 			}
-		}		
+		}
 
 		TExecUnlock(exec, g->lock);
 		TExecFree(exec, fquery);
@@ -137,7 +137,7 @@ vis_hostclosefont(TMOD_VIS *mod, TAPTR f
 		{
 			/* the font is currently used by another visual */
 			VISUAL *v = (VISUAL *) node;
-			
+
 			if (font == v->curfont)
 			{
 				TDBPRINTF(20, ("attempt to close font which is currently in use\n"));
@@ -145,14 +145,14 @@ vis_hostclosefont(TMOD_VIS *mod, TAPTR f
 			}
 		}
 	}
-	
+
 	/* free xfont */
 	if (fn->font)
 	{
 		XFreeFont(g->display, fn->font);
 		fn->font = TNULL;
 	}
-		
+
 	/* remove from openfonts list */
 	TRemove(&fn->node);
 
@@ -181,7 +181,7 @@ vis_hostgetfattrfunc(struct THook *hook,
 	struct attrdata *data = hook->thk_Data;
 	TTAGITEM *item = obj;
 	struct FontNode *fn = (struct FontNode *) data->font;
-	
+
 	switch (item->tti_Tag)
 	{
 		default:
@@ -1239,14 +1239,14 @@ vis_exit(TMOD_VIS *mod)
 	TAPTR exec = TGetExecBase(mod);
 	GLOBAL *g = mod->vis_HostGlobal;
 	struct TNode *node, *next;
-	
+
 	/* close all fonts */
 	node = g->fm.openfonts.tlh_Head;
 	for (; (next = node->tln_Succ); node = next)
 	{
 		vis_hostclosefont(mod, (TAPTR)node);
 	}
-	
+
 	if (g->display)
 		XCloseDisplay(g->display);
 
@@ -1269,7 +1269,7 @@ vis_open(TMOD_VIS *mod)
 	TInitList(&v->imsgpool);
 
 	TExecLock(exec, g->lock);
-	
+
 	for (;;)
 	{
 		XSetWindowAttributes swa;
@@ -1280,7 +1280,7 @@ vis_open(TMOD_VIS *mod)
 		struct FontNode *fn = g->fm.deffont;
 		v->curfont = fn;
 		g->fm.defref++;
-		
+
 		v->HalBase = TExecGetHALBase(TGetExecBase(mod));
 		THALInitLock(v->HalBase, &v->lock);
 
@@ -1290,9 +1290,8 @@ vis_open(TMOD_VIS *mod)
 		v->sizehints = XAllocSizeHints();
 		if (v->sizehints == TNULL) break;
 
-		//v->display = XOpenDisplay(TNULL);
-		//if (v->display == TNULL) break;
-		v->display = g->display;
+		v->display = XOpenDisplay(TNULL);
+		if (v->display == TNULL) break;
 
 		v->fd_display = ConnectionNumber(v->display);
 		if (pipe(pipefd) != 0) break;
@@ -1381,7 +1380,7 @@ vis_open(TMOD_VIS *mod)
 			GCForeground | GCBackground, v->gc);
 
 		XMapWindow(v->display, v->window);
-		
+
 #if 0
 		for (;;)
 		{
@@ -1422,7 +1421,7 @@ vis_close(TMOD_VIS *mod)
 		struct TNode *imsg;
 
 		TRemove(&v->node);
-		
+
 		while ((imsg = TRemHead(&v->imsgpool)))
 			TExecFree(TGetExecBase(mod), imsg);
 
@@ -1435,11 +1434,13 @@ vis_close(TMOD_VIS *mod)
 			XDestroyWindow(v->display, v->window);
 		if (v->colormap)
 			XFreeColormap(v->display, v->colormap);
+		if (v->display)
+			XCloseDisplay(v->display);
 		if (v->sizehints)
 			XFree(v->sizehints);
 
 		((GLOBAL *)(v->mod->vis_HostGlobal))->fm.defref--;
-		
+
 		if (v->fd_sigpipe_read != -1)
 		{
 			close(v->fd_sigpipe_read);
diff -r 1ba5d8f0030a -r b16fc54c855e src/visual/posix/visual_host.h
--- a/src/visual/posix/visual_host.h	Sun Sep 02 22:06:24 2007 +0200
+++ b/src/visual/posix/visual_host.h	Sun Sep 02 23:07:05 2007 +0200
@@ -16,7 +16,7 @@ struct FontMan
 	TAPTR deffont;				/* pointer to default font */
 	TINT defref;				/* count of references to default font */
 };
- 
+
 typedef struct
 {
 	struct TNode node;
@@ -36,7 +36,7 @@ typedef struct
 	TINT sigPending;
 
 	Display *display;
-	
+
 	int screen;
 	Visual *visual;
 	Window window;
@@ -78,9 +78,11 @@ typedef struct
 
 typedef struct
 {
+	/* display handle for global connections: */
 	Display *display;
 	struct FontMan fm;
-	struct TList vlist;			/* list of host visuals */
+	/* list of host visuals: */
+	struct TList vlist;
 	TAPTR lock;
 
 } GLOBAL;


More information about the teklib-general mailing list