File: FRenderInit.c

package info (click to toggle)
fvwm 1%3A2.5.18-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,084 kB
  • ctags: 14,319
  • sloc: ansic: 160,604; perl: 10,958; sh: 9,922; makefile: 1,109; yacc: 683; lex: 169; sed: 11
file content (137 lines) | stat: -rw-r--r-- 3,266 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* -*-c-*- */
/* Copyright (C) 2002  Olivier Chapuis */
/* This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* ---------------------------- included header files ---------------------- */

#include "config.h"

#include <stdio.h>

#include <X11/Xlib.h>

#include "fvwmlib.h"
#include "PictureBase.h"
#include "FRenderInit.h"

/* ---------------------------- local definitions -------------------------- */

/* ---------------------------- local macros ------------------------------- */

/* ---------------------------- imports ------------------------------------ */

/* ---------------------------- included code files ------------------------ */

/* ---------------------------- local types -------------------------------- */

/* ---------------------------- forward declarations ----------------------- */

/* ---------------------------- local variables ---------------------------- */

Bool FRenderExtensionSupported = False;
int FRenderErrorBase = -10000;
int FRenderMajorOpCode = -10000;
int FRenderAlphaDepth = 0;

/* ---------------------------- exported variables (globals) --------------- */

/* ---------------------------- local functions ---------------------------- */

void FRenderInit(Display *dpy)
{
	int event_basep;

	FRenderAlphaDepth = 8;
	if (!XRenderSupport || !(FRenderExtensionSupported = XQueryExtension(
		dpy, "RENDER", &FRenderMajorOpCode, &event_basep,
		&FRenderErrorBase)))
	{
		int *pmf = NULL;
		int i,n;
		int alpha_depth = 0;

		FRenderErrorBase = -10000;
		FRenderMajorOpCode = -10000;
		FRenderExtensionSupported = 0;
		pmf = XListDepths(dpy, DefaultScreen(dpy), &n);
		if (pmf)
		{
			i = 0;
			while(i < n)
			{
				if (pmf[i] == 8)
				{
					alpha_depth = 8;
					i = n-1;
				}
				else if (pmf[i] >= 8 &&
					 (pmf[i] < alpha_depth ||
					  alpha_depth == 0))
				{
					alpha_depth = pmf[i];
				}
				i++;
			}
			XFree(pmf);
		}
		FRenderAlphaDepth = alpha_depth;
	}
}


int FRenderGetErrorCodeBase(void)
{
	return FRenderErrorBase;
}

int FRenderGetMajorOpCode(void)
{
	return FRenderMajorOpCode;
}

Bool FRenderGetExtensionSupported(void)
{
	return FRenderExtensionSupported;
}

int FRenderGetAlphaDepth(void)
{
	return FRenderAlphaDepth;
}

Bool FRenderGetErrorText(int code, char *msg)
{

	if (XRenderSupport)
	{
		static char *error_names[] = {
			"BadPictFormat",
			"BadPicture",
			"BadPictOp",
			"BadGlyphSet",
			"BadGlyph"
		};

		if (code >= FRenderErrorBase &&
		    code <= FRenderErrorBase +
		    (sizeof(error_names) / sizeof(char *)) -1)
		{
			sprintf(msg, error_names[code - FRenderErrorBase]);
			return 1;
		}
	}
	return 0;
}