1 /* Copyright (c) 1996, 2015, 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 * TransOvl.c - the client side interface to the Transparent Overlays
31 #include <X11/Xlibint.h>
32 #include <X11/Xutil.h>
33 #include <X11/extensions/extutil.h>
34 #include <X11/extensions/transovlstr.h>
35 #include <X11/extensions/multibuf.h>
57 #define XOvlMBXBuffers (1L << 0)
58 #define XOvlSharedPixels (1L << 1)
59 #define XOvlSharedColors (1L << 2)
61 #define XOVL_MAX_BUFFERS (~0L)
62 #define XOVL_ALL_PLANES (~0L)
63 #define XOVL_ANY_POOL (~0L)
65 #define XOvlMBXBuffers (1 << 0)
66 #define XOvlSharedPixels (1 << 1)
67 #define XOvlSharedColors (1 << 2)
69 #define XOVL_MAX_BUFFERS (~0)
70 #define XOVL_ALL_PLANES (~0)
71 #define XOVL_ANY_POOL (~0)
78 unsigned long ovplanes
;
79 unsigned long unplanes
;
80 unsigned long clutpool
;
86 XSolarisOvlPaintType paintType
;
91 XOvlVisInfo candidate
;
93 Bool partnerpreferred
;
94 XSolarisOvlSelectType searchtype
;
95 unsigned long hardfailures
;
96 unsigned long softfailures
;
109 static int close_display(Display
*dpy
, XExtCodes
*codes
);
111 static XExtensionInfo
*ext_info
;
112 static char *ext_name
= OVLNAME
;
113 static XExtensionHooks ext_hooks
= {
114 NULL
, /* create_gc */
118 NULL
, /* create_font */
119 NULL
, /* free_font */
120 close_display
, /* close_display */
121 NULL
, /* wire_to_event */
122 NULL
, /* event_to_wire */
124 NULL
, /* error_string */
128 XEXT_GENERATE_CLOSE_DISPLAY(close_display
,
132 XEXT_GENERATE_FIND_DISPLAY(find_display
,
133 ext_info
, ext_name
, &ext_hooks
,
134 OvlNumberEvents
, NULL
)
136 #define OvlCheckExtension(dpy,i,val) \
137 XextCheckExtension (dpy, i, ext_name, val)
138 #define OvlSimpleCheckExtension(dpy,i) \
139 XextSimpleCheckExtension (dpy, i, ext_name)
142 /**********************************************************************/
145 * The utility function _XVIDtoVisual could be used, but we already
146 * know the screen structure where the visual is to be found, so there
147 * is no need to scan all the screens on the display. This procedure
148 * performs a more direct scan for the visual.
161 for (depth
= scr
->depths
; depth
< (scr
->depths
+ scr
->ndepths
); depth
++) {
162 if (depth
->visuals
) {
163 for (vis
= depth
->visuals
;
164 vis
< (depth
->visuals
+ depth
->nvisuals
);
167 if (vis
->visualid
== vid
) {
169 *depthReturn
= depth
->depth
;
182 XOvlVisEnumData
*visEnumData
185 visEnumData
->nDepths
= scr
->ndepths
;
186 visEnumData
->pDepths
= scr
->depths
;
187 visEnumData
->depth
= 0;
188 visEnumData
->nVisuals
= 0;
189 visEnumData
->pVisuals
= NULL
;
195 XOvlVisEnumData
*visEnumData
,
203 if (!visEnumData
->nVisuals
) {
204 ndepths
= visEnumData
->nDepths
;
205 depth
= visEnumData
->pDepths
;
207 if (depth
->visuals
) {
216 visEnumData
->nDepths
= ndepths
- 1;
217 visEnumData
->pDepths
= depth
+ 1;
218 visEnumData
->depth
= depth
->depth
;
219 visEnumData
->nVisuals
= depth
->nvisuals
;
220 visEnumData
->pVisuals
= depth
->visuals
;
222 visEnumData
->nVisuals
--;
223 *visReturn
= visEnumData
->pVisuals
++;
224 *depthReturn
= visEnumData
->depth
;
229 static XOvlScrExtData
*
233 XExtDisplayInfo
*info
236 XOvlScrExtData
*scrextdata
;
238 xOvlGetPartnersReq
*req
;
239 xOvlGetPartnersReply rep
;
240 unsigned long nbytes
;
241 unsigned long numPairs
;
242 XOvlVisPair
*vispairs
,
247 obj
.screen
= scr
= ScreenOfDisplay(dpy
, screen
);
248 scrextdata
= (XOvlScrExtData
*)
249 XFindOnExtensionList(XEHeadOfExtensionList(obj
),
250 info
->codes
->extension
);
252 GetReq(OvlGetPartners
, req
);
253 req
->reqType
= info
->codes
->major_opcode
;
254 req
->ovlReqType
= X_OvlGetPartners
;
255 req
->screen
= screen
;
256 if (_XReply(dpy
, (xReply
*)(&rep
), 0, xFalse
)) {
257 numPairs
= rep
.numPairs
;
258 nbytes
= numPairs
* sizeof(XOvlVisPair
);
259 scrextdata
= Xmalloc(sizeof(XOvlScrExtData
));
260 vispairs
= (XOvlVisPair
*)Xmalloc(nbytes
);
261 if (scrextdata
&& vispairs
) {
262 scrextdata
->extdata
.number
= info
->codes
->extension
;
263 scrextdata
->extdata
.free_private
= NULL
;
264 scrextdata
->extdata
.private_data
= (char *)vispairs
;
265 scrextdata
->numVisPairs
= rep
.numPairs
;
266 scrextdata
->pairsRestricted
= rep
.restricted
;
267 /* BugId: 4126680 - Purify detects reads in uninitialized
268 memory generating random results. culprit was id'd to
269 be the uninitialized field visdatatypes */
270 scrextdata
->visdatatypes
= 0;
273 _XRead(dpy
, (char *)(&vidpair
), sizeof(vidpair
));
274 vispair
->overlay
.vid
= vidpair
.overlayVid
;
275 vispair
->underlay
.vid
= vidpair
.underlayVid
;
276 if ( !find_visual(scr
, vidpair
.overlayVid
,
277 &vispair
->overlay
.vis
,
278 &vispair
->overlay
.depth
)
279 || !find_visual(scr
, vidpair
.underlayVid
,
280 &vispair
->underlay
.vis
,
281 &vispair
->underlay
.depth
))
287 nbytes
= numPairs
* sizeof(XOvlVidPair
);
288 _XEatData(dpy
, nbytes
);
295 XAddToExtensionList(XEHeadOfExtensionList(obj
),
296 &(scrextdata
->extdata
));
301 nbytes
= numPairs
* sizeof(XOvlVidPair
);
302 _XEatData(dpy
, nbytes
);
311 static XOvlVisExtData
*
314 XExtDisplayInfo
*info
317 XOvlVisExtData
*visextdata
;
321 visextdata
= (XOvlVisExtData
*)
322 XFindOnExtensionList(XEHeadOfExtensionList(obj
),
323 info
->codes
->extension
);
325 visextdata
= Xmalloc(sizeof(XOvlVisExtData
));
327 visextdata
->extdata
.number
= info
->codes
->extension
;
328 visextdata
->extdata
.free_private
= NULL
;
329 visextdata
->extdata
.private_data
= NULL
;
330 visextdata
->datatypes
= 0;
331 XAddToExtensionList(XEHeadOfExtensionList(obj
),
332 &(visextdata
->extdata
));
360 Visual
*candidateVis
,
361 XExtDisplayInfo
*info
)
363 XOvlVisExtData
*candidateData
;
364 XOvlScrExtData
*scrextdata
;
368 XmbufBufferInfo
*mono_info
,
372 XOvlVisExtData
*visextdata
;
375 candidateData
= find_visdata(candidateVis
, info
);
376 if (!candidateData
) {
378 * Cannot store data for this visual, assume the worst case.
382 if (!(candidateData
->datatypes
& XOvlMBXBuffers
)) {
383 scrextdata
= find_screendata(dpy
, screen
, info
);
384 if (!(scrextdata
->visdatatypes
& XOvlMBXBuffers
)) {
386 * We haven't queried the MBX extension for the buffer
387 * data on this screen yet. Call XmbufGetScreenInfo
388 * and fill in the data for all the returned visuals.
390 scr
= ScreenOfDisplay(dpy
, screen
);
391 scrextdata
->visdatatypes
|= XOvlMBXBuffers
;
392 XmbufGetScreenInfo(dpy
, RootWindow(dpy
, screen
),
394 &nstereo
, &stereo_info
);
395 for (i
= 0; i
< nmono
; i
++) {
396 if (find_visual(scr
, mono_info
[i
].visualid
, &vis
, &depth
)) {
397 visextdata
= find_visdata(vis
, info
);
399 visextdata
->numBuffers
= mono_info
[i
].max_buffers
;
400 if (!visextdata
->numBuffers
) {
401 visextdata
->numBuffers
= XOVL_MAX_BUFFERS
;
403 visextdata
->datatypes
|= XOvlMBXBuffers
;
406 * We were unable to finish the query, so mark
407 * the data as unqueried so we can try again later.
409 scrextdata
->visdatatypes
&= ~XOvlMBXBuffers
;
416 if (!(candidateData
->datatypes
& XOvlMBXBuffers
)) {
418 * No data was returned from MBX for this visual,
419 * so fill in a default value. Only mark the
420 * data valid if the server query completed.
422 candidateData
->numBuffers
= 0;
423 if (scrextdata
->visdatatypes
& XOvlMBXBuffers
) {
424 candidateData
->datatypes
|= XOvlMBXBuffers
;
429 return candidateData
->numBuffers
;
437 XSolarisOvlSelectType searchtype
,
438 Visual
*candidateVis
,
440 XExtDisplayInfo
*info
)
442 XOvlVisExtData
*candidateData
,
444 XOvlScrExtData
*scrextdata
;
446 xOvlGetSharedPixelsReq
*req
;
447 xOvlGetSharedPixelsReply rep
;
452 XOvlVisExtData
*visextdata
;
453 unsigned long commonplanes
;
455 candidateData
= find_visdata(candidateVis
, info
);
456 partnerData
= find_visdata(partnerVis
, info
);
457 if (!candidateData
|| !partnerData
) {
459 * Cannot store data for these visuals, assume the worst case.
463 if ( !(candidateData
->datatypes
& XOvlSharedPixels
)
464 || !( partnerData
->datatypes
& XOvlSharedPixels
))
466 scrextdata
= find_screendata(dpy
, screen
, info
);
467 if (!(scrextdata
->visdatatypes
& XOvlSharedPixels
)) {
469 * We haven't queried the server for plane group data
470 * on this screen yet. Send the query and fill in
471 * the data for the visuals indicated in the reply.
473 scr
= ScreenOfDisplay(dpy
, screen
);
474 scrextdata
->visdatatypes
|= XOvlSharedPixels
;
475 GetReq(OvlGetSharedPixels
, req
);
476 req
->reqType
= info
->codes
->major_opcode
;
477 req
->ovlReqType
= X_OvlGetSharedPixels
;
478 req
->screen
= screen
;
479 if (_XReply(dpy
, (xReply
*)(&rep
), 0, xFalse
)) {
480 for (i
= 0; i
< rep
.numPGInfos
; i
++) {
481 _XRead(dpy
, (char *)(&pginfo
), sizeof(pginfo
));
482 if (find_visual(scr
, pginfo
.vid
, &vis
, &depth
)) {
483 visextdata
= find_visdata(vis
, info
);
485 visextdata
->ovplanes
= pginfo
.ovplanes
;
486 visextdata
->unplanes
= pginfo
.unplanes
;
487 visextdata
->datatypes
|= XOvlSharedPixels
;
490 * We were unable to finish the query, so mark
491 * the data as unqueried so we can try again later.
493 scrextdata
->visdatatypes
&= ~XOvlSharedPixels
;
499 if (!(candidateData
->datatypes
& XOvlSharedPixels
)) {
501 * No data was returned from the server for this
502 * visual, so fill in a default value. Only mark
503 * the data valid if the server query completed.
505 candidateData
->ovplanes
= XOVL_ALL_PLANES
;
506 candidateData
->unplanes
= XOVL_ALL_PLANES
;
507 if (scrextdata
->visdatatypes
& XOvlSharedPixels
) {
508 candidateData
->datatypes
|= XOvlSharedPixels
;
511 if (!(partnerData
->datatypes
& XOvlSharedPixels
)) {
513 * No data was returned from the server for this
514 * visual, so fill in a default value. Only mark
515 * the data valid if the server query completed.
517 partnerData
->ovplanes
= XOVL_ALL_PLANES
;
518 partnerData
->unplanes
= XOVL_ALL_PLANES
;
519 if (scrextdata
->visdatatypes
& XOvlSharedPixels
) {
520 partnerData
->datatypes
|= XOvlSharedPixels
;
525 if (searchtype
== XSolarisOvlSelectBestOverlay
) {
526 commonplanes
= candidateData
->ovplanes
& partnerData
->unplanes
;
528 commonplanes
= candidateData
->unplanes
& partnerData
->ovplanes
;
530 return commonplanes
? True
: False
;
538 Visual
*candidateVis
,
540 XExtDisplayInfo
*info
)
542 XOvlVisExtData
*candidateData
,
544 XOvlScrExtData
*scrextdata
;
546 xOvlGetSharedColorsReq
*req
;
547 xOvlGetSharedColorsReply rep
;
549 XOvlClutInfo clutinfo
;
552 XOvlVisExtData
*visextdata
;
554 candidateData
= find_visdata(candidateVis
, info
);
555 partnerData
= find_visdata(partnerVis
, info
);
556 if (!candidateData
|| !partnerData
) {
558 * Cannot store data for these visuals, assume the worst case.
562 if ( !(candidateData
->datatypes
& XOvlSharedColors
)
563 || !( partnerData
->datatypes
& XOvlSharedColors
))
565 scrextdata
= find_screendata(dpy
, screen
, info
);
566 if (!(scrextdata
->visdatatypes
& XOvlSharedColors
)) {
568 * We haven't queried the server for clut pool data
569 * on this screen yet. Send the query and fill in
570 * the data for the visuals indicated in the reply.
572 scr
= ScreenOfDisplay(dpy
, screen
);
573 scrextdata
->visdatatypes
|= XOvlSharedColors
;
574 GetReq(OvlGetSharedColors
, req
);
575 req
->reqType
= info
->codes
->major_opcode
;
576 req
->ovlReqType
= X_OvlGetSharedColors
;
577 req
->screen
= screen
;
578 if (_XReply(dpy
, (xReply
*)(&rep
), 0, xFalse
)) {
579 for (i
= 0; i
< rep
.numClutInfos
; i
++) {
580 _XRead(dpy
, (char *)(&clutinfo
), sizeof(clutinfo
));
581 if (find_visual(scr
, clutinfo
.vid
, &vis
, &depth
)) {
582 visextdata
= find_visdata(vis
, info
);
584 visextdata
->clutpool
= (1 << clutinfo
.pool
);
585 visextdata
->clutcount
= clutinfo
.count
;
586 visextdata
->datatypes
|= XOvlSharedColors
;
589 * We were unable to finish the query, so mark
590 * the data as unqueried so we can try again later.
592 scrextdata
->visdatatypes
&= ~XOvlSharedColors
;
598 if (!(candidateData
->datatypes
& XOvlSharedColors
)) {
600 * No data was returned from the server for this
601 * visual, so fill in a default value. Only mark
602 * the data valid if the server query completed.
604 candidateData
->clutpool
= XOVL_ANY_POOL
;
605 candidateData
->clutcount
= 1;
606 if (scrextdata
->visdatatypes
& XOvlSharedColors
) {
607 candidateData
->datatypes
|= XOvlSharedColors
;
610 if (!(partnerData
->datatypes
& XOvlSharedColors
)) {
612 * No data was returned from the server for this
613 * visual, so fill in a default value. Only mark
614 * the data valid if the server query completed.
616 partnerData
->clutpool
= XOVL_ANY_POOL
;
617 partnerData
->clutcount
= 1;
618 if (scrextdata
->visdatatypes
& XOvlSharedColors
) {
619 partnerData
->datatypes
|= XOvlSharedColors
;
624 return ( (candidateData
->clutpool
& partnerData
->clutpool
)
625 && candidateData
->clutcount
<= 1)
634 XOvlVisualMatch
*match
,
635 XSolarisOvlVisualCriteria
*pCriteria
,
636 XExtDisplayInfo
*info
)
638 Visual
*vis
= match
->candidate
.vis
;
639 unsigned long hardmask
,
642 unsigned long hardfailures
,
645 hardmask
= pCriteria
->hardCriteriaMask
;
646 softmask
= pCriteria
->softCriteriaMask
;
647 mask
= hardmask
| softmask
;
651 if ( (mask
& XSolarisOvlVisualClass
)
652 && (vis
->class != pCriteria
->c_class
))
654 hardfailures
|= hardmask
& XSolarisOvlVisualClass
;
655 softfailures
|= softmask
& XSolarisOvlVisualClass
;
657 if ( (mask
& XSolarisOvlDepth
)
658 && (match
->candidate
.depth
!= pCriteria
->depth
))
660 hardfailures
|= hardmask
& XSolarisOvlDepth
;
661 softfailures
|= softmask
& XSolarisOvlDepth
;
663 if ( (mask
& XSolarisOvlMinColors
)
664 && (vis
->map_entries
< pCriteria
->minColors
))
666 hardfailures
|= hardmask
& XSolarisOvlMinColors
;
667 softfailures
|= softmask
& XSolarisOvlMinColors
;
669 if ( (mask
& XSolarisOvlMinRed
)
670 && ((1 << bitcount(vis
->red_mask
)) < pCriteria
->minRed
))
672 hardfailures
|= hardmask
& XSolarisOvlMinRed
;
673 softfailures
|= softmask
& XSolarisOvlMinRed
;
675 if ( (mask
& XSolarisOvlMinGreen
)
676 && ((1 << bitcount(vis
->green_mask
)) < pCriteria
->minGreen
))
678 hardfailures
|= hardmask
& XSolarisOvlMinGreen
;
679 softfailures
|= softmask
& XSolarisOvlMinGreen
;
681 if ( (mask
& XSolarisOvlMinBlue
)
682 && ((1 << bitcount(vis
->blue_mask
)) < pCriteria
->minBlue
))
684 hardfailures
|= hardmask
& XSolarisOvlMinBlue
;
685 softfailures
|= softmask
& XSolarisOvlMinBlue
;
687 if ( (mask
& XSolarisOvlMinBitsPerRGB
)
688 && (vis
->bits_per_rgb
< pCriteria
->minBitsPerRGB
))
690 hardfailures
|= hardmask
& XSolarisOvlMinBitsPerRGB
;
691 softfailures
|= softmask
& XSolarisOvlMinBitsPerRGB
;
693 if ( (mask
& XSolarisOvlMinBuffers
)
694 && ( GetNumMBXBuffers(dpy
, match
->screen
, vis
, info
)
695 < pCriteria
->minBuffers
))
697 hardfailures
|= hardmask
& XSolarisOvlMinBuffers
;
698 softfailures
|= softmask
& XSolarisOvlMinBuffers
;
700 if ( (mask
& XSolarisOvlUnsharedPixels
)
701 && CheckSharedPixels(dpy
, match
->screen
, match
->searchtype
,
702 vis
, match
->partner
.vis
, info
))
704 hardfailures
|= hardmask
& XSolarisOvlUnsharedPixels
;
705 softfailures
|= softmask
& XSolarisOvlUnsharedPixels
;
707 if ( (mask
& XSolarisOvlUnsharedColors
)
708 && CheckSharedColors(dpy
, match
->screen
,
709 vis
, match
->partner
.vis
, info
))
711 hardfailures
|= hardmask
& XSolarisOvlUnsharedColors
;
712 softfailures
|= softmask
& XSolarisOvlUnsharedColors
;
714 if ( (mask
& XSolarisOvlPreferredPartner
)
715 && (!match
->partnerpreferred
))
717 hardfailures
|= hardmask
& XSolarisOvlPreferredPartner
;
718 softfailures
|= softmask
& XSolarisOvlPreferredPartner
;
720 match
->hardfailures
= hardfailures
;
721 match
->numhardfailures
= bitcount(hardfailures
);
722 match
->softfailures
= softfailures
;
723 match
->numsoftfailures
= bitcount(softfailures
);
727 #define XSolarisOvlAllCriteria \
728 (XSolarisOvlVisualClass | \
730 XSolarisOvlMinColors | \
731 XSolarisOvlMinRed | \
732 XSolarisOvlMinGreen | \
733 XSolarisOvlMinBlue | \
734 XSolarisOvlMinBitsPerRGB | \
735 XSolarisOvlMinBuffers | \
736 XSolarisOvlUnsharedPixels | \
737 XSolarisOvlUnsharedColors | \
738 XSolarisOvlPreferredPartner)
742 XOvlVisualMatch
*match
745 match
->hardfailures
= XSolarisOvlAllCriteria
;
746 match
->softfailures
= XSolarisOvlAllCriteria
;
747 match
->numhardfailures
=
748 match
->numsoftfailures
=
749 bitcount(XSolarisOvlAllCriteria
);
753 #define IsPerfectMatch(pm) (!((pm)->hardfailures | (pm)->softfailures))
755 #define IsQualifiedMatch(pm) (!(pm)->hardfailures)
757 #define IsBetterMatch(pm1, pm2) \
758 ( ((pm1)->numhardfailures < (pm2)->numhardfailures) \
759 || ( ((pm1)->numhardfailures == (pm2)->numhardfailures) \
760 && ((pm1)->numsoftfailures < (pm2)->numsoftfailures)))
763 #define IsPerfectPair(povm, punm) \
764 (IsPerfectMatch(povm) && IsPerfectMatch(punm))
766 #define IsQualifiedPair(povm, punm) \
767 (IsQualifiedMatch(povm) && IsQualifiedMatch(punm))
769 #define IsBetterPair(povm1, punm1, povm2, punm2) \
770 ( ( ((povm1)->numhardfailures + (punm1)->numhardfailures) \
771 < ((povm2)->numhardfailures + (punm2)->numhardfailures)) \
772 || ( ( ((povm1)->numhardfailures + (punm1)->numhardfailures) \
773 == ((povm2)->numhardfailures + (punm2)->numhardfailures)) \
774 && ( ((povm1)->numsoftfailures + (punm1)->numsoftfailures) \
775 < ((povm2)->numsoftfailures + (punm2)->numsoftfailures))))
780 XVisualInfo
*visinfoReturn
,
781 XOvlVisualMatch
*match
784 Visual
*vis
= match
->candidate
.vis
;
786 visinfoReturn
->visual
= vis
;
787 visinfoReturn
->visualid
= match
->candidate
.vid
;
788 visinfoReturn
->screen
= match
->screen
;
789 visinfoReturn
->depth
= match
->candidate
.depth
;
790 visinfoReturn
->class = vis
->class;
791 visinfoReturn
->red_mask
= vis
->red_mask
;
792 visinfoReturn
->green_mask
= vis
->green_mask
;
793 visinfoReturn
->blue_mask
= vis
->blue_mask
;
794 visinfoReturn
->colormap_size
= vis
->map_entries
;
795 visinfoReturn
->bits_per_rgb
= vis
->bits_per_rgb
;
798 /**********************************************************************/
801 XSolarisOvlQueryExtension(
807 XExtDisplayInfo
*info
= find_display(dpy
);
809 if (XextHasExtension(info
)) {
810 *event_basep
= info
->codes
->first_event
;
811 *error_basep
= info
->codes
->first_error
;
820 XSolarisOvlQueryVersion(
825 XExtDisplayInfo
*info
= find_display(dpy
);
826 xOvlQueryVersionReply rep
;
827 xOvlQueryVersionReq
*req
;
829 OvlCheckExtension(dpy
, info
, 0);
832 GetReq(OvlQueryVersion
, req
);
833 req
->reqType
= info
->codes
->major_opcode
;
834 req
->ovlReqType
= X_OvlQueryVersion
;
835 if (!_XReply(dpy
, (xReply
*)(&rep
), 0, xTrue
)) {
840 *major_versionp
= rep
.majorVersion
;
841 *minor_versionp
= rep
.minorVersion
;
849 XSolarisOvlCreateWindow(
856 unsigned int border_width
,
860 unsigned long valuemask
,
861 XSetWindowAttributes
*attr
864 XExtDisplayInfo
*info
= find_display(dpy
);
866 xOvlCreateWindowReq
*req
;
869 * REMIND: Is there a proper return value to indicate error?
871 OvlCheckExtension(dpy
, info
, (Window
) 0);
874 GetReq(OvlCreateWindow
, req
);
875 req
->reqType
= info
->codes
->major_opcode
;
876 req
->ovlReqType
= X_OvlCreateWindow
;
877 req
->parent
= parent
;
881 req
->height
= height
;
882 req
->borderWidth
= border_width
;
885 if (visual
== CopyFromParent
) {
886 req
->visual
= CopyFromParent
;
888 req
->visual
= visual
->visualid
;
890 wid
= req
->wid
= XAllocID(dpy
);
891 valuemask
&= AllMaskBits
;
892 if (req
->mask
= valuemask
) {
894 /* BugId 4130905 - There were only 3 args to this call instead of 4 -
895 the last argument attr was missing - causing Bad Xerror Request. When
896 the client lin libXext was recompiled, the bus error caused the
897 client code to fail. Big change between 2.6 and 2.7 file. */
899 _XProcessWindowAttributes(dpy
, (xChangeWindowAttributesReq
*)req
,
909 XSolarisOvlIsOverlayWindow(
914 XExtDisplayInfo
*info
= find_display(dpy
);
915 xOvlIsOverlayWindowReq
*req
;
916 xOvlIsOverlayWindowReply rep
;
918 OvlCheckExtension(dpy
, info
, False
);
921 GetReq(OvlIsOverlayWindow
, req
);
922 req
->reqType
= info
->codes
->major_opcode
;
923 req
->ovlReqType
= X_OvlIsOverlayWindow
;
925 if (_XReply (dpy
, (xReply
*)(&rep
), 0, xTrue
) == 0) {
926 rep
.isoverlay
= False
;
930 return rep
.isoverlay
;
935 XSolarisOvlSetWindowTransparent(
939 XExtDisplayInfo
*info
= find_display(dpy
);
940 xOvlSetWindowTransparentReq
*req
;
942 OvlSimpleCheckExtension(dpy
, info
);
945 GetReq(OvlSetWindowTransparent
, req
);
946 req
->reqType
= info
->codes
->major_opcode
;
947 req
->ovlReqType
= X_OvlSetWindowTransparent
;
956 XSolarisOvlSetPaintType(
959 XSolarisOvlPaintType paintType
962 XExtDisplayInfo
*info
= find_display(dpy
);
963 XOvlGCExtData
*gcextdata
;
964 xOvlSetPaintTypeReq
*req
;
967 OvlCheckExtension(dpy
, info
, 0);
971 gcextdata
= (XOvlGCExtData
*)
972 XFindOnExtensionList(XEHeadOfExtensionList(obj
),
973 info
->codes
->extension
);
975 if (paintType
== XSolarisOvlPaintOpaque
) {
977 * No use creating an extension structure just to hold
984 gcextdata
= Xmalloc(sizeof(XOvlGCExtData
));
990 gcextdata
->extdata
.number
= info
->codes
->extension
;
991 gcextdata
->extdata
.free_private
= NULL
;
992 gcextdata
->extdata
.private_data
= NULL
;
993 gcextdata
->paintType
= XSolarisOvlPaintOpaque
;
994 XAddToExtensionList(XEHeadOfExtensionList(obj
), &(gcextdata
->extdata
));
996 if (gcextdata
->paintType
!= paintType
) {
997 gcextdata
->paintType
= paintType
;
999 GetReq(OvlSetPaintType
, req
);
1000 req
->reqType
= info
->codes
->major_opcode
;
1001 req
->ovlReqType
= X_OvlSetPaintType
;
1003 req
->paintType
= paintType
;
1011 XSolarisOvlPaintType
1012 XSolarisOvlGetPaintType(
1017 XExtDisplayInfo
*info
= find_display(dpy
);
1018 XOvlGCExtData
*gcextdata
;
1019 XSolarisOvlPaintType paintType
;
1022 OvlCheckExtension(dpy
, info
, XSolarisOvlPaintOpaque
);
1026 gcextdata
= (XOvlGCExtData
*)
1027 XFindOnExtensionList(XEHeadOfExtensionList(obj
),
1028 info
->codes
->extension
);
1029 paintType
= (gcextdata
) ? gcextdata
->paintType
: XSolarisOvlPaintOpaque
;
1037 XSolarisOvlCopyPaintType(
1045 unsigned int height
,
1048 unsigned long action_mask
,
1049 unsigned long planemask
1052 XExtDisplayInfo
*info
= find_display(dpy
);
1053 xOvlCopyPaintTypeReq
*req
;
1055 OvlCheckExtension(dpy
, info
, 0);
1059 GetReq(OvlCopyPaintType
, req
);
1060 req
->reqType
= info
->codes
->major_opcode
;
1061 req
->ovlReqType
= X_OvlCopyPaintType
;
1062 req
->srcDrawable
= src
;
1063 req
->dstDrawable
= dst
;
1067 req
->destX
= dest_x
;
1068 req
->destY
= dest_y
;
1070 req
->height
= height
;
1071 req
->action_mask
= action_mask
;
1072 req
->bitPlane
= planemask
;
1080 XSolarisOvlCopyAreaAndPaintType(
1083 Drawable paintTypeSrc
,
1085 Drawable paintTypeDst
,
1093 unsigned int height
,
1098 unsigned long action_mask
,
1099 unsigned long planemask
)
1101 XExtDisplayInfo
*info
= find_display(dpy
);
1102 xOvlCopyAreaAndPaintTypeReq
*req
;
1104 OvlCheckExtension(dpy
, info
, 0);
1107 FlushGC(dpy
, colorGC
);
1108 if (paintTypeGC
&& (paintTypeGC
!= colorGC
))
1109 FlushGC(dpy
, paintTypeGC
);
1110 GetReq(OvlCopyAreaAndPaintType
, req
);
1111 req
->reqType
= info
->codes
->major_opcode
;
1112 req
->ovlReqType
= X_OvlCopyAreaAndPaintType
;
1113 req
->colorSrc
= colorSrc
;
1114 req
->paintTypeSrc
= paintTypeSrc
;
1115 req
->colorDst
= colorDst
;
1116 req
->paintTypeDst
= paintTypeDst
;
1117 req
->colorGC
= colorGC
->gid
;
1118 req
->paintTypeGC
= (paintTypeGC
) ? paintTypeGC
->gid
: None
;
1119 req
->colorSrcX
= colorSrcX
;
1120 req
->colorSrcY
= colorSrcY
;
1121 req
->paintTypeSrcX
= paintTypeSrcX
;
1122 req
->paintTypeSrcY
= paintTypeSrcY
;
1123 req
->colorDstX
= colorDstX
;
1124 req
->colorDstY
= colorDstY
;
1125 req
->paintTypeDstX
= paintTypeDstX
;
1126 req
->paintTypeDstY
= paintTypeDstY
;
1128 req
->height
= height
;
1129 req
->action_mask
= action_mask
;
1130 req
->bitPlane
= planemask
;
1144 unsigned int height
,
1148 XExtDisplayInfo
*info
= find_display(dpy
);
1149 xOvlReadScreenReq
*req
;
1150 xOvlReadScreenReply rep
;
1155 OvlCheckExtension(dpy
, info
, NULL
);
1158 GetReq (OvlReadScreen
, req
);
1159 req
->reqType
= info
->codes
->major_opcode
;
1160 req
->ovlReqType
= X_OvlReadScreen
;
1165 req
->height
= height
;
1166 req
->includeCursor
= includeCursor
;
1168 if ( (_XReply(dpy
, (xReply
*)(&rep
), 0, xFalse
) == 0)
1169 || (rep
.length
== 0))
1175 if (rep
.length
< (INT_MAX
>> 2)) {
1176 nbytes
= (long)rep
.length
<< 2;
1177 data
= Xmalloc((size_t)nbytes
);
1182 _XEatDataWords(dpy
, rep
.length
);
1187 _XReadPad (dpy
, data
, nbytes
);
1188 image
= XCreateImage(dpy
, None
,
1189 24, ZPixmap
, 0, data
, width
, height
,
1190 dpy
->bitmap_pad
, 0);
1192 image
->red_mask
= READSCREEN_REDMASK
;
1193 image
->green_mask
= READSCREEN_GREENMASK
;
1194 image
->blue_mask
= READSCREEN_BLUEMASK
;
1204 XSolarisOvlSelectStatus
1205 XSolarisOvlSelectPartner(
1209 XSolarisOvlSelectType vistype
,
1211 XSolarisOvlVisualCriteria
*pCriteria
,
1212 XVisualInfo
*visinfoReturn
,
1213 unsigned long *unmetCriteriaReturn
1216 XExtDisplayInfo
*info
= find_display(dpy
);
1218 XOvlScrExtData
*scrextdata
;
1219 XOvlVisPair
*vispair
;
1223 XOvlVisInfo partner
;
1224 XOvlVisualMatch curMatch
,
1227 XOvlVisEnumData visEnumData
;
1228 unsigned long hardpreferred
,
1231 OvlCheckExtension(dpy
, info
, XSolarisOvlFailure
);
1234 scr
= ScreenOfDisplay(dpy
, screen
);
1235 scrextdata
= find_screendata(dpy
, screen
, info
);
1239 return XSolarisOvlFailure
;
1241 curMatch
.screen
= screen
;
1242 curMatch
.partner
.vid
= vid
;
1243 if (!find_visual(scr
, vid
, &curMatch
.partner
.vis
, &curMatch
.partner
.depth
))
1247 return XSolarisOvlFailure
;
1249 curMatch
.searchtype
= vistype
;
1250 SetWorstMatch(&bestMatch
);
1251 for (i
= numCriteria
; i
> 0; --i
) {
1252 SetWorstMatch(&betterMatch
);
1253 curMatch
.partnerpreferred
= True
;
1254 vispair
= (XOvlVisPair
*)(scrextdata
->extdata
.private_data
);
1255 for (j
= scrextdata
->numVisPairs
; j
> 0; --j
) {
1257 ((vistype
== XSolarisOvlSelectBestOverlay
)
1258 ? (vispair
->underlay
.vid
)
1259 : (vispair
->overlay
.vid
)))
1261 curMatch
.candidate
= (vistype
== XSolarisOvlSelectBestOverlay
)
1263 : vispair
->underlay
;
1264 ComputeVisualMatch(dpy
, &curMatch
, pCriteria
, info
);
1265 if (IsPerfectMatch(&curMatch
)) {
1266 set_visinfo(visinfoReturn
, &curMatch
);
1269 return XSolarisOvlSuccess
;
1271 if (IsBetterMatch(&curMatch
, &betterMatch
)) {
1272 betterMatch
= curMatch
;
1277 if (!scrextdata
->pairsRestricted
) {
1278 curMatch
.partnerpreferred
= False
;
1279 vis_enum_init(scr
, &visEnumData
);
1280 while (vis_enum_next(&visEnumData
,
1281 &curMatch
.candidate
.vis
,
1282 &curMatch
.candidate
.depth
))
1284 curMatch
.candidate
.vid
= curMatch
.candidate
.vis
->visualid
;
1285 ComputeVisualMatch(dpy
, &curMatch
, pCriteria
, info
);
1286 if (IsPerfectMatch(&curMatch
)) {
1287 set_visinfo(visinfoReturn
, &curMatch
);
1290 return XSolarisOvlSuccess
;
1292 if (IsBetterMatch(&curMatch
, &betterMatch
)) {
1293 betterMatch
= curMatch
;
1297 if (IsQualifiedMatch(&betterMatch
)) {
1298 set_visinfo(visinfoReturn
, &betterMatch
);
1299 *unmetCriteriaReturn
= betterMatch
.softfailures
;
1302 return XSolarisOvlQualifiedSuccess
;
1304 if (IsBetterMatch(&betterMatch
, &bestMatch
)) {
1305 bestMatch
= betterMatch
;
1309 *unmetCriteriaReturn
= bestMatch
.hardfailures
| bestMatch
.softfailures
;
1312 return XSolarisOvlCriteriaFailure
;
1316 XSolarisOvlSelectStatus
1317 XSolarisOvlSelectPair(
1321 XSolarisOvlPairCriteria
*pCriteria
,
1322 XVisualInfo
*ovVisinfoReturn
,
1323 XVisualInfo
*unVisinfoReturn
,
1324 unsigned long *unmetOvCriteriaReturn
,
1325 unsigned long *unmetUnCriteriaReturn
)
1327 XExtDisplayInfo
*info
= find_display(dpy
);
1329 XOvlScrExtData
*scrextdata
;
1330 XOvlVisPair
*vispair
;
1333 XOvlVisualMatch curOvMatch
, curUnMatch
,
1334 betterOvMatch
, betterUnMatch
,
1335 bestOvMatch
, bestUnMatch
;
1336 XOvlVisEnumData ovVisEnumData
, unVisEnumData
;
1338 OvlCheckExtension(dpy
, info
, XSolarisOvlFailure
);
1340 scr
= ScreenOfDisplay(dpy
, screen
);
1341 scrextdata
= find_screendata(dpy
, screen
, info
);
1345 return XSolarisOvlFailure
;
1347 curOvMatch
.screen
= curUnMatch
.screen
= screen
;
1348 curOvMatch
.searchtype
= XSolarisOvlSelectBestUnderlay
;
1349 curUnMatch
.searchtype
= XSolarisOvlSelectBestOverlay
;
1350 SetWorstMatch(&bestOvMatch
);
1351 SetWorstMatch(&bestUnMatch
);
1352 for (i
= numCriteria
; i
> 0; --i
) {
1353 SetWorstMatch(&betterOvMatch
);
1354 SetWorstMatch(&betterUnMatch
);
1355 curOvMatch
.partnerpreferred
= curUnMatch
.partnerpreferred
= True
;
1356 vispair
= (XOvlVisPair
*)(scrextdata
->extdata
.private_data
);
1357 for (j
= scrextdata
->numVisPairs
; j
> 0; --j
) {
1358 curOvMatch
.candidate
= curUnMatch
.partner
= vispair
->overlay
;
1359 curOvMatch
.partner
= curUnMatch
.candidate
= vispair
->underlay
;
1360 ComputeVisualMatch(dpy
, &curOvMatch
,
1361 &pCriteria
->overlayCriteria
, info
);
1362 ComputeVisualMatch(dpy
, &curUnMatch
,
1363 &pCriteria
->underlayCriteria
, info
);
1364 if (IsPerfectPair(&curOvMatch
, &curUnMatch
)) {
1365 set_visinfo(unVisinfoReturn
, &curUnMatch
);
1366 set_visinfo(ovVisinfoReturn
, &curOvMatch
);
1369 return XSolarisOvlSuccess
;
1371 if (IsBetterPair(&curOvMatch
, &curUnMatch
,
1372 &betterOvMatch
, &betterUnMatch
))
1374 betterOvMatch
= curOvMatch
;
1375 betterUnMatch
= curUnMatch
;
1379 if (!scrextdata
->pairsRestricted
) {
1380 curOvMatch
.partnerpreferred
= False
;
1381 curUnMatch
.partnerpreferred
= False
;
1382 vis_enum_init(scr
, &ovVisEnumData
);
1383 while (vis_enum_next(&ovVisEnumData
,
1384 &curOvMatch
.candidate
.vis
,
1385 &curOvMatch
.candidate
.depth
))
1387 curOvMatch
.candidate
.vid
= curOvMatch
.candidate
.vis
->visualid
;
1388 curUnMatch
.partner
= curOvMatch
.candidate
;
1389 vis_enum_init(scr
, &unVisEnumData
);
1390 while (vis_enum_next(&unVisEnumData
,
1391 &curUnMatch
.candidate
.vis
,
1392 &curUnMatch
.candidate
.depth
))
1394 curUnMatch
.candidate
.vid
=
1395 curUnMatch
.candidate
.vis
->visualid
;
1396 curOvMatch
.partner
= curUnMatch
.candidate
;
1397 ComputeVisualMatch(dpy
, &curOvMatch
,
1398 &pCriteria
->overlayCriteria
, info
);
1399 ComputeVisualMatch(dpy
, &curUnMatch
,
1400 &pCriteria
->underlayCriteria
, info
);
1401 if (IsPerfectPair(&curOvMatch
, &curUnMatch
)) {
1402 set_visinfo(unVisinfoReturn
, &curUnMatch
);
1403 set_visinfo(ovVisinfoReturn
, &curOvMatch
);
1406 return XSolarisOvlSuccess
;
1408 if (IsBetterPair(&curOvMatch
, &curUnMatch
,
1409 &betterOvMatch
, &betterUnMatch
))
1411 betterOvMatch
= curOvMatch
;
1412 betterUnMatch
= curUnMatch
;
1417 if (IsQualifiedPair(&betterOvMatch
, &betterUnMatch
)) {
1418 set_visinfo(ovVisinfoReturn
, &betterOvMatch
);
1419 set_visinfo(unVisinfoReturn
, &betterUnMatch
);
1420 *unmetOvCriteriaReturn
= betterOvMatch
.softfailures
;
1421 *unmetUnCriteriaReturn
= betterUnMatch
.softfailures
;
1424 return XSolarisOvlQualifiedSuccess
;
1426 if (IsBetterPair(&betterOvMatch
, &betterUnMatch
,
1427 &bestOvMatch
, &bestUnMatch
))
1429 bestOvMatch
= betterOvMatch
;
1430 bestUnMatch
= betterUnMatch
;
1434 *unmetOvCriteriaReturn
= bestOvMatch
.hardfailures
|bestOvMatch
.softfailures
;
1435 *unmetUnCriteriaReturn
= bestUnMatch
.hardfailures
|bestUnMatch
.softfailures
;
1438 return XSolarisOvlCriteriaFailure
;