Update key files in preparation for 2.5.31.
[fvwm.git] / libs / FRenderInit.c
blobfcdb2591867f05ba439c5253ab777ee8a5b26b6f
1 /* -*-c-*- */
2 /* Copyright (C) 2002 Olivier Chapuis */
3 /* This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 /* ---------------------------- included header files ---------------------- */
20 #include "config.h"
22 #include <stdio.h>
24 #include <X11/Xlib.h>
26 #include "fvwmlib.h"
27 #include "PictureBase.h"
28 #include "FRenderInit.h"
30 /* ---------------------------- local definitions -------------------------- */
32 /* ---------------------------- local macros ------------------------------- */
34 /* ---------------------------- imports ------------------------------------ */
36 /* ---------------------------- included code files ------------------------ */
38 /* ---------------------------- local types -------------------------------- */
40 /* ---------------------------- forward declarations ----------------------- */
42 /* ---------------------------- local variables ---------------------------- */
44 Bool FRenderExtensionSupported = False;
45 int FRenderErrorBase = -10000;
46 int FRenderMajorOpCode = -10000;
47 int FRenderAlphaDepth = 0;
49 /* ---------------------------- exported variables (globals) --------------- */
51 /* ---------------------------- local functions ---------------------------- */
53 void FRenderInit(Display *dpy)
55 int event_basep;
57 FRenderAlphaDepth = 8;
58 if (!XRenderSupport || !(FRenderExtensionSupported = XQueryExtension(
59 dpy, "RENDER", &FRenderMajorOpCode, &event_basep,
60 &FRenderErrorBase)))
62 int *pmf = NULL;
63 int i,n;
64 int alpha_depth = 0;
66 FRenderErrorBase = -10000;
67 FRenderMajorOpCode = -10000;
68 FRenderExtensionSupported = 0;
69 pmf = XListDepths(dpy, DefaultScreen(dpy), &n);
70 if (pmf)
72 i = 0;
73 while(i < n)
75 if (pmf[i] == 8)
77 alpha_depth = 8;
78 i = n-1;
80 else if (pmf[i] >= 8 &&
81 (pmf[i] < alpha_depth ||
82 alpha_depth == 0))
84 alpha_depth = pmf[i];
86 i++;
88 XFree(pmf);
90 FRenderAlphaDepth = alpha_depth;
95 int FRenderGetErrorCodeBase(void)
97 return FRenderErrorBase;
100 int FRenderGetMajorOpCode(void)
102 return FRenderMajorOpCode;
105 Bool FRenderGetExtensionSupported(void)
107 return FRenderExtensionSupported;
110 int FRenderGetAlphaDepth(void)
112 return FRenderAlphaDepth;
115 Bool FRenderGetErrorText(int code, char *msg)
118 if (XRenderSupport)
120 static char *error_names[] = {
121 "BadPictFormat",
122 "BadPicture",
123 "BadPictOp",
124 "BadGlyphSet",
125 "BadGlyph"
128 if (code >= FRenderErrorBase &&
129 code <= FRenderErrorBase +
130 (sizeof(error_names) / sizeof(char *)) -1)
132 sprintf(msg, error_names[code - FRenderErrorBase]);
133 return 1;
136 return 0;