1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0023792: 3D viewer window content is blended with Linux desktop

Eliminate tabulation symbols
Prefer 24-bit visual over 32-bit
This commit is contained in:
kgv 2013-03-07 13:30:09 +04:00
parent 9b308cd3f6
commit b1fa9f3841

View File

@ -19,50 +19,10 @@
#include <config.h>
#endif
#define CTS17988 /*GG_240697
// Ne pas chercher a ajuster la profondeur du visual
// recherche en TrueColor par rapport aux MultiBuffers disponibles
*/
#define GG250997 /*
// Pour le 2D et plans overlay prendre de
// preference une colormap existante afin
// d'eviter des pb d'installation sur la nouvelle
// colormap.
*/
#define TEST /*051297
// Ameliorer la recuperation de la colormap OVERLAY lorsque
// celle ci est invalide voir ligne 925-928
*/
#define PURIFY /*GG+STT 110199
// Avoid memory leak
*/
#define IMP040100 /*GG_040100 Overlay planes are not usable
// when the alone installed colormap is used
// by the default root visual.
*/
#include <Xw_Extension.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
# include <X11/extensions/multibuf.h>
#endif
#include <X11/Xmu/StdCmap.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_COLORMAP
#define TRACE_CLOSE_COLORMAP
#define TRACE_SET_COLORMAP_MAPPING
#endif
/*
XW_EXT_COLORMAP* Xw_def_colormap(adisplay,pclass,ncolor,basemap,mapping):
XW_EXT_DISPLAY *adisplay Extended Display structure
@ -140,17 +100,8 @@ static char svalue[80] ;
static Atom DefaultAtom = 0 ;
static const char *XW_RGB_BEST_MAP = "Xw_RGB_BEST_MAP" ;
#ifdef XW_PROTOTYPE
void* Xw_def_colormap (void* adisplay,Xw_TypeOfVisual pclass,
int ncolor,Aspect_Handle basemap,Xw_TypeOfMapping mapping)
#else
void* Xw_def_colormap (adisplay,pclass,ncolor,basemap,mapping)
void *adisplay ;
Xw_TypeOfVisual pclass ;
int ncolor ;
Aspect_Handle basemap ;
Xw_TypeOfMapping mapping ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_COLORMAP *pcolormap = NULL ;
@ -385,11 +336,6 @@ RESTART :
}
for( i=0 ; i<n ; i++,b++ ) usrpixels[i] = usrpixels[b] ;
acolor = n ;
#ifdef TRACE_DEF_COLORMAP
if( Xw_get_trace() ) {
Xw_set_error(105,"Xw_def_colormap",&acolor) ;
}
#endif
}
_CINFO.base_pixel = usrpixels[0] ;
@ -475,31 +421,16 @@ RESTART :
Xw_set_colormap_mapping(pcolormap,mapping) ;
Xw_def_highlight_color(pcolormap,1.,1.,1.) ;
#ifdef TRACE_DEF_COLORMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_colormap(%lx,%d,%d)\n",
(long ) pcolormap,(long ) adisplay,pclass,acolor) ;
}
#endif
return (pcolormap);
}
static XW_EXT_COLORMAP *PcolormapList =NULL ;
#ifdef XW_PROTOTYPE
//! Create and Insert one Extended colormap structure in the
//! EXtended colormap List
//! returns Extended colormap address if successful
//! or NULL if Bad Allocation
XW_EXT_COLORMAP* Xw_add_colormap_structure(int size)
#else
XW_EXT_COLORMAP* Xw_add_colormap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended colormap structure in the
EXtended colormap List
returns Extended colormap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*) Xw_malloc(size) ;
//int i ;
@ -541,30 +472,17 @@ XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*) Xw_malloc(size) ;
return (pcolormap) ;
}
#ifdef XW_PROTOTYPE
//! Get the NEXT ColorMap structure from the List
//! returns Extended colormap address if successful
//! or NULL if No MORE Colormap is found
XW_EXT_COLORMAP* Xw_get_colormap_structure(XW_EXT_COLORMAP* pcolormap)
#else
XW_EXT_COLORMAP* Xw_get_colormap_structure(pcolormap)
XW_EXT_COLORMAP *pcolormap ;
#endif /*XW_PROTOTYPE*/
/*
Get the NEXT ColorMap structure from the List
returns Extended colormap address if successful
or NULL if No MORE Colormap is found
*/
{
if( pcolormap ) return (XW_EXT_COLORMAP*)pcolormap->link ;
else return (PcolormapList) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_colormap(void* acolormap)
#else
XW_STATUS Xw_close_colormap(acolormap)
void *acolormap;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XW_STATUS status ;
@ -577,28 +495,14 @@ XW_STATUS status ;
status = Xw_del_colormap_structure(pcolormap) ;
#ifdef TRACE_CLOSE_COLORMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_colormap(%lx)\n",status,(long ) pcolormap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
//! Remove the Extended colormap address from the Extended List and
//! Free the Extended Colormap
//! returns ERROR if the colormap address is not Found in the list
//! returns SUCCESS if successful
XW_STATUS Xw_del_colormap_structure(XW_EXT_COLORMAP* pcolormap)
#else
XW_STATUS Xw_del_colormap_structure(pcolormap)
XW_EXT_COLORMAP *pcolormap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended colormap address from the Extended List and
Free the Extended Colormap
returns ERROR if the colormap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_COLORMAP *fcolormap;
//int i ;
@ -641,27 +545,18 @@ XW_EXT_COLORMAP *fcolormap;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
//! Set MAPPING Colormap mode
//! if mapping is SIMPLERAMP all color cells access is done
//! across the PIXEL index array .
//! if mapping is BESTRAMP all color cells access is done
//! across the PIXEL index array and an HIGHLIGHT plane is created .
//! if mapping is HARDRAMP all color cells access is done
//! directly (Make becarefull !!)
//! if mapping is COLORCUBE all color cells access is done
//! across a ColorCube PIXEL index array .
//! if mapping is READONLY all color cells access is done
//! across a readonly PIXEL index array without color allocation.
XW_STATUS Xw_set_colormap_mapping(void* acolormap,Xw_TypeOfMapping mode)
#else
XW_STATUS Xw_set_colormap_mapping(acolormap,mode)
void *acolormap ;
Xw_TypeOfMapping mode ;
#endif /*XW_PROTOTYPE*/
/*
Set MAPPING Colormap mode
if mapping is SIMPLERAMP all color cells access is done
across the PIXEL index array .
if mapping is BESTRAMP all color cells access is done
across the PIXEL index array and an HIGHLIGHT plane is created .
if mapping is HARDRAMP all color cells access is done
directly (Make becarefull !!)
if mapping is COLORCUBE all color cells access is done
across a ColorCube PIXEL index array .
if mapping is READONLY all color cells access is done
across a readonly PIXEL index array without color allocation.
*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
int status,cstatus,gstatus ;
@ -941,7 +836,7 @@ int nmap;
pcolormap->define[i] = FREECOLOR ;
}
}
#ifdef GG250997
if( mode == Xw_TOM_READONLY ) {
if( !DefaultAtom ) DefaultAtom = XInternAtom(_CDISPLAY,
XW_RGB_BEST_MAP,True) ;
@ -962,7 +857,7 @@ int nmap;
int error,gravity;
// unsigned long pixel;
color.red = color.green = color.blue = 0xFFFF;
#ifdef TEST
char *serror;
Xw_print_error();
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,True) ;
@ -970,9 +865,6 @@ int nmap;
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,False) ;
serror = Xw_get_error(&error,&gravity);
if( status && (error < 1000) ) {
#else
if( XAllocColor(_CDISPLAY,cinfo->colormap,&color) ) {
#endif
if( _CINFO.colormap != cinfo->colormap ) {
if( _CINFO.colormap && (_CINFO.colormap != _CCOLORMAP) ) {
XFreeColormap(_CDISPLAY,_CINFO.colormap) ;
@ -992,10 +884,10 @@ int nmap;
} else {
if( Xw_get_trace() )
printf(" Xw_set_colormap_mapping.BAD registered COLORMAP 0x%lx\n",cinfo->colormap);
#ifdef TEST
status = False;
Xw_print_error();
#endif
}
}
}
@ -1030,7 +922,7 @@ int nmap;
if( pinfo ) XFree(pinfo);
XInstallColormap(_CDISPLAY,_CINFO.colormap);
}
#endif
break ;
case Xw_TOM_BESTRAMP :
@ -1330,14 +1222,6 @@ int nmap;
switch (SetColorCube) {
case 'N' :
#ifdef TRACE_SET_COLORMAP_MAPPING
if( Xw_get_trace() ) printf(
" Xw_SET_COLOR_CUBE(%ld,%ld,%ld,%ld),(%ld,%ld,%ld,%ld)\n",
_CINFO.base_pixel,_CINFO.red_max,
_CINFO.green_max,_CINFO.blue_max,
_CGINFO.base_pixel,_CGINFO.red_max,
_CGINFO.green_max,_CGINFO.blue_max) ;
#endif
break ;
case 'Y' :
if( !DefaultAtom )
@ -1345,14 +1229,6 @@ int nmap;
XW_RGB_BEST_MAP,False) ;
XSetRGBColormaps(_CDISPLAY,_CROOT,
pinfo,nmap,DefaultAtom) ;
#ifdef TRACE_SET_COLORMAP_MAPPING
if( Xw_get_trace() ) printf(
" Xw_SET_STANDARD_COLOR_CUBE(%ld,%ld,%ld,%ld),(%ld,%ld,%ld,%ld)\n",
_CINFO.base_pixel,_CINFO.red_max,
_CINFO.green_max,_CINFO.blue_max,
_CGINFO.base_pixel,_CGINFO.red_max,
_CGINFO.green_max,_CGINFO.blue_max) ;
#endif
break ;
case 'T' :
if( !DefaultAtom )
@ -1361,14 +1237,6 @@ int nmap;
XSetRGBColormaps(_CDISPLAY,_CROOT,
pinfo,nmap,DefaultAtom) ;
XSetCloseDownMode(_CDISPLAY,RetainTemporary) ;
#ifdef TRACE_SET_COLORMAP_MAPPING
if( Xw_get_trace() ) printf(
" Xw_SET_TEMPORARY_COLOR_CUBE(%ld,%ld,%ld,%ld),(%ld,%ld,%ld,%ld)\n",
_CINFO.base_pixel,_CINFO.red_max,
_CINFO.green_max,_CINFO.blue_max,
_CGINFO.base_pixel,_CGINFO.red_max,
_CGINFO.green_max,_CGINFO.blue_max) ;
#endif
break ;
case 'P' :
if( !DefaultAtom )
@ -1395,29 +1263,19 @@ int nmap;
XFlush(_CDISPLAY) ;
#ifdef TRACE_SET_COLORMAP_MAPPING
if( Xw_get_trace() ) {
printf(" Xw_set_color_mapping(%lx,%d)\n",(long ) pcolormap,mode) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XVisualInfo* Xw_get_visual_info(XW_EXT_DISPLAY* pdisplay,Xw_TypeOfVisual pclass)
#else
XVisualInfo* Xw_get_visual_info(pdisplay,pclass)
XW_EXT_DISPLAY *pdisplay ;
Xw_TypeOfVisual pclass ;
#endif /*XW_PROTOTYPE*/
/*
Return the visual Information matching with the specified class
or NULL if class is not founded on this Display .
*/
//! Return the visual Information matching with the specified class
//! or NULL if class is not founded on this Display.
XVisualInfo* Xw_get_visual_info (XW_EXT_DISPLAY* pdisplay,
Xw_TypeOfVisual pclass)
{
Xw_TypeOfVisual class1 = pclass,class2 = Xw_TOV_DEFAULT ;
XVisualInfo *vinfo = NULL,*ginfo = NULL,info1,info2 ;
Xw_TypeOfVisual class1 = pclass;
Xw_TypeOfVisual class2 = Xw_TOV_DEFAULT;
XVisualInfo* vinfo = NULL;
XVisualInfo* ginfo = NULL;
XVisualInfo info1, info2;
int i, ninfo;
long mask1 = 0,mask2 = 0;
unsigned long backpixel;
@ -1449,21 +1307,10 @@ unsigned long backpixel;
Xw_TOV_PSEUDOCOLOR,&backpixel);
return ginfo;
case Xw_TOV_PREFERRED_TRUECOLOR :
#ifdef OLD
if( MaxCmapsOfScreen(_DSCREEN) > 1 ) {
class1 = Xw_TOV_TRUECOLOR ;
class2 = Xw_TOV_PSEUDOCOLOR ;
mask2 |= VisualColormapSizeMask;
info2.colormap_size = 256;
} else {
class1 = _DCLASS ;
}
#else
class1 = Xw_TOV_TRUECOLOR ;
class2 = Xw_TOV_PSEUDOCOLOR ;
mask2 |= VisualColormapSizeMask;
info2.colormap_size = 256;
#endif
break;
case Xw_TOV_PREFERRED_OVERLAY :
class1 = Xw_TOV_PSEUDOCOLOR ;
@ -1477,91 +1324,59 @@ unsigned long backpixel;
break ;
}
if( !ginfo ) {
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
XmbufBufferInfo *pmono = NULL,*pstereo = NULL;
int nmono=0,nstereo=0;
#endif
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
XmbufGetScreenInfo(_DDISPLAY, _DROOT, &nmono, &pmono,
&nstereo, &pstereo);
#endif
#if defined(__cplusplus) || defined(c_plusplus)
if (ginfo == NULL)
{
info1.c_class = class1;
#else
info1.class = class1 ;
#endif
info1.screen = DefaultScreen(_DDISPLAY);
mask1 |= VisualClassMask | VisualScreenMask ;
vinfo = XGetVisualInfo(_DDISPLAY,mask1,&info1,&ninfo) ;
if( ninfo ) {
if (ninfo > 0)
{
ginfo = vinfo;
for( i=1 ; i<ninfo ; i++ ) {
if( (vinfo[i].depth > ginfo->depth) ||
(vinfo[i].visualid == _DVISUAL->visualid) ) {
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
if( pmono ) {
for( j=0 ; j<nmono ; j++ ) {
if( (pmono[j].visualid == vinfo[i].visualid) &&
((pmono[j].max_buffers == 0) ||
(pmono[j].max_buffers > 1)) ) {
ginfo = &vinfo[i];
break;
}
}
} else
#endif
for (i = 1; i < ninfo; i++)
{
if ((vinfo[i].depth > ginfo->depth && !(vinfo[i].depth == 32 && ginfo->depth == 24))
|| (vinfo[i].depth == 24 && ginfo->depth == 32) // prefer 24-bit depth over 32-bit - we do not need blend window content with desktop (see CR23792)
|| (vinfo[i].visualid == _DVISUAL->visualid))
{
ginfo = &vinfo[i];
}
}
if( (ginfo->depth < TrueColorMinDepth) &&
(class1 == Xw_TOV_TRUECOLOR) ) {
if ((ginfo->depth < TrueColorMinDepth)
&& (class1 == Xw_TOV_TRUECOLOR))
{
XFree ((char* )vinfo);
ginfo = vinfo = NULL;
}
}
if( !ginfo && (class2 != Xw_TOV_DEFAULT) ) {
#if defined(__cplusplus) || defined(c_plusplus)
if (ginfo == NULL && (class2 != Xw_TOV_DEFAULT))
{
info2.c_class = class2;
#else
info2.class = class2 ;
#endif
info2.screen = DefaultScreen(_DDISPLAY);
mask2 |= VisualClassMask | VisualScreenMask;
vinfo = XGetVisualInfo(_DDISPLAY,mask2,&info2,&ninfo);
if( ninfo ) {
if (ninfo > 0)
{
ginfo = vinfo ;
for( i=1 ; i<ninfo ; i++ ) {
if( vinfo[i].depth > ginfo->depth ) {
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
if( pmono ) {
for( j=0 ; j<nmono ; j++ ) {
if( (pmono[j].visualid == vinfo[i].visualid) &&
((pmono[j].max_buffers == 0) ||
(pmono[j].max_buffers > 1)) ) {
ginfo = &vinfo[i];
break;
}
}
} else
#endif
for (i = 1; i < ninfo; i++)
{
if ((vinfo[i].depth > ginfo->depth && !(vinfo[i].depth == 32 && ginfo->depth == 24))
|| (vinfo[i].depth == 24 && ginfo->depth == 32)) // prefer 24-bit depth over 32-bit)
{
ginfo = &vinfo[i];
}
}
if( (ginfo->depth < TrueColorMinDepth) &&
(class2 == Xw_TOV_TRUECOLOR) ) {
if ((ginfo->depth < TrueColorMinDepth)
&& (class2 == Xw_TOV_TRUECOLOR))
{
XFree((char*)vinfo);
ginfo = vinfo = NULL;
}
}
}
#if (!defined (CTS17988)) && defined(HAVE_X11_EXTENSIONS_MULTIBUF_H)
if( pmono ) XFree(pmono);
if( pstereo ) XFree(pstereo);
#endif
}
if( ginfo ) {
@ -1579,18 +1394,9 @@ unsigned long backpixel;
return (ginfo) ;
}
#ifdef XW_PROTOTYPE
//! Return the Overlay visual Information matching with the specified class
//! or NULL if the overlay class is not founded on this Display.
XVisualInfo* Xw_get_overlay_visual_info(XW_EXT_DISPLAY* pdisplay,Xw_TypeOfVisual /*pclass*/,unsigned long *backpixel)
#else
XVisualInfo* Xw_get_overlay_visual_info(pdisplay,pclass,backpixel)
XW_EXT_DISPLAY *pdisplay ;
Xw_TypeOfVisual pclass ;
unsigned long *backpixel;
#endif /*XW_PROTOTYPE*/
/*
Return the Overlay visual Information matching with the specified class
or NULL if the overlay class is not founded on this Display .
*/
{
XVisualInfo *vinfo = NULL,*ginfo = NULL,tinfo ;
int ninfo;
@ -1628,9 +1434,9 @@ Atom oatom = XInternAtom(_DDISPLAY, "SERVER_OVERLAY_VISUALS", True);
}
}
}
#ifdef PURIFY
if( prop.string && (status == Success) ) Xw_free(prop.string);
#endif
} else if( (pdisplay->server == XW_SERVER_IS_SUN) && EnableSunOverlay ) {
int mOptCode,fEvent,fError;
if( XQueryExtension(_DDISPLAY,"SUN_OVL",&mOptCode,&fEvent,&fError) ) {
@ -1645,17 +1451,11 @@ Atom oatom = XInternAtom(_DDISPLAY, "SERVER_OVERLAY_VISUALS", True);
}
}
#ifdef IMP040100
if( ginfo && MaxCmapsOfScreen(_DSCREEN) < 2 &&
ginfo->visualid != _DVISUAL->visualid &&
#if defined(__cplusplus) || defined(c_plusplus)
ginfo->c_class == _DCLASS )
#else
ginfo->class == _DCLASS )
#endif
{
XFree(ginfo); ginfo = NULL;
}
#endif
return ginfo;
}