|
|
|||
File indexing completed on 2026-09-16 09:16:21
0001 // Copyright (c) 2013-2014 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef Aspect_DisplayConnection_HeaderFile 0015 #define Aspect_DisplayConnection_HeaderFile 0016 0017 #include <Standard_Transient.hxx> 0018 #include <Aspect_XAtom.hxx> 0019 #include <Aspect_FBConfig.hxx> 0020 0021 #include <TCollection_AsciiString.hxx> 0022 #include <NCollection_DataMap.hxx> 0023 0024 struct Aspect_XDisplay; 0025 struct Aspect_XVisualInfo; 0026 0027 //! This class creates and provides connection with X server. 0028 //! Raises exception if can not connect to X server. 0029 //! On Windows and Mac OS X (in case when Cocoa used) platforms this class does nothing. 0030 //! WARNING: Do not close display connection manually! 0031 class Aspect_DisplayConnection : public Standard_Transient 0032 { 0033 DEFINE_STANDARD_RTTIEXT(Aspect_DisplayConnection, Standard_Transient) 0034 public: 0035 //! Default constructor. Creates connection with display name taken from "DISPLAY" environment 0036 //! variable 0037 Standard_EXPORT Aspect_DisplayConnection(); 0038 0039 //! Destructor. Close opened connection. 0040 Standard_EXPORT ~Aspect_DisplayConnection() override; 0041 0042 //! Constructor. Creates connection with display specified in theDisplayName. 0043 //! Display name should be in format "hostname:number" or "hostname:number.screen_number", where: 0044 //! hostname 0045 //! - Specifies the name of the host machine on which the display is physically attached. 0046 //! number 0047 //! - Specifies the number of the display server on that host machine. 0048 //! screen_number 0049 //! - Specifies the screen to be used on that server. Optional variable. 0050 Standard_EXPORT Aspect_DisplayConnection(const TCollection_AsciiString& theDisplayName); 0051 0052 //! Constructor wrapping existing Display instance. 0053 //! WARNING! it is a responsibility of application to keep this pointer 0054 //! valid while Aspect_DisplayConnection is alive and to close Display when it is no more needed. 0055 Standard_EXPORT Aspect_DisplayConnection(Aspect_XDisplay* theDisplay); 0056 0057 //! @return pointer to Display structure that serves as the connection to the X server. 0058 Aspect_XDisplay* GetDisplayAspect() { return myDisplay; } 0059 0060 //! @return TRUE if X Display has been allocated by this class 0061 bool IsOwnDisplay() const { return myIsOwnDisplay; } 0062 0063 //! @return identifier(atom) for custom named property associated with windows that use current 0064 //! connection to X server. 0065 uint64_t GetAtom(const Aspect_XAtom theAtom) const { return myAtoms.Find(theAtom); } 0066 0067 //! @return display name for this connection. 0068 const TCollection_AsciiString& GetDisplayName() { return myDisplayName; } 0069 0070 //! Open connection with display specified in myDisplayName class field 0071 //! or takes theDisplay parameter when it is not NULL. 0072 //! WARNING! When external Display is specified, it is a responsibility of application 0073 //! to keep this pointer valid while Aspect_DisplayConnection is alive 0074 //! and to close Display when it is no more needed. 0075 //! @param theDisplay external pointer to allocated Display, or NULL if new connection should be 0076 //! created 0077 Standard_EXPORT void Init(Aspect_XDisplay* theDisplay); 0078 0079 //! Return default window visual or NULL when undefined. 0080 Aspect_XVisualInfo* GetDefaultVisualInfo() const { return myDefVisualInfo; } 0081 0082 //! @return native Window FB config (GLXFBConfig on Xlib) 0083 Aspect_FBConfig GetDefaultFBConfig() const { return myDefFBConfig; } 0084 0085 //! Set default window visual; the visual will be deallocated using XFree(). 0086 Standard_EXPORT void SetDefaultVisualInfo(Aspect_XVisualInfo* theVisual, 0087 Aspect_FBConfig theFBConfig); 0088 0089 #ifdef X_PROTOCOL 0090 //! Constructor wrapping existing Display instance. 0091 //! WARNING! it is a responsibility of application to keep this pointer 0092 //! valid while Aspect_DisplayConnection is alive and to close Display when it is no more needed. 0093 Aspect_DisplayConnection(Display* theDisplay) 0094 : Aspect_DisplayConnection((Aspect_XDisplay*)theDisplay) 0095 { 0096 } 0097 0098 //! @return pointer to Display structure that serves as the connection to the X server. 0099 Display* GetDisplay() { return (Display*)myDisplay; } 0100 0101 //! Return default window visual or NULL when undefined. 0102 XVisualInfo* GetDefaultVisualInfoX() const { return (XVisualInfo*)myDefVisualInfo; } 0103 0104 //! Set default window visual; the visual will be deallocated using XFree(). 0105 void SetDefaultVisualInfo(XVisualInfo* theVisual, Aspect_FBConfig theFBConfig) 0106 { 0107 SetDefaultVisualInfo((Aspect_XVisualInfo*)theVisual, theFBConfig); 0108 } 0109 0110 //! @return identifier(atom) for custom named property associated with windows that use current 0111 //! connection to X server. 0112 Atom GetAtomX(const Aspect_XAtom theAtom) const { return (Atom)GetAtom(theAtom); } 0113 0114 //! Open connection with display specified in myDisplayName class field 0115 //! or takes theDisplay parameter when it is not NULL. 0116 void Init(Display* theDisplay) { Init((Aspect_XDisplay*)theDisplay); } 0117 #endif 0118 0119 private: 0120 Aspect_XDisplay* myDisplay; 0121 Aspect_XVisualInfo* myDefVisualInfo; 0122 Aspect_FBConfig myDefFBConfig; 0123 NCollection_DataMap<Aspect_XAtom, uint64_t> myAtoms; 0124 TCollection_AsciiString myDisplayName; 0125 bool myIsOwnDisplay; 0126 0127 private: 0128 //! To protect the connection from closing copying allowed only through the handles. 0129 Aspect_DisplayConnection(const Aspect_DisplayConnection&) = delete; 0130 Aspect_DisplayConnection& operator=(const Aspect_DisplayConnection&) = delete; 0131 }; 0132 0133 #endif // _Aspect_DisplayConnection_H__
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|