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
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 ** mbsmemb_inquiry.c - state inquiry routines for mbufset members.
30 #endif /* SERVER_DGA */
31 #include "dga_incls.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
);
39 dgai_mbsmemb_display (_Dga_window dgawin
)
41 return (dgawin
->w_dpy
);
45 dgai_mbsmemb_devname (_Dga_window dgawin
)
47 if (dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
)
50 return(((WXINFO
*) (dgawin
->w_info
))->w_devname
);
54 dgai_mbsmemb_devfd (_Dga_window dgawin
)
56 return(dgawin
->w_devfd
);
60 dgai_mbsmemb_depth (_Dga_window dgawin
)
62 WXINFO
*infop
= (WXINFO
*) dgawin
->w_info
;
64 if (dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
)
67 if (infop
->w_version
>= 3)
68 return((int)infop
->w_depth
);
74 dgai_mbsmemb_set_client_infop (_Dga_window dgawin
, void *client_info_ptr
)
76 dgawin
->w_client
= client_info_ptr
;
80 dgai_mbsmemb_get_client_infop (_Dga_window dgawin
)
82 return (dgawin
->w_client
);
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
) {
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
;
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
;
123 *reason
= DGA_SITECHG_UNKNOWN
;
129 dgai_mbsmemb_sitesetnotify (_Dga_window dgawin
, DgaSiteNotifyFunc site_notify_func
,
132 dgawin
->siteNotifyFunc
= site_notify_func
;
133 dgawin
->siteNotifyClientData
= client_data
;
137 dgai_mbsmemb_sitegetnotify (_Dga_window dgawin
, DgaSiteNotifyFunc
*site_notify_func
,
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
162 infop
= dgawin
->pMbs
->pNbShinfo
[dgawin
->eLockSubj
];
163 return (infop
->cached
? DGA_SITE_DEVICE
: DGA_SITE_SYSTEM
);
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
)) {
177 /* the return value is only valid for nonviewable multibuffers that
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
)) {
194 /* the return value is only valid for nonviewable multibuffers that
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
)) {
211 /* the return value is only valid for nonviewable multibuffers that
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
222 if (dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
) {
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
;
236 if (dgawin
->changeMask
& DGA_CHANGE_CLIP
) {
237 dgawin
->changeMask
&= ~DGA_CHANGE_CLIP
;
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
) {
257 if (DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
258 dga_win_bbox((Dga_window
)dgawin
, xp
, yp
, widthp
, heightp
);
261 SHARED_PIXMAP_INFO
*infop
;
263 infop
= dgawin
->pMbs
->pNbShinfo
[dgawin
->eLockSubj
];
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
));
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
) {
294 if (DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
295 return (dga_win_empty((Dga_window
)dgawin
));
298 SHARED_PIXMAP_INFO
*infop
;
300 infop
= dgawin
->pMbs
->pNbShinfo
[dgawin
->eLockSubj
];
301 return (infop
->width
<= 0 || infop
->height
<= 0);
305 static short nonviewableShape
[] = {
307 0, /* ymax: fill in based on height */
309 0, /* xmax: fill in based on width */
318 dgai_mbsmemb_clipinfo (_Dga_window dgawin
)
320 if ((dgawin
->eLockSubj
== DGA_LOCKSUBJ_INVALID
) ||
321 dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
) {
325 if (DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
326 return (dga_win_clipinfo((Dga_window
)dgawin
));
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) {
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 */
352 if (DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
353 return (dga_win_singlerect((Dga_window
)dgawin
));
355 /* nonviewable is always a single rectangle */
361 dgai_mbsmemb_obscured (_Dga_window dgawin
)
363 if (dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
) {
364 /* consider a zombie to be always fully obscured */
368 if (DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
369 return (dga_win_obscured((Dga_window
)dgawin
));
371 /* nonviewable can never be obscured */
378 dgai_mbsmemb_borderwidth (_Dga_window dgawin
)
380 if (dgawin
->changeMask
& DGA_CHANGE_ZOMBIE
) {
381 /* zombies don't have borders */
385 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
386 return (dga_win_borderwidth((Dga_window
)dgawin
));
388 /* multibuffers don't have borders */
394 typedef void (*DgaCursTakeDownFuncOld
)();
397 dgai_mbsmemb_curshandle (_Dga_window dgawin
, DgaCursTakeDownFunc take_down_func
,
402 /* Nonviewable drawables never have a cursor */
403 if (!DGA_LOCKSUBJ_VIEWABLE(dgawin
, dgawin
->eLockSubj
)) {
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
,
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
));
441 /* rtn is not applicable to multibuffers -- always force an activity check */
447 dgai_mbsmemb_rtnactive (_Dga_window dgawin
)
449 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
450 return (dga_rtn_active((Dga_window
)dgawin
));
452 /* rtn is not applicable to multibuffers -- never active */
458 dgai_mbsmemb_rtncached (_Dga_window dgawin
)
460 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
461 return (dga_rtn_cached((Dga_window
)dgawin
));
463 /* rtn is not applicable to multibuffers -- never cached */
469 dgai_mbsmemb_rtndevinfop (_Dga_window dgawin
)
471 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
472 return (dga_rtn_devinfo((Dga_window
)dgawin
));
474 /* rtn is not applicable to multibuffers -- no devinfo */
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
);
485 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
492 dgai_mbsmemb_rtndimensions (_Dga_window dgawin
, short *width
, short *height
,
495 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
496 dga_rtn_dimensions((Dga_window
)dgawin
, width
, height
, linebytes
);
498 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
506 dgai_mbsmemb_rtnbitsperpixel (_Dga_window dgawin
)
508 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
509 return (dga_rtn_bitsperpixel((Dga_window
)dgawin
));
511 /* rtn is not applicable to multibuffers -- values of return args are arbitrary */
517 dgai_mbsmemb_rtnpixels (_Dga_window dgawin
)
519 if (DGA_LOCKSUBJ_WINDOW(dgawin
, dgawin
->eLockSubj
)) {
520 return (dga_rtn_pixels((Dga_window
)dgawin
));
522 /* rtn is not applicable to multibuffers -- 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
;
536 *reason
= DGA_MBCHG_UNKNOWN
;
542 dgai_mbsmemb_mbsetnotify (_Dga_window dgawin
, DgaMbNotifyFunc mb_notify_func
,
545 dgawin
->mbNotifyFunc
= mb_notify_func
;
546 dgawin
->mbNotifyClientData
= client_data
;
550 dgai_mbsmemb_mbgetnotify (_Dga_window dgawin
, DgaMbNotifyFunc
*mb_notify_func
,
553 *mb_notify_func
= dgawin
->mbNotifyFunc
;
554 *client_data
= dgawin
->mbNotifyClientData
;
559 dgai_mbsmemb_mbaccessmode (_Dga_window dgawin
)
562 return (DGA_MBACCESS_NONE
);
566 infop
= (WXINFO
*) dgawin
->w_info
;
568 return (infop
->w_mbsInfo
.accessMode
);
573 dgai_mbsmemb_mbsitetypeconst (_Dga_window dgawin
)
580 infop
= (WXINFO
*) dgawin
->w_info
;
582 return (infop
->w_mbsInfo
.siteTypeConst
);
587 dgai_mbsmemb_mbsetrendbufnotify (_Dga_window dgawin
, DgaRendBufNotifyFunc rb_notify_func
,
590 dgawin
->rendBufNotifyFunc
= rb_notify_func
;
591 dgawin
->rendBufNotifyClientData
= client_data
;
595 dgai_mbsmemb_mbgetrendbufnotify (_Dga_window dgawin
, DgaRendBufNotifyFunc
*rb_notify_func
,
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
;
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
;
625 return dgawin
->c_ovlstate
;
629 dgai_mbsmemb_setovlstatenotify (_Dga_window dgawin
,
630 DgaOvlStateNotifyFunc ovlstate_notify_func
,
633 dgawin
->ovlStateNotifyFunc
= ovlstate_notify_func
;
634 dgawin
->ovlStateNotifyClientData
= client_data
;
638 dgai_mbsmemb_getovlstatenotify (_Dga_window dgawin
,
639 DgaOvlStateNotifyFunc
*ovlstate_notify_func
,
642 *ovlstate_notify_func
= dgawin
->ovlStateNotifyFunc
;
643 *client_data
= dgawin
->ovlStateNotifyClientData
;