[teklib-general] changeset in /hg/teklib/current: Debug messages removed; fontbug...
Timm S. Mueller
tmueller at neoscientists.org
Mon Nov 26 16:23:51 CET 2007
changeset a72c544030ac in /hg/teklib/current
details: http://teklib.org:8001/hg/teklib/current?cmd=changeset;node=a72c544030ac
description:
Debug messages removed; fontbug.c added; xft usage commented out; dlclose()
commented out; TVisualHost_GrabButton in setattrs added; minor cleanup
diffs (truncated from 318 to 300 lines):
diff -r 53f3ad93fd51 -r a72c544030ac src/visual/posix/visual_font.c
--- a/src/visual/posix/visual_font.c Mon Sep 17 23:45:58 2007 +0200
+++ b/src/visual/posix/visual_font.c Tue Sep 18 14:39:21 2007 +0200
@@ -391,8 +391,6 @@ vis_hostopenfont(TMOD_VIS *mod, TTAGITEM
{
TAPTR font = TNULL;
GLOBAL *g = mod->vis_HostGlobal;
-
- printf("%s\n", __FUNCTION__);
if (g->use_xft == TTRUE)
font = hostopenfont_xft(mod, tags);
@@ -760,14 +758,12 @@ setfont(TMOD_VIS *mod, TAPTR font)
VISUAL *v = mod->vis_HostVisual;
GLOBAL *g = mod->vis_HostGlobal;
- printf("%s\n", __FUNCTION__);
if (font)
{
if (!g->use_xft)
{
XGCValues gcv;
struct FontNode *fn = (struct FontNode *) font;
-
gcv.font = fn->font->fid;
XChangeGC(v->display, v->gc, GCFont, &gcv);
}
@@ -838,8 +834,6 @@ vis_hostclosefont(TMOD_VIS *mod, TAPTR f
GLOBAL *g = mod->vis_HostGlobal;
struct FontNode *fn = (struct FontNode *) font;
TAPTR exec = TGetExecBase(mod);
-
- printf("%s\n", __FUNCTION__);
TExecLock(exec, g->lock);
diff -r 53f3ad93fd51 -r a72c544030ac src/visual/posix/visual_host.c
--- a/src/visual/posix/visual_host.c Mon Sep 17 23:45:58 2007 +0200
+++ b/src/visual/posix/visual_host.c Tue Sep 18 14:39:21 2007 +0200
@@ -160,6 +160,7 @@ drawtext1(TMOD_VIS *mod, VISUAL *v, TINT
if (g->use_xft == TTRUE)
{
XftFont *f = ((struct FontNode *) v->curfont)->xftfont;
+
if (v->draw && f)
(*g->xftiface.XftDrawStringUtf8)(v->draw, &v->xftwhite, f, x, y + f->ascent,
(FcChar8 *)text, len);
@@ -534,11 +535,53 @@ setattrfunc(struct THook *hook, TAPTR ob
v->sizehints->max_height = (TINT) item->tti_Value;
v->sizehints->flags |= PMaxSize;
break;
+ case TVisualHost_GrabButton:
+ {
+ TINT res = -1;
+ switch (item->tti_Value)
+ {
+ case 0:
+ {
+ XUngrabButton(v->display, AnyButton, AnyModifier, v->window);
+ break;
+ }
+ case 1:
+ {
+ TUINT mask = ButtonPressMask | Button1MotionMask | ButtonReleaseMask;
+ res = XGrabButton(v->display, Button1, AnyModifier,
+ v->window, True, mask, GrabModeAsync, GrabModeSync,
+ None, None);
+ break;
+ }
+ }
+ TDBPRINTF(20,("GrabButton(%d): %d\n", item->tti_Value, res));
+ break;
+ }
+ case TVisualHost_GrabPointer:
+ {
+ TINT res = -1;
+ switch (item->tti_Value)
+ {
+ case 0:
+ {
+ XUngrabPointer(v->display, None);
+ break;
+ }
+ case 1:
+ {
+ TUINT mask = PointerMotionMask;
+ res = XGrabPointer(v->display, v->window, True, mask,
+ GrabModeAsync, GrabModeSync, None, None, None);
+ break;
+ }
+ }
+ TDBPRINTF(20,("GrabPointer(%d): %d\n", item->tti_Value, res));
+ break;
+ }
}
data->num++;
return TTRUE;
}
-
/*****************************************************************************/
@@ -1061,6 +1104,7 @@ vis_init(TMOD_VIS *mod)
if (dlerror()) break;
}
+ #if 0
if (i == LIBXFT_NUMSYMS)
{
g->use_xft = TTRUE;
@@ -1072,6 +1116,7 @@ vis_init(TMOD_VIS *mod)
TDBPRINTF(10, ("libXft initialisation failed\n"));
TDBPRINTF(10, ("defaulting to xlib based font rendering\n"));
}
+ #endif
}
else
{
@@ -1114,8 +1159,10 @@ vis_exit(TMOD_VIS *mod)
vis_hostclosefont(mod, (TAPTR)node);
}
- if (g->libxfthandle)
- dlclose(g->libxfthandle);
+ #if 0
+ if (g->libxfthandle)
+ dlclose(g->libxfthandle);
+ #endif
if (g->display)
XCloseDisplay(g->display);
@@ -1402,7 +1449,7 @@ vis_wake(TMOD_VIS *mod)
vis_wake(TMOD_VIS *mod)
{
VISUAL *v = mod->vis_HostVisual;
- char sig[1];
+ char sig = 0;
write(v->fd_sigpipe_write, &sig, 1);
}
diff -r 53f3ad93fd51 -r a72c544030ac src/visual/tests/fontbug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/visual/tests/fontbug.c Tue Sep 18 14:39:21 2007 +0200
@@ -0,0 +1,161 @@
+
+/*
+** $Id: bashing.c,v 1.3 2006/09/10 01:06:45 tmueller Exp $
+** teklib/src/visual/tests/bashing.c - Visual module unit test
+**
+** Written by Timm S. Mueller <tmueller at neoscientists.org>
+** See copyright notice in teklib/COPYRIGHT
+*/
+
+#include <math.h>
+#include <stdio.h>
+#include <tek/teklib.h>
+#include <tek/debug.h>
+#include <tek/inline/exec.h>
+#include <tek/inline/util.h>
+#include <tek/inline/time.h>
+#include <tek/proto/visual.h>
+
+TAPTR TExecBase;
+TAPTR TTimeBase;
+TAPTR TUtilBase;
+TAPTR vismod;
+
+/*****************************************************************************/
+
+#define NUMPENS 4
+
+/*****************************************************************************/
+
+TVOID fonttest(TAPTR v, TVPEN *pentab)
+{
+ TINT fh = 0;
+ TAPTR cfont = TNULL;
+ TAPTR dfont = TNULL;
+ TSTRPTR buf = "hallo";
+ TTAGITEM ftags[6];
+ static TBOOL init_done = TFALSE;
+
+ if (!init_done)
+ {
+ TAPTR fq = TNULL;
+ TTAGITEM *ctags = TNULL;
+
+ dfont = TVisualOpenFont(v, TNULL);
+
+ /* open custom font */
+ ftags[0].tti_Tag = TVisual_FontName;
+ ftags[0].tti_Value = (TTAG) "utopia";
+ ftags[1].tti_Tag = TVisual_FontPxSize;
+ ftags[1].tti_Value = (TTAG) 32;
+ ftags[2].tti_Tag = TTAG_DONE;
+ cfont = TVisualOpenFont(v, ftags);
+
+ if (dfont && cfont)
+ {
+ TVisualSetFont(v, cfont);
+
+ printf("size of text: %d\n", TVisualTextSize(v, cfont, "hallo"));
+
+// TVisualSetFont(v, dfont);
+// TVisualCloseFont(v, cfont);
+ }
+
+ init_done = TTRUE;
+ }
+
+ TVisualText(v, 30, 30, "hallo", 5, pentab[0], TVPEN_UNDEFINED);
+}
+
+/*****************************************************************************/
+/*
+** Main Program
+*/
+
+TTASKENTRY TVOID TEKMain(TAPTR task)
+{
+ TExecBase = TGetExecBase(task);
+ TUtilBase = TOpenModule("util", 0, TNULL);
+ TTimeBase = TOpenModule("time", 0, TNULL);
+
+ if (TUtilBase && TTimeBase)
+ {
+ vismod = TOpenModule("visual", 0, TNULL);
+ if (vismod)
+ {
+ TAPTR v;
+ TTAGITEM vistags[4];
+
+ vistags[0].tti_Tag = TVisual_PixWidth;
+ vistags[0].tti_Value = (TTAG) 680;
+ vistags[1].tti_Tag = TVisual_PixHeight;
+ vistags[1].tti_Value = (TTAG) 460;
+ vistags[2].tti_Tag = TVisual_Title;
+ vistags[2].tti_Value = (TTAG) "Font Test";
+ vistags[3].tti_Tag = TTAG_DONE;
+
+ v = TVisualOpen(vismod, vistags);
+
+ if (v)
+ {
+ TIMSG *imsg;
+ TBOOL abort = TFALSE;
+ TAPTR iport;
+ TINT i = 0;
+ TVPEN pentab[NUMPENS];
+
+ pentab[0] = TVisualAllocPen(v, 0xffffff);
+ pentab[1] = TVisualAllocPen(v, 0x000000);
+ pentab[2] = TVisualAllocPen(v, 0xff00ff);
+ pentab[3] = TVisualAllocPen(v, 0xff0000);
+
+ TVisualClear(v, pentab[1]);
+
+ fonttest(v, pentab);
+
+ TVisualSetInput(v, TITYPE_NONE, TITYPE_CLOSE |
+ TITYPE_COOKEDKEY | TITYPE_NEWSIZE | TITYPE_REFRESH);
+
+ iport = TVisualGetPort(v);
+
+ do
+ {
+ TWait(TGetPortSignal(iport));
+
+ while ((imsg = (TIMSG *) TGetMsg(iport)))
+ {
+ switch (imsg->timsg_Type)
+ {
+ case TITYPE_REFRESH:
+ case TITYPE_NEWSIZE:
+ TVisualClear(v, pentab[1]);
+ fonttest(v, pentab);
+ break;
+
+ case TITYPE_CLOSE:
+ abort = TTRUE;
+ break;
+
+ case TITYPE_COOKEDKEY:
+ if (imsg->timsg_Code == TKEYC_ESC)
+ abort = TTRUE;
+ break;
+ }
+ TAckMsg(imsg);
+ }
+
+ } while (!abort);
+
+ for (i = 0; i < NUMPENS; ++i)
+ TVisualFreePen(v, pentab[i]);
+
+ TVisualClose(vismod, v);
+ }
+
+ TCloseModule(vismod);
+ }
More information about the teklib-general
mailing list