30 int screen = XDefaultScreen( display.
x() ) ;
31 ::Visual * vp = XDefaultVisual( display.
x() , screen ) ;
32 if( vp ==
nullptr )
throw Error(
"XDefaultVisual" ) ;
33 init( display , vp->visualid ) ;
38 init( display , info.visual->visualid ) ;
41 void GX::Visual::init(
Display & display , ::VisualID
id )
43 std::list<Info> info_list = infoList( display ) ;
44 std::list<Info>::iterator p = info_list.begin() ;
45 for( ; p != info_list.end() ; ++p )
47 if( (*p).visualid ==
id )
53 if( p == info_list.end() )
54 throw Error(
"unknown visual" ) ;
63 return m_info.visual ;
69 template_.screen = XDefaultScreen( display.
x() ) ;
72 XVisualInfo * vp = XGetVisualInfo( display.
x() , VisualScreenMask , &template_ , &n ) ;
74 throw Error(
"XGetVisualInfo" ) ;
76 std::list<Info> result ;
77 for(
int i = 0 ; i < n ; i++ )
80 result.push_back( copy ) ;
88 check( m_info.visualid == XVisualIDFromVisual(m_info.visual) ) ;
89 return m_info.visualid ;
92 void GX::Visual::check(
bool b )
95 throw Error(
"internal error" ) ;
100 return m_info.c_class ;
105 return m_info.depth ;
110 if( type() == PseudoColor )
return "PseudoColour" ;
111 if( type() == GrayScale )
return "GreyScale" ;
112 if( type() == DirectColor )
return "DirectColour" ;
113 if( type() == TrueColor )
return "TrueColour" ;
114 if( type() == StaticColor )
return "StaticColour" ;
115 if( type() == StaticGray )
return "StaticGrey" ;
116 std::stringstream ss ;
117 ss <<
"unrecognised visual class [" <<
static_cast<int>(type()) <<
"]" ;
118 throw Error( ss.str() ) ;
::Display * x()
Returns the X object.
Visual(Display &)
Constructor for the display's default visual.
int type() const
Returns the type.
std::string typeName() const
Returns the type name.
static std::list< Info > infoList(Display &)
Returns a list of supported "visuals" for the default screen.
An exception class for GX classes.
int depth() const
Returns the depth.
::VisualID id() const
Returns the id.
::Visual * x()
Returns the X object.