From 03b772b5fe3c366a25e0ff05e37ab89bb1d7cdff Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 9 Feb 2017 11:22:41 +0100 Subject: Xserver/Imakefile: Improve readability by introducing the NULL variable and adding more line-breaks. --- nx-X11/programs/Xserver/Imakefile | 63 ++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile index 745b26154..801df5edc 100644 --- a/nx-X11/programs/Xserver/Imakefile +++ b/nx-X11/programs/Xserver/Imakefile @@ -27,6 +27,8 @@ * Server Master Makefile */ +NULL = + #include /* On most systems the linker requires the libraries in dependency order. @@ -216,14 +218,17 @@ NX_XCOMP_HEADERS = \ ../../../nxcomp/NX.h \ ../../../nxcomp/NXpack.h \ ../../../nxcomp/NXproto.h \ - ../../../nxcomp/NXvars.h + ../../../nxcomp/NXvars.h \ + $(NULL) NX_XCOMPSHAD_HEADERS = \ - ../../../nxcompshad/Shadow.h + ../../../nxcompshad/Shadow.h \ + $(NULL) NX_HEADERS = \ $(NX_XCOMP_HEADERS) \ - $(NX_XCOMPSHAD_HEADERS) + $(NX_XCOMPSHAD_HEADERS) \ + $(NULL) BuildIncludes($(NX_HEADERS),nx,..) @@ -243,7 +248,8 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXmiexpose.o \ hw/nxagent/NXresource.o \ - hw/nxagent/NXdamage.o + hw/nxagent/NXdamage.o \ + $(NULL) #elif !defined(Win32Architecture) NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXwindow.o \ @@ -260,7 +266,8 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXxvdisp.o \ hw/nxagent/NXmiexpose.o \ hw/nxagent/NXresource.o \ - hw/nxagent/NXdamage.o + hw/nxagent/NXdamage.o \ + $(NULL) #else NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXwindow.o \ @@ -278,7 +285,8 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXmiexpose.o \ hw/nxagent/NXresource.o \ hw/nxagent/NXdamage.o \ - dix/main.o + dix/main.o \ + $(NULL) #endif XPMLIB = -lXpm @@ -313,16 +321,29 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \ -lrt \ -lXcomp \ -lXcompshad \ - -lXrender -lXfixes -lXfont -lXcomposite -lXinerama -lXdmcp \ - -lNX_X11 -lXext + -lXrender \ + -lXfixes \ + -lXfont \ + -lXcomposite \ + -lXinerama \ + -lXdmcp \ + -lNX_X11 \ + -lXext \ + $(NULL) #elif defined(cygwinArchitecture) NXAGENTNXLIBS = -L../../../nxcomp \ -L../../../nx-X11/exports/lib \ -L../../../nxcompshad \ -lXcomp \ -lXcompshad \ - -lXrender -lXfixes -lXfont -lXcomposite -lXdmcp \ - -lNX_X11 -lXext + -lXrender \ + -lXfixes \ + -lXfont \ + -lXcomposite \ + -lXdmcp \ + -lNX_X11 \ + -lXext \ + $(NULL) #elif defined(OpenBSDArchitecture) NXAGENTNXLIBS = -L../../../nxcomp \ -L../../../nx-X11/exports/lib \ @@ -330,16 +351,30 @@ NXAGENTNXLIBS = -L../../../nxcomp \ -lkvm \ -lXcomp \ -lXcompshad \ - -lXrender -lXfixes -lXfont -lXcomposite -lXinerama -lXdmcp \ - -lNX_X11 -lXext + -lXrender \ + -lXfixes \ + -lXfont \ + -lXcomposite \ + -lXinerama \ + -lXdmcp \ + -lNX_X11 \ + -lXext \ + $(NULL) #else NXAGENTNXLIBS = -L../../../nxcomp \ -L../../../nx-X11/exports/lib \ -L../../../nxcompshad \ -lXcomp \ -lXcompshad \ - -lXrender -lXfixes -lXfont -lXcomposite -lXinerama -lXdmcp \ - -lNX_X11 -lXext + -lXrender \ + -lXfixes \ + -lXfont \ + -lXcomposite \ + -lXinerama \ + -lXdmcp \ + -lNX_X11 \ + -lXext \ + $(NULL) #endif #endif -- cgit v1.2.3 From 6a06a6c81047a08ba35c3c4995ae8139d355f366 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 9 Feb 2017 22:31:19 +0000 Subject: dix: Move InitFonts up above screen initialization Backport from X.org: commit 91ea0965dd4dfeba0a914c47ad4a64768e983b1b Author: Keith Packard Date: Wed Nov 11 22:02:04 2015 -0800 dix: Move InitFonts up above screen initialization Font initialization was split into two stages, the first was to set up font privates with a call to ResetFontPrivateIndex, then much later the call to InitFonts to set up all of the FPEs. Doing the full font initialization before initializing the video drivers means that we can move the call to ResetFontPrivateIndex inside InitFonts. Reviewed-by: Adam Jackson Signed-off-by: Keith Packard Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/dixfonts.c | 2 ++ nx-X11/programs/Xserver/dix/main.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index 782aa251b..e43af3bbb 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -1953,6 +1953,8 @@ InitFonts () { patternCache = MakeFontPatternCache(); + ResetFontPrivateIndex(); + register_fpe_functions(); } diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index ab8e41394..86d495466 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -261,8 +261,8 @@ main(int argc, char *argv[], char *envp[]) ResetPixmapPrivates(); #endif ResetColormapPrivates(); - ResetFontPrivateIndex(); ResetDevicePrivateIndex(); + InitFonts(); InitCallbackManager(); InitVisualWrap(); InitOutput(&screenInfo, argc, argv); @@ -294,7 +294,6 @@ main(int argc, char *argv[], char *envp[]) FatalError("failed to initialize core devices"); ReserveClientIds(serverClient); - InitFonts(); if (loadableFonts) { SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error); } else { -- cgit v1.2.3 From 523009b96bd2e479c9823267bc060f8e5b0516e8 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 14 Feb 2017 09:17:25 +0100 Subject: hw/nxagent/BitmapUtils.c: Derive from utilbitmap.c in deprecated libXfont1 and ship as copy-of-code with nxagent. --- nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c | 118 +++++++++++++++++++++++ nx-X11/programs/Xserver/hw/nxagent/Image.c | 14 +-- nx-X11/programs/Xserver/hw/nxagent/Imakefile | 2 + nx-X11/programs/Xserver/hw/nxagent/Render.c | 6 +- 4 files changed, 130 insertions(+), 10 deletions(-) create mode 100644 nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c diff --git a/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c new file mode 100644 index 000000000..b889d2a62 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c @@ -0,0 +1,118 @@ +/* + +Copyright 1990, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +/* + * Author: Keith Packard, MIT X Consortium + */ + +/* + * Derived from libXfont1's utilbitmap.c (available via fontmisc.h). + */ + +/* Utility functions for reformating font bitmaps */ + +static const unsigned char _reverse_byte[0x100] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +/* + * Invert bit order within each BYTE of an array. + */ +void +nxagentBitOrderInvert(unsigned char *buf, int nbytes) +{ + const unsigned char *rev = _reverse_byte; + + for (; --nbytes >= 0; buf++) + *buf = rev[*buf]; +} + +/* + * Invert byte order within each 16-bits of an array. + */ +void +nxagentTwoByteSwap(unsigned char *buf, int nbytes) +{ + unsigned char c; + + for (; nbytes > 0; nbytes -= 2, buf += 2) + { + c = buf[0]; + buf[0] = buf[1]; + buf[1] = c; + } +} + +/* + * Invert byte order within each 32-bits of an array. + */ +void +nxagentFourByteSwap(unsigned char *buf, int nbytes) +{ + unsigned char c; + + for (; nbytes > 0; nbytes -= 4, buf += 4) + { + c = buf[0]; + buf[0] = buf[3]; + buf[3] = c; + c = buf[1]; + buf[1] = buf[2]; + buf[2] = c; + } +} + diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index 4fa98f842..590f0b249 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -98,9 +98,9 @@ int nxagentAlphaCompat = 0; * displays having different byte order. */ -extern void BitOrderInvert(unsigned char *, int); -extern void TwoByteSwap(unsigned char *, register int); -extern void FourByteSwap(register unsigned char *, register int); +extern void nxagentBitOrderInvert(unsigned char *, int); +extern void nxagentTwoByteSwap(unsigned char *, register int); +extern void nxagentFourByteSwap(register unsigned char *, register int); /* * Store the last visual used to unpack @@ -206,7 +206,7 @@ int nxagentImageReformat(char *base, int nbytes, int bpp, int order) "bits per pixel [%d] byte order [%d].\n", nbytes, bpp, order); #endif - BitOrderInvert((unsigned char *) base, nbytes); + nxagentBitOrderInvert((unsigned char *) base, nbytes); } #if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8 @@ -231,7 +231,7 @@ int nxagentImageReformat(char *base, int nbytes, int bpp, int order) "bits per pixel [%d] byte order [%d].\n", nbytes, bpp, order); #endif - TwoByteSwap((unsigned char *) base, nbytes); + nxagentTwoByteSwap((unsigned char *) base, nbytes); } break; @@ -245,7 +245,7 @@ int nxagentImageReformat(char *base, int nbytes, int bpp, int order) "bits per pixel [%d] byte order [%d].\n", nbytes, bpp, order); #endif - FourByteSwap((unsigned char *) base, nbytes); + nxagentFourByteSwap((unsigned char *) base, nbytes); } break; @@ -1152,7 +1152,7 @@ FIXME: Should use an unpack resource here. #ifdef TEST fprintf(stderr, "nxagentPutSubImage: Display image order is [%d] bitmap order is [%d].\n", - ImageByteOrder(nxagentDisplay), BitmapBitOrder(nxagentDisplay)); + ImageByteOrder(nxagentDisplay), nxagentBitmapBitOrder(nxagentDisplay)); #endif /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index 8ac016aea..e9e076e0a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -26,6 +26,7 @@ SRCS = \ NXmitrap.c \ Args.c \ Binder.c \ + BitmapUtils.c \ Colormap.c \ Cursor.c \ Dialog.c \ @@ -87,6 +88,7 @@ OBJS = \ NXmitrap.o \ Args.o \ Binder.o \ + BitmapUtils.o \ Colormap.o \ Cursor.o \ Dialog.o \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index 3193e01f5..bab6b7989 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -132,10 +132,10 @@ static void nxagentPrintFormat(XRenderPictFormat *pFormat); extern const CARD8 glyphDepths[]; /* - * From NXdispatch.c. + * From BitmapUtils.c. */ -extern void BitOrderInvert(unsigned char *data, int nbytes); +extern void nxagentBitOrderInvert(unsigned char *data, int nbytes); /* * Other functions defined here. @@ -2266,7 +2266,7 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, if (glyphDepths[glyphSet -> fdepth] == 1 && nxagentServerOrder() != BitmapBitOrder(nxagentDisplay)) { - BitOrderInvert ((unsigned char *) normalizedImages, sizeImages); + nxagentBitOrderInvert ((unsigned char *) normalizedImages, sizeImages); } } else -- cgit v1.2.3 From 4768662b03067afbc122683d234205716ba3606e Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 16 Feb 2017 08:21:56 +0000 Subject: dix: pass a valid ClientPtr to SetFontPath in all cases. Backported from X.org: commit 7e9e01a4a34fa45521067d43c5bbff942dd5d51a Author: Eamon Walsh Date: Wed Oct 10 17:40:22 2007 -0400 dix: pass a valid ClientPtr to SetFontPath in all cases. Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 86d495466..745ca14e8 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -295,7 +295,7 @@ main(int argc, char *argv[], char *envp[]) ReserveClientIds(serverClient); if (loadableFonts) { - SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error); + SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath, &error); } else { if (SetDefaultFontPath(defaultFontPath) != Success) ErrorF("failed to set default font path '%s'\n", -- cgit v1.2.3 From f743f9f743362c891f049a514cdcf3d39546194b Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Thu, 16 Feb 2017 08:19:40 +0000 Subject: SetFontPath: set client->errorValue on failure. Backported from X.org: commit 21ceae9002c6364deb3d074cf2da7d3864cf6879 Author: Jamey Sharp Date: Tue May 11 10:24:00 2010 -0700 SetFontPath: set client->errorValue on failure. Previously the callers were only setting errorValue on Success, when it's ignored, and leaving it alone on failure, when it's sent to the client. Since SetFontPath takes the ClientPtr, let it set client->errorValue instead of letting the callers continue to get it wrong. Signed-off-by: Jamey Sharp Reviewed-by: Julien Cristau Signed-off-by: Keith Packard Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/dispatch.c | 7 +------ nx-X11/programs/Xserver/dix/dixfonts.c | 7 ++++--- nx-X11/programs/Xserver/dix/main.c | 2 +- nx-X11/programs/Xserver/include/dixfont.h | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 8294a583a..1016e6eae 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -3364,7 +3364,6 @@ ProcSetFontPath(register ClientPtr client) unsigned long nbytes, total; long nfonts; int n, result; - int error; REQUEST(xSetFontPathReq); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); @@ -3382,13 +3381,9 @@ ProcSetFontPath(register ClientPtr client) } if (total >= 4) return(BadLength); - result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1], - &error); + result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1]); if (!result) - { result = client->noClientException; - client->errorValue = error; - } return (result); } diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index e43af3bbb..18f2e7877 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -1805,9 +1805,8 @@ bail: return FontToXError(err); } -/* XXX -- do we need to pass error down to each renderer? */ int -SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) +SetFontPath(ClientPtr client, int npaths, unsigned char *paths) { int err = Success; @@ -1815,7 +1814,9 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) if (SetDefaultFontPath(defaultFontPath) != Success) return BadValue; } else { - err = SetFontPathElements(npaths, paths, error, FALSE); + int bad; + err = SetFontPathElements(npaths, paths, &bad, FALSE); + client->errorValue = bad; } return err; } diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 745ca14e8..384b6f9b6 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -295,7 +295,7 @@ main(int argc, char *argv[], char *envp[]) ReserveClientIds(serverClient); if (loadableFonts) { - SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath, &error); + SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath); } else { if (SetDefaultFontPath(defaultFontPath) != Success) ErrorF("failed to set default font path '%s'\n", diff --git a/nx-X11/programs/Xserver/include/dixfont.h b/nx-X11/programs/Xserver/include/dixfont.h index 6149d2160..004acefbf 100644 --- a/nx-X11/programs/Xserver/include/dixfont.h +++ b/nx-X11/programs/Xserver/include/dixfont.h @@ -100,8 +100,7 @@ extern int ImageText(ClientPtr /*client*/, extern int SetFontPath(ClientPtr /*client*/, int /*npaths*/, - unsigned char * /*paths*/, - int * /*error*/); + unsigned char * /*paths*/); extern int SetDefaultFontPath(char * /*path*/); -- cgit v1.2.3 From f4c80a78ce0e5648334fc43e5c93a068ed3ec5be Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 9 Feb 2017 14:05:57 +0100 Subject: Xserver: Support building against libXfont2 (v2) API and old libXfont(1) API alike. Fixes ArcticaProject/nx-libs#296. Inspired by the following X.org commit. Other than X.org, we will continue support for building nx-libs against libXfont1 for a while. commit 05a793f5b3c40747d5a92a076def7f4fb673c7e7 Author: Keith Packard Date: Tue Sep 1 18:50:55 2015 -0700 dix: Switch to the libXfont2 API (v2) This new libXfont API eliminates exposing internal X server symbols to the font library, replacing those with a struct full of the entire API needed to use that library. v2: Use libXfont2 instead of libXfont_2 Signed-off-by: Keith Packard Reviewed-by: Adam Jackson --- nx-X11/config/cf/Imake.tmpl | 3 + nx-X11/config/cf/Server.tmpl | 8 + nx-X11/config/cf/host.def | 6 + nx-X11/config/cf/xorg.cf | 4 + nx-X11/programs/Xserver/Imakefile | 8 +- nx-X11/programs/Xserver/Xext/Imakefile | 2 +- nx-X11/programs/Xserver/Xext/xf86bigfont.c | 12 + nx-X11/programs/Xserver/dix/Imakefile | 4 +- nx-X11/programs/Xserver/dix/dispatch.c | 9 + nx-X11/programs/Xserver/dix/dixfonts.c | 369 +++++++++++++++++++++++- nx-X11/programs/Xserver/dix/main.c | 10 + nx-X11/programs/Xserver/hw/nxagent/Font.c | 13 + nx-X11/programs/Xserver/hw/nxagent/Imakefile | 6 +- nx-X11/programs/Xserver/hw/nxagent/Init.c | 5 + nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 106 ++++++- nx-X11/programs/Xserver/include/dixfont.h | 36 ++- nx-X11/programs/Xserver/include/dixfontstr.h | 3 + nx-X11/programs/Xserver/mi/Imakefile | 3 + nx-X11/programs/Xserver/mi/miglblt.c | 12 +- nx-X11/programs/Xserver/miext/damage/Imakefile | 2 + nx-X11/programs/Xserver/miext/damage/damage.c | 9 + nx-X11/programs/Xserver/os/Imakefile | 2 +- nx-X11/programs/Xserver/os/utils.c | 9 + 23 files changed, 621 insertions(+), 20 deletions(-) diff --git a/nx-X11/config/cf/Imake.tmpl b/nx-X11/config/cf/Imake.tmpl index 944af2fdc..9ca1f16d7 100644 --- a/nx-X11/config/cf/Imake.tmpl +++ b/nx-X11/config/cf/Imake.tmpl @@ -564,6 +564,9 @@ X_BYTE_ORDER = ByteOrder #ifndef HasFfs #define HasFfs YES #endif +#ifndef HasXfont2 +#define HasXfont2 NO +#endif #ifndef GzipLibrary /* if OS config didn't define it, assume it's -lz */ #define GzipLibrary -lz #endif diff --git a/nx-X11/config/cf/Server.tmpl b/nx-X11/config/cf/Server.tmpl index ffdca6811..bae6f3b02 100644 --- a/nx-X11/config/cf/Server.tmpl +++ b/nx-X11/config/cf/Server.tmpl @@ -70,3 +70,11 @@ GLX_DEFINES = GlxDefines #ifdef XorgVersion #include #endif + +#if HasXfont2 +FONT_DEFINES = -DHAS_XFONT2 + XFONTLIB = -lXfont2 +#else +FONT_DEFINES = + XFONTLIB = -lXfont +#endif diff --git a/nx-X11/config/cf/host.def b/nx-X11/config/cf/host.def index ffcf4c0de..4b22042c4 100644 --- a/nx-X11/config/cf/host.def +++ b/nx-X11/config/cf/host.def @@ -389,6 +389,12 @@ #define BuildXKB YES #define BuildXKBlib YES +/* + * If you want to build against libXfont2, rather than libXfont(1), uncomment this. + * +#define HasXfont2 YES + */ + /* * If you are running NetBSD 0.9C or later, and have the aperture driver * installed, uncomment this. diff --git a/nx-X11/config/cf/xorg.cf b/nx-X11/config/cf/xorg.cf index ddc501978..1aa7daf06 100644 --- a/nx-X11/config/cf/xorg.cf +++ b/nx-X11/config/cf/xorg.cf @@ -424,6 +424,10 @@ IPLAN2P8_DEFS = -DUSE_IPLAN2P8 # define BuildXKBlib YES #endif +#ifndef HasXfont2 +# define HasXfont2 NO +#endif + #ifndef BuildScreenSaverExt # define BuildScreenSaverExt YES #endif diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile index 801df5edc..e5dfa9320 100644 --- a/nx-X11/programs/Xserver/Imakefile +++ b/nx-X11/programs/Xserver/Imakefile @@ -323,7 +323,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \ -lXcompshad \ -lXrender \ -lXfixes \ - -lXfont \ + $(XFONTLIB) \ -lXcomposite \ -lXinerama \ -lXdmcp \ @@ -338,7 +338,7 @@ NXAGENTNXLIBS = -L../../../nxcomp \ -lXcompshad \ -lXrender \ -lXfixes \ - -lXfont \ + $(XFONTLIB) \ -lXcomposite \ -lXdmcp \ -lNX_X11 \ @@ -353,7 +353,7 @@ NXAGENTNXLIBS = -L../../../nxcomp \ -lXcompshad \ -lXrender \ -lXfixes \ - -lXfont \ + $(XFONTLIB) \ -lXcomposite \ -lXinerama \ -lXdmcp \ @@ -368,7 +368,7 @@ NXAGENTNXLIBS = -L../../../nxcomp \ -lXcompshad \ -lXrender \ -lXfixes \ - -lXfont \ + $(XFONTLIB) \ -lXcomposite \ -lXinerama \ -lXdmcp \ diff --git a/nx-X11/programs/Xserver/Xext/Imakefile b/nx-X11/programs/Xserver/Xext/Imakefile index becc7b66e..44a0f068a 100644 --- a/nx-X11/programs/Xserver/Xext/Imakefile +++ b/nx-X11/programs/Xserver/Xext/Imakefile @@ -119,7 +119,7 @@ LintLibraryTarget(ext,$(SRCS)) NormalLintTarget($(SRCS)) #if BuildXF86BigfontExt -SpecialCObjectRule(xf86bigfont,$(ICONFIGFILES),$(SHM_DEFINES)) +SpecialCObjectRule(xf86bigfont,$(ICONFIGFILES),$(SHM_DEFINES) $(FONT_DEFINES)) #endif #if BuildXCSecurity SpecialCObjectRule(security,$(ICONFIGFILES),$(POLICYFILEDEF)) diff --git a/nx-X11/programs/Xserver/Xext/xf86bigfont.c b/nx-X11/programs/Xserver/Xext/xf86bigfont.c index 4c8f02c2c..d8cae74ef 100644 --- a/nx-X11/programs/Xserver/Xext/xf86bigfont.c +++ b/nx-X11/programs/Xserver/Xext/xf86bigfont.c @@ -75,6 +75,10 @@ #define _XF86BIGFONT_SERVER_ #include +#ifdef HAS_XFONT2 +# include +#endif /* HAS_XFONT2 */ + static void XF86BigfontResetProc( ExtensionEntry * /* extEntry */ ); @@ -186,7 +190,11 @@ XFree86BigfontExtensionInit() + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ +#ifdef HAS_XFONT2 + FontShmdescIndex = xfont2_allocate_font_private_index(); +#else FontShmdescIndex = AllocateFontPrivateIndex(); +#endif /* HAS_XFONT2 */ #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; @@ -526,7 +534,11 @@ ProcXF86BigfontQueryFont( #ifdef HAS_SHM if (pDesc && !badSysCall) { *(CARD32 *)(pCI + nCharInfos) = signature; +#ifdef HAS_XFONT2 + if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) { +#else if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { +#endif /* HAS_XFONT2 */ shmdealloc(pDesc); return BadAlloc; } diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile index 1024de965..49722da00 100644 --- a/nx-X11/programs/Xserver/dix/Imakefile +++ b/nx-X11/programs/Xserver/dix/Imakefile @@ -133,7 +133,9 @@ LintLibraryTarget(dix,$(SRCS) $(XPSRC)) NormalLintTarget($(SRCS) $(XPSRC)) SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES)) -SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES)) +SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES) $(FONT_DEFINES)) +SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(dixfonts,$(ICONFIGFILES),$(FONT_DEFINES)) SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES)) diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 1016e6eae..51468f1c7 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -86,6 +86,11 @@ int ProcInitialConnection(); #include "windowstr.h" #include +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS_XFONT2 */ #include "dixfontstr.h" #include "gcstruct.h" #include "selection.h" @@ -1399,7 +1404,11 @@ ProcQueryTextExtents(register ClientPtr client) return(BadLength); length--; } +#ifdef HAS_XFONT2 + if (!xfont2_query_text_extents(pFont, length, (unsigned char *)&stuff[1], &info)) +#else if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info)) +#endif /* HAS_XFONT2 */ return(BadAlloc); reply.type = X_Reply; reply.length = 0; diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index 18f2e7877..98d2a6439 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -59,10 +59,14 @@ Equipment Corporation. #include "resource.h" #include "dixstruct.h" #include "cursorstr.h" +#include "list.h" #include "misc.h" #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" +#ifdef HAS_XFONT2 +# include +#endif /* HAS_XFONT2 */ #ifdef DEBUG #include @@ -79,14 +83,20 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics +#ifndef HAS_XFONT2 extern void register_fpe_functions(void); +#endif extern void * fosNaturalParams; extern FontPtr defaultFont; static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; +#ifdef HAS_XFONT2 +xfont2_fpe_funcs_rec const **fpe_functions; +#else FPEFunctions *fpe_functions = (FPEFunctions *) 0; +#endif static int num_fpe_types = 0; static unsigned char *font_path_string; @@ -94,7 +104,11 @@ static unsigned char *font_path_string; static int num_slept_fpes = 0; static int size_slept_fpes = 0; static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; +#ifdef HAS_XFONT2 +xfont2_pattern_cache_ptr patternCache; +#else static FontPatternCachePtr patternCache; +#endif /* HAS_FONT2 */ int FontToXError(err) @@ -205,7 +219,11 @@ FontWakeup(void * data, int count, void * LastSelectMask) /* wake up any fpe's that may be waiting for information */ for (i = 0; i < num_slept_fpes; i++) { fpe = slept_fpes[i]; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); +#else (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); +#endif /* HAS_XFONT2 */ } } @@ -221,7 +239,11 @@ FreeFPE (FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->free_fpe) (fpe); +#else (*fpe_functions[fpe->type].free_fpe) (fpe); +#endif free(fpe->name); free(fpe); } @@ -276,14 +298,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->open_font) +#else err = (*fpe_functions[fpe->type].open_font) +#endif /* HAS_XFONT2 */ ((void *) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -361,7 +391,11 @@ doOpenFont(ClientPtr client, OFclosurePtr c) goto bail; } if (patternCache && pfont != c->non_cachable_font) +#ifdef HAS_XFONT2 + xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, +#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, +#endif /* HAS_XFONT2 */ pfont); bail: if (err != Successful && c->client != serverClient) { @@ -417,7 +451,11 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna ** having to create another instance of a font that already exists. */ +#ifdef HAS_XFONT2 + cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); +#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); +#endif /* HAS_XFONT2 */ if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (void *) cached)) @@ -482,7 +520,11 @@ CloseFont(void * value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) +#ifdef HAS_XFONT2 + xfont2_remove_cached_font_pattern(patternCache, pfont); +#else RemoveCachedFontPattern (patternCache, pfont); +#endif /* HAS_XFONT2 */ /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -498,7 +540,11 @@ CloseFont(void * value, XID fid) XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->close_font) (fpe, pfont); +#else (*fpe_functions[fpe->type].close_font) (fpe, pfont); +#endif FreeFPE(fpe); } return (Success); @@ -597,7 +643,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -610,11 +660,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef HAS_XFONT2 + if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ { /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_fonts) +#else err = (*fpe_functions[fpe->type].list_fonts) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -643,7 +701,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -662,7 +724,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { char *tmpname; name = 0; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else err = (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -687,11 +753,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->haveSaved) { if (c->savedName) +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, c->savedName, +#else (void)AddFontNamesName(c->names, c->savedName, +#endif /* HAS_XFONT2 */ c->savedNameLen); } else +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, name, namelen); +#else (void)AddFontNamesName(c->names, name, namelen); +#endif /* HAS_XFONT2 */ } /* @@ -716,7 +790,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else (void) (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) @@ -827,7 +905,11 @@ bail: FreeFPE(c->fpe_list[i]); free(c->fpe_list); if (c->savedName) free(c->savedName); +#ifdef HAS_XFONT2 + xfont2_free_font_names(names); +#else FreeFontNames(names); +#endif /* HAS_XFONT2 */ free(c); if (resolved) free(resolved); return TRUE; @@ -857,7 +939,11 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } +#ifdef HAS_XFONT2 + c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); +#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); +#endif /* HAS_XFONT2 */ if (!c->names) { free(c->fpe_list); @@ -905,7 +991,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -919,7 +1009,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) err = Successful; if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) +#else err = (*fpe_functions[fpe->type].start_list_fonts_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) @@ -938,7 +1032,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) { name = 0; pFontInfo = &fontInfo; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_with_info) +#else err = (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) @@ -975,7 +1073,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#else + (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) @@ -1175,7 +1277,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ if (c->slept) { @@ -1203,7 +1309,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ c->pDraw = (DrawablePtr)0; } @@ -1480,7 +1590,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif err = Success; goto bail; } @@ -1494,7 +1608,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ err = Success; goto bail; } @@ -1642,7 +1760,11 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { +#ifdef HAS_XFONT2 + if ((*fpe_functions[i]->name_check) (pathname)) +#else if ((*fpe_functions[i].name_check) (pathname)) +#endif /* HAS_XFONT2 */ return i; } return -1; @@ -1706,8 +1828,13 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { +#ifdef HAS_XFONT2 + if (fpe_functions[i]->set_path_hook) + (*fpe_functions[i]->set_path_hook) (); +#else if (fpe_functions[i].set_path_hook) (*fpe_functions[i].set_path_hook) (); +#endif /* HAS_XFONT2 */ } for (i = 0; i < npaths; i++) { @@ -1729,7 +1856,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].reset_fpe) (fpe); +#endif /* HAS_XFONT2 */ if (err == Successful) { UseFPE(fpe);/* since it'll be decref'd later when freed @@ -1763,7 +1894,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->init_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].init_fpe) (fpe); +#endif /* HAS_XFONT2 */ if (err != Successful) { #ifndef NXAGENT_SERVER @@ -1793,7 +1928,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) +#ifdef HAS_XFONT2 + xfont2_empty_font_pattern_cache(patternCache); +#else EmptyFontPatternCache(patternCache); +#endif /* HAS_XFONT2 */ num_fpes = valid_paths; return Success; @@ -1928,13 +2067,35 @@ GetFontPath(int *count, int *length) int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { +#ifdef HAS_XFONT2 + if (fpe_functions[pfont->fpe->type]->load_glyphs) + return (*fpe_functions[pfont->fpe->type]->load_glyphs) +#else if (fpe_functions[pfont->fpe->type].load_glyphs) return (*fpe_functions[pfont->fpe->type].load_glyphs) +#endif (client, pfont, 0, nchars, item_size, data); else return Successful; } +void +#ifdef HAS_XFONT2 +GetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount, /* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ +#else +dixGetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount, /* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ +#endif /* HAS_XFONT2 */ + { + (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); + } + + void DeleteClientFontStuff(ClientPtr client) { @@ -1944,11 +2105,33 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; +#ifdef HAS_XFONT2 + if (fpe_functions[fpe->type]->client_died) + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else if (fpe_functions[fpe->type].client_died) (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } } +#ifdef HAS_XFONT2 +static int +register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs) +{ + xfont2_fpe_funcs_rec const **new; + + /* grow the list */ + new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(xfont2_fpe_funcs_ptr)); + if (!new) + return -1; + fpe_functions = new; + + fpe_functions[num_fpe_types] = funcs; + + return num_fpe_types++; +} +#else void InitFonts () { @@ -1958,16 +2141,38 @@ InitFonts () register_fpe_functions(); } +#endif /* HAS_XFONT2 */ +#ifdef HAS_XFONT2 +static unsigned long +get_server_generation(void) +{ + return serverGeneration; +} + +static void * +get_server_client(void) +{ + return serverClient; +} + +static int +get_default_point_size(void) +#else int GetDefaultPointSize () +#endif /* HAS_XFONT2 */ { return 120; } - +#ifdef HAS_XFONT2 +static FontResolutionPtr +get_client_resolutions(int *num) +#else FontResolutionPtr GetClientResolutions (int *num) +#endif /* HAS_XFONT2 */ { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) @@ -1999,6 +2204,7 @@ GetClientResolutions (int *num) } } +#ifndef HAS_XFONT2 /* * returns the type index of the new fpe * @@ -2053,12 +2259,17 @@ RegisterFPEFunctions(NameCheckFunc name_func, return num_fpe_types++; } +#endif /* !HAS_XFONT2 */ void FreeFonts() { if (patternCache) { +#ifdef HAS_XFONT2 + xfont2_free_font_pattern_cache(patternCache); +#else FreeFontPatternCache(patternCache); +#endif /* HAS_XFONT2 */ patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); @@ -2066,11 +2277,18 @@ FreeFonts() num_fpes = 0; free(fpe_functions); num_fpe_types = 0; +#ifdef HAS_XFONT2 + fpe_functions = NULL; +#else fpe_functions = (FPEFunctions *) 0; +#endif /* HAS_XFONT2 */ } /* convenience functions for FS interface */ +#ifdef HAS_XFONT2 +static +#endif /* HAS_XFONT2 */ FontPtr find_old_font(XID id) { @@ -2078,26 +2296,46 @@ find_old_font(XID id) DixUnknownAccess); } +#ifdef HAS_XFONT2 +static Font +get_new_font_client_id(void) +#else Font GetNewFontClientID() +#endif /* HAS_XFONT2 */ { return FakeClientID(0); } +#ifdef HAS_XFONT2 +static int +store_font_Client_font(FontPtr pfont, Font id) +#else int StoreFontClientFont(FontPtr pfont, Font id) +#endif /* HAS_XFONT2 */ { return AddResource(id, RT_NONE, (void *) pfont); } +#ifdef HAS_XFONT2 +static void +delete_font_client_id(Font id) +#else void DeleteFontClientID(Font id) +#endif /* HAS_XFONT2 */ { FreeResource(id, RT_NONE); } +#ifdef HAS_XFONT2 +static int +_client_auth_generation(ClientPtr client) +#else int client_auth_generation(ClientPtr client) +#endif /* HAS_XFONT2 */ { return 0; } @@ -2105,8 +2343,78 @@ client_auth_generation(ClientPtr client) static int fs_handlers_installed = 0; static unsigned int last_server_gen; +#ifdef HAS_XFONT2 +static void +fs_block_handler(void *blockData, OSTimePtr timeout, void *readmask) +{ + FontBlockHandlerProcPtr block_handler = blockData; + + (*block_handler)(timeout); +} + +struct fs_fd_entry { + struct xorg_list entry; + int fd; + void *data; + FontFdHandlerProcPtr handler; +}; + +static void +fs_fd_handler(int fd, int ready, void *data) +{ + struct fs_fd_entry *entry = data; + + entry->handler(fd, entry->data); +} + +static struct xorg_list fs_fd_list; + +static int +add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data) +{ + struct fs_fd_entry *entry = calloc(1, sizeof (struct fs_fd_entry)); + + if (!entry) + return FALSE; + + entry->fd = fd; + entry->data = data; + entry->handler = handler; + if (!SetNotifyFd(fd, fs_fd_handler, X_NOTIFY_READ, entry)) { + free(entry); + return FALSE; + } + xorg_list_add(&entry->entry, &fs_fd_list); + return TRUE; +} + +static void +remove_fs_fd(int fd) +{ + struct fs_fd_entry *entry, *temp; + + xorg_list_for_each_entry_safe(entry, temp, &fs_fd_list, entry) { + if (entry->fd == fd) { + xorg_list_del(&entry->entry); + free(entry); + break; + } + } + RemoveNotifyFd(fd); +} + +static void +adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) +{ + AdjustWaitForDelay(wt, newdelay); +} + +static int +_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) +#else int init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) +#endif /* HAS_XFONT2 */ { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2119,17 +2427,30 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) fprintf(stderr, "adding FS b & w handlers\n"); #endif +#ifdef HAS_XFONT2 + if (!RegisterBlockAndWakeupHandlers(fs_block_handler, + FontWakeup, (void *) block_handler)) +#else if (!RegisterBlockAndWakeupHandlers(block_handler, FontWakeup, (void *) 0)) +#endif /* HAS_XFONT2 */ return AllocError; +#ifdef HAS_XFONT2 + xorg_list_init(&fs_fd_list); +#endif /* HAS_XFONT2 */ fs_handlers_installed++; } QueueFontWakeup(fpe); return Successful; } +#ifdef HAS_XFONT2 +static void +_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, Bool all) +#else void remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) +#endif /* HAS_XFONT2 */ { if (all) { /* remove the handlers if no one else is using them */ @@ -2139,13 +2460,57 @@ remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bo fprintf(stderr, "removing FS b & w handlers\n"); #endif +#ifdef HAS_XFONT2 + RemoveBlockAndWakeupHandlers(fs_block_handler, FontWakeup, + (void *) block_handler); +#else RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (void *) 0); +#endif /* HAS_XFONT2 */ } } RemoveFontWakeup(fpe); } +#ifdef HAS_XFONT2 +static const xfont2_client_funcs_rec xfont2_client_funcs = { + .version = XFONT2_CLIENT_FUNCS_VERSION, + .client_auth_generation = _client_auth_generation, + .client_signal = ClientSignal, + .delete_font_client_id = delete_font_client_id, + .verrorf = VErrorF, + .find_old_font = find_old_font, + .get_client_resolutions = get_client_resolutions, + .get_default_point_size = get_default_point_size, + .get_new_font_client_id = get_new_font_client_id, + .get_time_in_millis = GetTimeInMillis, + .init_fs_handlers = _init_fs_handlers, + .register_fpe_funcs = register_fpe_funcs, + .remove_fs_handlers = _remove_fs_handlers, + .get_server_client = get_server_client, + .set_font_authorizations = set_font_authorizations, + .store_font_client_font = store_font_Client_font, + .make_atom = MakeAtom, + .valid_atom = ValidAtom, + .name_for_atom = NameForAtom, + .get_server_generation = get_server_generation, + .add_fs_fd = add_fs_fd, + .remove_fs_fd = remove_fs_fd, + .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, +}; + +xfont2_pattern_cache_ptr fontPatternCache; + +void +InitFonts(void) +{ + if (fontPatternCache) + xfont2_free_font_pattern_cache(fontPatternCache); + fontPatternCache = xfont2_make_font_pattern_cache(); + xfont2_init(&xfont2_client_funcs); +} +#endif /* HAS_XFONT2 */ + #ifdef DEBUG #define GLWIDTHBYTESPADDED(bits,nbytes) \ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 384b6f9b6..3f3c079e4 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -95,6 +95,12 @@ Equipment Corporation. #include "colormapst.h" #include "cursorstr.h" #include +#include +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS_XFONT2 */ #include "opaque.h" #include "servermd.h" #include "site.h" @@ -252,7 +258,11 @@ main(int argc, char *argv[], char *envp[]) InitAtoms(); InitEvents(); +#ifdef HAS_XFONT2 + xfont2_init_glyph_caching(); +#else InitGlyphCaching(); +#endif /* of HAS_XFONT2 */ ResetClientPrivates(); ResetScreenPrivates(); ResetWindowPrivates(); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index e1f12e733..f9c682765 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -41,6 +41,7 @@ is" without express or implied warranty. #include "dixstruct.h" #include #include +#include "dixfontstr.h" #include "misc.h" #include "miscstruct.h" #include "opaque.h" @@ -495,7 +496,11 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) const char *name; char *origName = (char*) pScreen; +#ifdef HAS_XFONT2 + xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL); +#else FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL); +#endif /* HAS_XFONT2 */ if (requestingClient && XpClientIsPrintClient(requestingClient, NULL)) return True; @@ -540,7 +545,11 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) } priv = (void *)malloc(sizeof(nxagentPrivFont)); +#ifdef HAS_XFONT2 + xfont2_font_set_private(pFont, nxagentFontPrivateIndex, priv); +#else FontSetPrivate(pFont, nxagentFontPrivateIndex, priv); +#endif /* HAS_XFONT2 */ nxagentFontPriv(pFont) -> mirrorID = 0; @@ -688,7 +697,11 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) FreeResource(nxagentFontPriv(pFont) -> mirrorID, RT_NONE); free(nxagentFontPriv(pFont)); +#ifdef HAS_XFONT2 + xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL); +#else FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL); +#endif /* HAS_XFONT2 */ } return True; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index e9e076e0a..e9175df72 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -257,7 +257,11 @@ all:: $(OBJS) LinkSourceFile(stubs.c,$(SERVERSRC)/Xi) LinkSourceFile(xpstubs.c,$(SERVERSRC)/dix) -SpecialCObjectRule(Init,$(ICONFIGFILES),$(_NOOP_)) +SpecialCObjectRule(Init,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(Font,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(NXdamage,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(NXdispatch,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(NXdixfonts,$(ICONFIGFILES),$(FONT_DEFINES)) LinkSourceFile(miinitext.c,$(SERVERSRC)/mi) SpecialCObjectRule(miinitext,$(ICONFIGFILES), $(_NOOP_)) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 014ab17f9..a35e3d5a8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -51,6 +51,7 @@ is" without express or implied warranty. #include "servermd.h" #include "mi.h" #include +#include "dixfontstr.h" #include "Agent.h" #include "Display.h" @@ -367,7 +368,11 @@ FIXME: These variables, if not removed at all because have probably nxagentWindowPrivateIndex = AllocateWindowPrivateIndex(); nxagentGCPrivateIndex = AllocateGCPrivateIndex(); RT_NX_GC = CreateNewResourceType(nxagentDestroyNewGCResourceType); +#ifdef HAS_XFONT2 + nxagentFontPrivateIndex = xfont2_allocate_font_private_index(); +#else nxagentFontPrivateIndex = AllocateFontPrivateIndex(); +#endif /* HAS_XFONT2 */ RT_NX_FONT = CreateNewResourceType(nxagentDestroyNewFontResourceType); nxagentClientPrivateIndex = AllocateClientPrivateIndex(); nxagentPixmapPrivateIndex = AllocatePixmapPrivateIndex(); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index 1b7ce114b..49d864887 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -210,14 +210,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->open_font) +#else err = (*fpe_functions[fpe->type].open_font) +#endif /* HAS_XFONT2 */ ((void *) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -314,7 +322,11 @@ doOpenFont(ClientPtr client, OFclosurePtr c) } } if (patternCache && pfont != c->non_cachable_font) +#ifdef HAS_XFONT2 + xfont2_cache_font_pattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen, +#else CacheFontPattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen, +#endif /* HAS_XFONT2 */ pfont); bail: if (err != Successful && c->client != serverClient) { @@ -359,7 +371,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -372,11 +388,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef HAS_XFONT2 + if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ { /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_fonts) +#else err = (*fpe_functions[fpe->type].list_fonts) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -408,7 +432,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -427,7 +455,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { char *tmpname; name = 0; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else err = (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -458,11 +490,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->haveSaved) { if (c->savedName) +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, c->savedName, +#else (void)AddFontNamesName(c->names, c->savedName, +#endif /* HAS_XFONT2 */ c->savedNameLen); } else +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, name, namelen); +#else (void)AddFontNamesName(c->names, name, namelen); +#endif /* HAS_XFONT2 */ } /* @@ -487,7 +527,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else (void) (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) @@ -621,7 +665,11 @@ bail: FreeFPE(c->fpe_list[i]); free(c->fpe_list); if (c->savedName) free(c->savedName); +#ifdef HAS_XFONT2 + xfont2_free_font_names(names); +#else FreeFontNames(names); +#endif /* HAS_XFONT2 */ free(c); if (resolved) free(resolved); return TRUE; @@ -651,7 +699,11 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } +#ifdef HAS_XFONT2 + c->names = xfont2_make_font_names_record(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames); +#else c->names = MakeFontNamesRecord(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames); +#endif /* HAS_XFONT2 */ if (!c->names) { free(c->fpe_list); @@ -699,7 +751,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -713,7 +769,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) err = Successful; if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) +#else err = (*fpe_functions[fpe->type].start_list_fonts_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) @@ -735,7 +795,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) { name = 0; pFontInfo = &fontInfo; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_with_info) +#else err = (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) @@ -775,7 +839,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#else + (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) @@ -1028,7 +1096,11 @@ nxdoListFontsAndAliases(client, fss) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -1041,11 +1113,19 @@ nxdoListFontsAndAliases(client, fss) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef HAS_XFONT2 + if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ { /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_fonts) +#else err = (*fpe_functions[fpe->type].list_fonts) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -1077,7 +1157,11 @@ nxdoListFontsAndAliases(client, fss) the FPEs. */ if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -1099,7 +1183,11 @@ nxdoListFontsAndAliases(client, fss) if (err == Successful) { char *tmpname; name = 0; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else err = (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -1170,7 +1258,11 @@ nxdoListFontsAndAliases(client, fss) int tmpnamelen; tmpname = 0; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else (void) (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif /* HAS_XFONT2 */ ((void *) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) @@ -1281,7 +1373,11 @@ finish: FreeFPE(c->fpe_list[i]); free(c->fpe_list); if (c->savedName) free(c->savedName); +#ifdef HAS_XFONT2 + xfont2_free_font_names(c->names); +#else FreeFontNames(c->names); +#endif /* HAS_XFONT2 */ free(c); free(fss); if (resolved) free(resolved); @@ -1333,7 +1429,11 @@ nxOpenFont(client, fid, flags, lenfname, pfontname) ** having to create another instance of a font that already exists. */ +#ifdef HAS_XFONT2 + cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); +#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); +#endif /* HAS_XFONT2 */ if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (void *) cached)) @@ -1357,7 +1457,11 @@ nxOpenFont(client, fid, flags, lenfname, pfontname) free(fss); return BadAlloc; } +#ifdef HAS_XFONT2 + c->names = xfont2_make_font_names_record(100); +#else c->names = MakeFontNamesRecord(100); +#endif /* HAS_XFONT2 */ if (!c->names) { free(c->fpe_list); diff --git a/nx-X11/programs/Xserver/include/dixfont.h b/nx-X11/programs/Xserver/include/dixfont.h index 004acefbf..21d917fe5 100644 --- a/nx-X11/programs/Xserver/include/dixfont.h +++ b/nx-X11/programs/Xserver/include/dixfont.h @@ -29,11 +29,21 @@ SOFTWARE. #include "closure.h" #include +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS XFONT2 */ + #define NullDIXFontProp ((DIXFontPropPtr)0) typedef struct _DIXFontProp *DIXFontPropPtr; +#ifdef HAS_XFONT2 +xfont2_fpe_funcs_rec const **fpe_functions; +#else extern FPEFunctions *fpe_functions; +#endif /* HAS_XFONT2 */ extern int FontToXError(int /*err*/); @@ -124,14 +134,25 @@ extern void InitFonts(void); extern void FreeFonts(void); +#ifdef HAS_XFONT2 +extern void GetGlyphs(FontPtr /*font */ , + unsigned long /*count */ , + unsigned char * /*chars */ , + FontEncoding /*fontEncoding */ , + unsigned long * /*glyphcount */ , + CharInfoPtr * /*glyphs */ ); +#else extern FontPtr find_old_font(XID /*id*/); -extern void GetGlyphs(FontPtr /*font*/, - unsigned long /*count*/, - unsigned char * /*chars*/, - FontEncoding /*fontEncoding*/, - unsigned long * /*glyphcount*/, - CharInfoPtr * /*glyphs*/); +#define GetGlyphs dixGetGlyphs +extern void dixGetGlyphs(FontPtr /*font*/, + unsigned long /*count*/, + unsigned char * /*chars*/, + FontEncoding /*fontEncoding*/, + unsigned long * /*glyphcount*/, + CharInfoPtr * /*glyphs*/); + +extern void register_fpe_functions(void); extern void QueryGlyphExtents(FontPtr /*pFont*/, CharInfoPtr * /*charinfo*/, @@ -142,6 +163,7 @@ extern Bool QueryTextExtents(FontPtr /*pFont*/, unsigned long /*count*/, unsigned char * /*chars*/, ExtentInfoPtr /*info*/); +#endif /* HAS_XFONT2 */ extern Bool ParseGlyphCachingMode(char * /*str*/); @@ -149,6 +171,4 @@ extern void InitGlyphCaching(void); extern void SetGlyphCachingMode(int /*newmode*/); -extern void register_fpe_functions(void); - #endif /* DIXFONT_H */ diff --git a/nx-X11/programs/Xserver/include/dixfontstr.h b/nx-X11/programs/Xserver/include/dixfontstr.h index a2cb3639c..3e76f9e6a 100644 --- a/nx-X11/programs/Xserver/include/dixfontstr.h +++ b/nx-X11/programs/Xserver/include/dixfontstr.h @@ -27,6 +27,9 @@ SOFTWARE. #include "servermd.h" #include "dixfont.h" #include +#ifdef HAS_XFONT2 +# include +#endif /* HAS_XFONT2 */ #include "closure.h" #include /* for xQueryFontReply */ diff --git a/nx-X11/programs/Xserver/mi/Imakefile b/nx-X11/programs/Xserver/mi/Imakefile index def061051..de7015c73 100644 --- a/nx-X11/programs/Xserver/mi/Imakefile +++ b/nx-X11/programs/Xserver/mi/Imakefile @@ -179,6 +179,9 @@ NormalLibraryTarget(cbrt,cbrt.o) SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES)) SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES)) +SpecialCObjectRule(miglblt,$(ICONFIGFILES),$(FONT_DEFINES)) +SpecialCObjectRule(mipolytext,$(ICONFIGFILES),$(FONT_DEFINES)) + #ifdef ItsyCompilerBug SpecialCObjectRule(mipolycon,$(_NOOP_),-O0) #endif diff --git a/nx-X11/programs/Xserver/mi/miglblt.c b/nx-X11/programs/Xserver/mi/miglblt.c index e317541a4..60c28fad4 100644 --- a/nx-X11/programs/Xserver/mi/miglblt.c +++ b/nx-X11/programs/Xserver/mi/miglblt.c @@ -55,6 +55,11 @@ SOFTWARE. #include #include "misc.h" #include +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS_XFONT2 */ #include "dixfontstr.h" #include "gcstruct.h" #include "windowstr.h" @@ -203,13 +208,18 @@ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) CharInfoPtr *ppci; /* array of character info */ void *pglyphBase; /* start of array of glyphs */ { - ExtentInfoRec info; /* used by QueryGlyphExtents() */ + ExtentInfoRec info; /* used by xfont2_query_glyph_extents (libXfont2) + resp. QueryGlyphExtents() (libXfont1) */ XID gcvals[3]; int oldAlu, oldFS; unsigned long oldFG; xRectangle backrect; +#ifdef HAS_XFONT2 + xfont2_query_glyph_extents(pGC->font, ppci, (unsigned long) nglyph, &info); +#else QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); +#endif /* HAS_XFONT2 */ if (info.overallWidth >= 0) { diff --git a/nx-X11/programs/Xserver/miext/damage/Imakefile b/nx-X11/programs/Xserver/miext/damage/Imakefile index 34d3fcf5a..b06261b24 100644 --- a/nx-X11/programs/Xserver/miext/damage/Imakefile +++ b/nx-X11/programs/Xserver/miext/damage/Imakefile @@ -22,6 +22,8 @@ NormalLibraryTarget(damage,$(OBJS)) LintLibraryTarget(damage,$(SRCS)) NormalLintTarget($(SRCS)) + +SpecialCObjectRule(damage,$(ICONFIGFILES),$(FONT_DEFINES)) #endif DependTarget() diff --git a/nx-X11/programs/Xserver/miext/damage/damage.c b/nx-X11/programs/Xserver/miext/damage/damage.c index 348adcb65..9c9161d36 100644 --- a/nx-X11/programs/Xserver/miext/damage/damage.c +++ b/nx-X11/programs/Xserver/miext/damage/damage.c @@ -34,6 +34,11 @@ #include #include "dixfontstr.h" #include +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS_XFONT2 */ #include "mi.h" #include "regionstr.h" #include "globals.h" @@ -1297,7 +1302,11 @@ damageDamageChars (DrawablePtr pDrawable, ExtentInfoRec extents; BoxRec box; +#ifdef HAS_XFONT2 + xfont2_query_glyph_extents(font, charinfo, n, &extents); +#else QueryGlyphExtents(font, charinfo, n, &extents); +#endif /* HAS_XFONT2 */ if (imageblt) { if (extents.overallWidth > extents.overallRight) diff --git a/nx-X11/programs/Xserver/os/Imakefile b/nx-X11/programs/Xserver/os/Imakefile index 7932e32cd..b82da1baa 100644 --- a/nx-X11/programs/Xserver/os/Imakefile +++ b/nx-X11/programs/Xserver/os/Imakefile @@ -248,7 +248,7 @@ SpecialCObjectRule(connection,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES)) SpecialCObjectRule(osinit,$(ICONFIGFILES),$(ADM_DEFINES)) SpecialCObjectRule(WaitFor,$(ICONFIGFILES),$(EXT_DEFINES)) SpecialCObjectRule(io,$(ICONFIGFILES),$(EXT_DEFINES)) -SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES)) +SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES) $(FONT_DEFINES)) #if defined(SparcArchitecture) && HasGcc && !HasGcc2 oscolor.o: oscolor.c $(ICONFIGFILES) $(RM) $@ diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 31ea55bc3..dd637ca4b 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -96,6 +96,11 @@ OR PERFORMANCE OF THIS SOFTWARE. #include #include "input.h" #include "dixfont.h" +#ifdef HAS_XFONT2 +# include +#else +# include +#endif /* HAS_XFONT2 */ #include "osdep.h" #ifdef X_POSIX_C_SOURCE #define _POSIX_C_SOURCE X_POSIX_C_SOURCE @@ -797,7 +802,11 @@ ProcessCommandLine(int argc, char *argv[]) #endif else if ( strcmp( argv[i], "-deferglyphs") == 0) { +#ifdef HAS_XFONT2 + if(++i >= argc || !!xfont2_parse_glyph_caching_mode(argv[i])) +#else if(++i >= argc || !ParseGlyphCachingMode(argv[i])) +#endif /* HAS_XFONT2 */ UseMsg(); } else if ( strcmp( argv[i], "-f") == 0) -- cgit v1.2.3 From 92979a4e860f7e52f82292469e10b411ebaca0ae Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 10 Apr 2017 10:08:14 +0000 Subject: Makefile: Tell Xserver build which Xfont API to use (v2 or v1) depending on what's available in the build env. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eb53f1ed2..f2bf63264 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,10 @@ USRLIBDIR ?= $(NXLIBDIR)/X11 INCLUDEDIR ?= $(PREFIX)/include CONFIGURE ?= ./configure +# use Xfont2 if available in the build env +FONT_DEFINES ?= $(shell pkg-config --modversion xfont2 1>/dev/null 2>/dev/null && echo "-DHAS_XFONT2") +XFONTLIB ?= $(shell pkg-config --modversion xfont2 1>/dev/null 2>/dev/null && echo "-lXfont2" || echo "-lXfont") + NX_VERSION_MAJOR=$(shell ./version.sh 1) NX_VERSION_MINOR=$(shell ./version.sh 2) NX_VERSION_MICRO=$(shell ./version.sh 3) @@ -75,7 +79,8 @@ build-full: cd nxcompshad && autoconf && (${CONFIGURE}) && ${MAKE} ./mesa-quilt push -a - cd nx-X11 && ${MAKE} World USRLIBDIR=$(USRLIBDIR) SHLIBDIR=$(SHLIBDIR) + + cd nx-X11 && ${MAKE} World USRLIBDIR=$(USRLIBDIR) SHLIBDIR=$(SHLIBDIR) FONT_DEFINES=$(FONT_DEFINES) XFONTLIB=$(XFONTLIB) cd nxproxy && autoconf && (${CONFIGURE}) && ${MAKE} -- cgit v1.2.3 From a5432aac893cc6857b2189fcaae55002858ca376 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 10 Apr 2017 10:09:32 +0000 Subject: debian/control: Use B-D libxfont-dev only. Follow libXfont2 transition on Debian (and alike). --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index c00550dc2..b1898252f 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Build-Depends: libxmltok1-dev, libxml2-dev, libxpm-dev, - libxfont1-dev | libxfont-dev (>= 1.4.2), + libxfont-dev (>= 1.4.2), libxdmcp-dev, libxdamage-dev, libxext-dev, -- cgit v1.2.3 From c4c5485474a03bcfd2632d12c2e6e88ba20be471 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 10 Apr 2017 12:43:33 +0200 Subject: nx-libs.spec: Prefer libXfont2-devel on RPM distro versions that have it.~ --- nx-libs.spec | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nx-libs.spec b/nx-libs.spec index 7e25b7e81..935219f0f 100644 --- a/nx-libs.spec +++ b/nx-libs.spec @@ -38,7 +38,11 @@ BuildRequires: pkgconfig(pixman-1) >= 0.13.2 BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(xext) BuildRequires: pkgconfig(xpm) +#%%if 0%%{?suse_version} >= 42XX +#BuildRequires: pkgconfig(xfont2) +#%%else BuildRequires: pkgconfig(xfont) >= 1.4.2 +#%%endif BuildRequires: pkgconfig(xdmcp) BuildRequires: pkgconfig(xdamage) BuildRequires: pkgconfig(xcomposite) @@ -74,7 +78,11 @@ BuildRequires: pixman-devel >= 0.13.2 BuildRequires: libX11-devel BuildRequires: libXext-devel BuildRequires: libXpm-devel +%if 0%{?fedora} >= 24 || 0%{?rhel} >= 8 +BuildRequires: libXfont2-devel +%else BuildRequires: libXfont-devel >= 1.4.2 +%endif BuildRequires: libXdmcp-devel BuildRequires: libXdamage-devel BuildRequires: libXcomposite-devel -- cgit v1.2.3