File: FRenderInit.c

package info (click to toggle)
fvwm 1:2.6.8-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,804 kB
  • sloc: ansic: 145,770; xml: 17,093; perl: 7,302; sh: 4,921; makefile: 1,094; yacc: 688; lex: 187; sed: 11
file content (136 lines) | stat: -rw-r--r-- 3,206 bytes parent folder | download
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
/* -*-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, see: <http://www.gnu.org/licenses/>
 */

/* ---------------------------- 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, "%s\n", error_names[code - FRenderErrorBase]);
			return 1;
		}
	}
	return 0;
}