rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libdga / src / pix_inquiry.c
blob5fb419784a30f8314b73d650a58c52d08652f957
1 /* Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
25 ** pix_inquiry.c - state inquiry routines for pixmaps.
28 #ifdef SERVER_DGA
29 #include <X11/Xlib.h>
30 #endif /* SERVER_DGA */
31 #include "dga_incls.h"
32 #include "pix_grab.h"
34 Display *
35 dgai_pix_display(_Dga_pixmap dgapix)
37 return (dgapix->p_dpy);
40 char *
41 dgai_pix_devname(_Dga_pixmap dgapix)
43 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE)
44 return (NULL);
45 return((char *)(((SHARED_PIXMAP_INFO *)(dgapix->p_infop))->scr_name));
48 int
49 dgai_pix_devfd(_Dga_pixmap dgapix)
51 return(dgapix->p_infofd);
54 int
55 dgai_pix_depth(_Dga_pixmap dgapix)
57 return(dgapix->depth);
60 void
61 dgai_pix_set_client_infop(_Dga_pixmap dgapix, void *client_info_ptr)
63 dgapix->p_client = client_info_ptr;
66 void *
67 dgai_pix_get_client_infop(_Dga_pixmap dgapix)
69 return(dgapix->p_client);
72 void *
73 dgai_pix_devinfo(_Dga_pixmap dgapix)
75 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE)
76 return (NULL);
77 return(((char *)dgapix->p_infop) + PIX_INFOP(dgapix)->device_offset);
80 int
81 dgai_pix_devinfochg(_Dga_pixmap dgapix)
83 if (dgapix->changeMask & DGA_CHANGE_DEVINFO) {
84 dgapix->changeMask &= ~DGA_CHANGE_DEVINFO;
85 return (1);
86 } else {
87 return (0);
91 int
92 dgai_pix_sitechg(_Dga_pixmap dgapix, int *reason)
94 if (dgapix->changeMask & DGA_CHANGE_SITE) {
95 dgapix->changeMask &= ~DGA_CHANGE_SITE;
96 *reason = dgapix->siteChgReason;
97 return (1);
98 } else {
99 *reason = DGA_SITECHG_UNKNOWN;
100 return (0);
104 void
105 dgai_pix_sitesetnotify(_Dga_pixmap dgapix,
106 DgaSiteNotifyFunc site_notify_func, void *client_data)
108 dgapix->siteNotifyFunc = site_notify_func;
109 dgapix->siteNotifyClientData = client_data;
112 void
113 dgai_pix_sitegetnotify(_Dga_pixmap dgapix,
114 DgaSiteNotifyFunc *site_notify_func, void **client_data)
116 *site_notify_func = dgapix->siteNotifyFunc;
117 *client_data = dgapix->siteNotifyClientData;
121 dgai_pix_site(_Dga_pixmap dgapix)
123 SHARED_PIXMAP_INFO *infop;
125 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE) {
126 return (DGA_SITE_NULL);
129 infop = PIX_INFOP(dgapix);
130 return (infop->cached ? DGA_SITE_DEVICE : DGA_SITE_SYSTEM);
133 void *
134 dgai_pix_address(_Dga_pixmap dgapix)
136 SHARED_PIXMAP_INFO *infop;
138 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE)
139 return (NULL);
141 infop = PIX_INFOP(dgapix);
142 return(infop->cached ? NULL : (void *)(infop + 1));
146 dgai_pix_linebytes(_Dga_pixmap dgapix)
148 SHARED_PIXMAP_INFO *infop;
150 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE)
151 return (NULL);
153 infop = PIX_INFOP(dgapix);
154 return(infop->cached ? 0 : infop->linebytes);
158 dgai_pix_bitsperpixel(_Dga_pixmap dgapix)
160 SHARED_PIXMAP_INFO *infop;
162 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE)
163 return (NULL);
165 infop = PIX_INFOP(dgapix);
166 return(infop->cached ? 0 : infop->bitsperpixel);
170 dgai_pix_clipchg(_Dga_pixmap dgapix)
172 /* always force a clip change on a zombie to get the client
173 to notice */
174 if ((dgapix->changeMask & DGA_CHANGE_ZOMBIE) ||
175 (dgapix->pix_flags & PIX_NOTICE_CLIPCHG)){
176 dgapix->pix_flags &= ~PIX_NOTICE_CLIPCHG;
177 return (1);
178 } else {
179 return(0);
184 void
185 dgai_pix_bbox(_Dga_pixmap dgapix, int *xp, int *yp, int *widthp, int *heightp)
187 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE) {
188 *xp = 0;
189 *yp = 0;
190 *widthp = 0;
191 *heightp = 0;
192 } else {
193 SHARED_PIXMAP_INFO *infop;
195 infop = PIX_INFOP(dgapix);
196 *xp = 0;
197 *yp = 0;
198 *widthp = infop->width;
199 *heightp = infop->height;
204 dgai_pix_empty(_Dga_pixmap dgapix)
206 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE) {
207 return (1);
208 } else {
209 SHARED_PIXMAP_INFO *infop;
211 infop = PIX_INFOP(dgapix);
212 return (infop->width <= 0 || infop->height <= 0);
216 static short nonviewableShape[] = {
217 0, /* ymin */
218 0, /* ymax: fill in based on height */
219 0, /* xmin */
220 0, /* xmax: fill in based on width */
221 DGA_X_EOL,
222 DGA_Y_EOL,
225 #define YMAX_INDEX 1
226 #define XMAX_INDEX 3
228 short *
229 dgai_pix_clipinfo(_Dga_pixmap dgapix)
231 if (dgapix->changeMask & DGA_CHANGE_ZOMBIE) {
232 return (NULL);
233 } else {
234 SHARED_PIXMAP_INFO *infop;
236 infop = PIX_INFOP(dgapix);
237 if (infop->width <= 0 || infop->height <= 0) {
238 return (NULL);
239 } else {
240 nonviewableShape[YMAX_INDEX] = infop->height - 1;
241 nonviewableShape[XMAX_INDEX] = infop->width - 1;
242 return (nonviewableShape);