rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libdga / src / mbsmemb_inquiry.c
blob3e820b1b20e34219d37b1c909cd9cd7f2f48a616
1 /* Copyright (c) 1993, 1997, 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.
24 /*
25 ** mbsmemb_inquiry.c - state inquiry routines for mbufset members.
28 #ifdef SERVER_DGA
29 #include <X11/Xlib.h>
30 #endif /* SERVER_DGA */
31 #include "dga_incls.h"
32 #include "pix_grab.h"
33 #include "mbufsetstr.h"
35 extern int dgai_rtn_ungrab_common(_Dga_window dgawin, int drawableGrabber);
36 extern int dga_rtn_bitsperpixel(Dga_window clientpi);
38 Display *
39 dgai_mbsmemb_display (_Dga_window dgawin)
41 return (dgawin->w_dpy);
44 char *
45 dgai_mbsmemb_devname (_Dga_window dgawin)
47 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE)
48 return (NULL);
50 return(((WXINFO *) (dgawin->w_info))->w_devname);
53 int
54 dgai_mbsmemb_devfd (_Dga_window dgawin)
56 return(dgawin->w_devfd);
59 int
60 dgai_mbsmemb_depth (_Dga_window dgawin)
62 WXINFO *infop = (WXINFO *) dgawin->w_info;
64 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE)
65 return (NULL);
67 if (infop->w_version >= 3)
68 return((int)infop->w_depth);
69 else
70 return (0);
73 void
74 dgai_mbsmemb_set_client_infop (_Dga_window dgawin, void *client_info_ptr)
76 dgawin->w_client = client_info_ptr;
79 void *
80 dgai_mbsmemb_get_client_infop (_Dga_window dgawin)
82 return (dgawin->w_client);
85 void *
86 dgai_mbsmemb_devinfo (_Dga_window dgawin)
88 SHARED_PIXMAP_INFO *infop;
90 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
91 dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
92 return (NULL);
95 if (dgawin->eLockSubj == -1) {
96 WXINFO *infop = (WXINFO *) dgawin->w_info;
98 return ((void *) &(infop->wx_dbuf.device_info));
100 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
101 return (((char *)infop) + infop->device_offset);
105 dgai_mbsmemb_devinfochg (_Dga_window dgawin)
107 if (dgawin->changeMask & DGA_CHANGE_DEVINFO) {
108 dgawin->changeMask &= ~DGA_CHANGE_DEVINFO;
109 return (1);
110 } else {
111 return (0);
116 dgai_mbsmemb_sitechg (_Dga_window dgawin, int *reason)
118 if (dgawin->changeMask & DGA_CHANGE_SITE) {
119 dgawin->changeMask &= ~DGA_CHANGE_SITE;
120 *reason = dgawin->siteChgReason;
121 return (1);
122 } else {
123 *reason = DGA_SITECHG_UNKNOWN;
124 return (0);
128 void
129 dgai_mbsmemb_sitesetnotify (_Dga_window dgawin, DgaSiteNotifyFunc site_notify_func,
130 void *client_data)
132 dgawin->siteNotifyFunc = site_notify_func;
133 dgawin->siteNotifyClientData = client_data;
136 void
137 dgai_mbsmemb_sitegetnotify (_Dga_window dgawin, DgaSiteNotifyFunc *site_notify_func,
138 void **client_data)
140 *site_notify_func = dgawin->siteNotifyFunc;
141 *client_data = dgawin->siteNotifyClientData;
145 dgai_mbsmemb_site (_Dga_window dgawin)
147 SHARED_PIXMAP_INFO *infop;
149 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID)||
150 dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
151 return (DGA_SITE_NULL);
154 /* viewable drawables always are in device site */
155 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
156 return (DGA_SITE_DEVICE);
159 /* the site of a nonviewable multibuffer depends on whether or not
160 it is cached */
162 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
163 return (infop->cached ? DGA_SITE_DEVICE : DGA_SITE_SYSTEM);
166 void *
167 dgai_mbsmemb_address (_Dga_window dgawin)
169 SHARED_PIXMAP_INFO *infop;
171 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
172 dgawin->changeMask & DGA_CHANGE_ZOMBIE ||
173 DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
174 return (NULL);
177 /* the return value is only valid for nonviewable multibuffers that
178 are not cached */
179 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
180 return (infop->cached ? NULL : (void *)(infop + 1));
184 dgai_mbsmemb_linebytes (_Dga_window dgawin)
186 SHARED_PIXMAP_INFO *infop;
188 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
189 dgawin->changeMask & DGA_CHANGE_ZOMBIE ||
190 DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
191 return (0);
194 /* the return value is only valid for nonviewable multibuffers that
195 are not cached */
196 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
197 return (infop->cached ? 0 : infop->linebytes);
201 dgai_mbsmemb_bitsperpixel (_Dga_window dgawin)
203 SHARED_PIXMAP_INFO *infop;
205 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
206 dgawin->changeMask & DGA_CHANGE_ZOMBIE ||
207 DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
208 return (0);
211 /* the return value is only valid for nonviewable multibuffers that
212 are not cached */
213 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
214 return (infop->cached ? 0 : infop->bitsperpixel);
218 dgai_mbsmemb_clipchg (_Dga_window dgawin)
220 /* always force a clip change on a zombie to get the client
221 to notice */
222 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
223 return (1);
226 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
227 if (dga_win_clipchg((Dga_window)dgawin) ||
228 (dgawin->changeMask & DGA_CHANGE_CLIP)) {
229 dgawin->changeMask &= ~DGA_CHANGE_CLIP;
230 return (1);
231 } else {
232 return (0);
234 } else {
235 /* nonviewable */
236 if (dgawin->changeMask & DGA_CHANGE_CLIP) {
237 dgawin->changeMask &= ~DGA_CHANGE_CLIP;
238 return (1);
239 } else {
240 return (0);
245 void
246 dgai_mbsmemb_bbox(_Dga_window dgawin, int *xp, int *yp, int *widthp, int *heightp)
248 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
249 dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
250 *xp = 0;
251 *yp = 0;
252 *widthp = 0;
253 *heightp = 0;
254 return;
257 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
258 dga_win_bbox((Dga_window)dgawin, xp, yp, widthp, heightp);
259 } else {
260 /* nonviewable */
261 SHARED_PIXMAP_INFO *infop;
263 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
264 *xp = 0;
265 *yp = 0;
266 *widthp = infop->width;
267 *heightp = infop->height;
272 dgai_mbsmemb_visibility (_Dga_window dgawin)
274 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
275 return (DGA_VIS_FULLY_OBSCURED);
278 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
279 return (dgai_win_visibility((Dga_window)dgawin));
280 } else {
281 /* Non viewable mbufs are always unobscured */
282 return (DGA_VIS_UNOBSCURED);
287 dgai_mbsmemb_empty (_Dga_window dgawin)
289 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID)||
290 dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
291 return (1);
294 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
295 return (dga_win_empty((Dga_window)dgawin));
296 } else {
297 /* nonviewable */
298 SHARED_PIXMAP_INFO *infop;
300 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
301 return (infop->width <= 0 || infop->height <= 0);
305 static short nonviewableShape[] = {
306 0, /* ymin */
307 0, /* ymax: fill in based on height */
308 0, /* xmin */
309 0, /* xmax: fill in based on width */
310 DGA_X_EOL,
311 DGA_Y_EOL,
314 #define YMAX_INDEX 1
315 #define XMAX_INDEX 3
317 short *
318 dgai_mbsmemb_clipinfo (_Dga_window dgawin)
320 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
321 dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
322 return (NULL);
325 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
326 return (dga_win_clipinfo((Dga_window)dgawin));
327 } else {
328 /* nonviewable */
329 SHARED_PIXMAP_INFO *infop;
331 /* build a dummy shape describing the rectangle */
332 infop = dgawin->pMbs->pNbShinfo[dgawin->eLockSubj];
333 if (infop->width <= 0 || infop->height <= 0) {
334 return (NULL);
335 } else {
336 nonviewableShape[YMAX_INDEX] = infop->height - 1;
337 nonviewableShape[XMAX_INDEX] = infop->width - 1;
338 return (nonviewableShape);
345 dgai_mbsmemb_singlerect (_Dga_window dgawin)
347 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
348 /* consider a zombie to be a "single rectangle" of 0 width and height */
349 return (1);
352 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
353 return (dga_win_singlerect((Dga_window)dgawin));
354 } else {
355 /* nonviewable is always a single rectangle */
356 return (1);
361 dgai_mbsmemb_obscured (_Dga_window dgawin)
363 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
364 /* consider a zombie to be always fully obscured */
365 return (1);
368 if (DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
369 return (dga_win_obscured((Dga_window)dgawin));
370 } else {
371 /* nonviewable can never be obscured */
372 return (0);
377 u_short
378 dgai_mbsmemb_borderwidth (_Dga_window dgawin)
380 if (dgawin->changeMask & DGA_CHANGE_ZOMBIE) {
381 /* zombies don't have borders */
382 return (0);
385 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
386 return (dga_win_borderwidth((Dga_window)dgawin));
387 } else {
388 /* multibuffers don't have borders */
389 return (0);
394 typedef void (*DgaCursTakeDownFuncOld)();
396 void
397 dgai_mbsmemb_curshandle (_Dga_window dgawin, DgaCursTakeDownFunc take_down_func,
398 void *client_data)
400 Dga_window dgaw;
402 /* Nonviewable drawables never have a cursor */
403 if (!DGA_LOCKSUBJ_VIEWABLE(dgawin, dgawin->eLockSubj)) {
404 return;
407 /* viewable multibuffers share the cursor of the main window */
408 dgaw = (Dga_window) dgawin;
409 if (dga_win_curschg(dgaw)) {
410 if (dga_win_cursactive(dgaw)) {
411 dga_win_cursupdate(dgaw,
412 (DgaCursTakeDownFuncOld)take_down_func,
413 client_data);
420 dgai_mbsmemb_rtngrab (_Dga_window dgawin)
422 /* rtngrab is not something that must be called from inside a lock
423 * and therefore the eLockSubj is meaningless. Just do a
424 * dga_rtn_grab() on the window. */
426 return (dga_rtn_grab((Dga_window)dgawin));
430 dgai_mbsmemb_rtnungrab (_Dga_window dgawin)
432 return (dgai_rtn_ungrab_common(dgawin,1));
436 dgai_mbsmemb_rtnchg (_Dga_window dgawin)
438 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
439 return (dga_win_rtnchg((Dga_window)dgawin));
440 } else {
441 /* rtn is not applicable to multibuffers -- always force an activity check */
442 return (1);
447 dgai_mbsmemb_rtnactive (_Dga_window dgawin)
449 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
450 return (dga_rtn_active((Dga_window)dgawin));
451 } else {
452 /* rtn is not applicable to multibuffers -- never active */
453 return (0);
458 dgai_mbsmemb_rtncached (_Dga_window dgawin)
460 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
461 return (dga_rtn_cached((Dga_window)dgawin));
462 } else {
463 /* rtn is not applicable to multibuffers -- never cached */
464 return (0);
468 void *
469 dgai_mbsmemb_rtndevinfop (_Dga_window dgawin)
471 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
472 return (dga_rtn_devinfo((Dga_window)dgawin));
473 } else {
474 /* rtn is not applicable to multibuffers -- no devinfo */
475 return (NULL);
479 void
480 dgai_mbsmemb_rtndevtype (_Dga_window dgawin, u_char *type, char **name)
482 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
483 dga_rtn_devtype((Dga_window)dgawin, type, name);
484 } else {
485 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
486 *type = (u_char) 0;
487 *name = NULL;
491 void
492 dgai_mbsmemb_rtndimensions (_Dga_window dgawin, short *width, short *height,
493 u_int *linebytes)
495 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
496 dga_rtn_dimensions((Dga_window)dgawin, width, height, linebytes);
497 } else {
498 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
499 *width = 0;
500 *height = 0;
501 *linebytes = 0;
506 dgai_mbsmemb_rtnbitsperpixel (_Dga_window dgawin)
508 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
509 return (dga_rtn_bitsperpixel((Dga_window)dgawin));
510 } else {
511 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
512 return (0);
516 void *
517 dgai_mbsmemb_rtnpixels (_Dga_window dgawin)
519 if (DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
520 return (dga_rtn_pixels((Dga_window)dgawin));
521 } else {
522 /* rtn is not applicable to multibuffers -- return NULL */
523 return (NULL);
529 dgai_mbsmemb_mbchg (_Dga_window dgawin, int *reason)
531 if (dgawin->changeMask & DGA_CHANGE_MBUFSET) {
532 dgawin->changeMask &= ~DGA_CHANGE_MBUFSET;
533 *reason = dgawin->mbChgReason;
534 return (1);
535 } else {
536 *reason = DGA_MBCHG_UNKNOWN;
537 return (0);
541 void
542 dgai_mbsmemb_mbsetnotify (_Dga_window dgawin, DgaMbNotifyFunc mb_notify_func,
543 void *client_data)
545 dgawin->mbNotifyFunc = mb_notify_func;
546 dgawin->mbNotifyClientData = client_data;
549 void
550 dgai_mbsmemb_mbgetnotify (_Dga_window dgawin, DgaMbNotifyFunc *mb_notify_func,
551 void **client_data)
553 *mb_notify_func = dgawin->mbNotifyFunc;
554 *client_data = dgawin->mbNotifyClientData;
559 dgai_mbsmemb_mbaccessmode (_Dga_window dgawin)
561 if (!dgawin->pMbs) {
562 return (DGA_MBACCESS_NONE);
563 } else {
564 WXINFO *infop;
566 infop = (WXINFO *) dgawin->w_info;
568 return (infop->w_mbsInfo.accessMode);
573 dgai_mbsmemb_mbsitetypeconst (_Dga_window dgawin)
575 if (!dgawin->pMbs) {
576 return (1);
577 } else {
578 WXINFO *infop;
580 infop = (WXINFO *) dgawin->w_info;
582 return (infop->w_mbsInfo.siteTypeConst);
586 void
587 dgai_mbsmemb_mbsetrendbufnotify (_Dga_window dgawin, DgaRendBufNotifyFunc rb_notify_func,
588 void *client_data)
590 dgawin->rendBufNotifyFunc = rb_notify_func;
591 dgawin->rendBufNotifyClientData = client_data;
594 void
595 dgai_mbsmemb_mbgetrendbufnotify (_Dga_window dgawin, DgaRendBufNotifyFunc *rb_notify_func,
596 void **client_data)
598 *rb_notify_func = dgawin->rendBufNotifyFunc;
599 *client_data = dgawin->rendBufNotifyClientData;
603 dgai_mbsmemb_ovlstatechg (_Dga_window dgawin)
605 if (dgawin->changeMask & DGA_CHANGE_OVLSTATE) {
606 dgawin->changeMask &= ~DGA_CHANGE_OVLSTATE;
607 return (1);
608 } else {
609 return (0);
614 dgai_mbsmemb_ovlstate (_Dga_window dgawin)
616 /* REMIND: Do we need to check this stuff? */
617 if ((dgawin->eLockSubj == DGA_LOCKSUBJ_INVALID) ||
618 (dgawin->changeMask & DGA_CHANGE_ZOMBIE)) {
619 return (DGA_OVLSTATE_CONFLICT);
621 if (!dgawin->isOverlay)
622 /* Don't let clients do "overlay" rendering to regular windows! */
623 return DGA_OVLSTATE_CONFLICT;
624 else
625 return dgawin->c_ovlstate;
628 void
629 dgai_mbsmemb_setovlstatenotify (_Dga_window dgawin,
630 DgaOvlStateNotifyFunc ovlstate_notify_func,
631 void *client_data)
633 dgawin->ovlStateNotifyFunc = ovlstate_notify_func;
634 dgawin->ovlStateNotifyClientData = client_data;
637 void
638 dgai_mbsmemb_getovlstatenotify (_Dga_window dgawin,
639 DgaOvlStateNotifyFunc *ovlstate_notify_func,
640 void **client_data)
642 *ovlstate_notify_func = dgawin->ovlStateNotifyFunc;
643 *client_data = dgawin->ovlStateNotifyClientData;