-// Created by: NW,JPB,CAL,GG
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Created on: 2013-04-06
+// Created by: Kirill Gavrilov
+// Copyright (c) 2013 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-#define BUC60701 //GG 23/06/00 Enable to dump an exact image size
-// according to the window size
-#define RIC120302 //GG Add a NEW XParentWindow methods which enable
-// to retrieve the parent of the actual Xwindow ID.
+#include <Xw_Window.hxx>
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
-//-Version
-
-//-Design Creation d'une fenetre X
-
-//-Warning
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <Xw_Window.ixx>
-// Routines C a declarer en extern
-//extern "C" {
-#include <Xw_Cextern.hxx>
-//}
#include <Aspect_Convert.hxx>
-#include <Aspect_DisplayConnection.hxx>
-#include <Image_AlienPixMap.hxx>
-#include <Standard_PCharacter.hxx>
+#include <Aspect_WindowDefinitionError.hxx>
-#include <Xw_Extension.h>
+#include <GL/glx.h>
-//-Static data definitions
-
-static XW_STATUS status ;
+namespace
+{
-//============================================================================
-//==== HashCode : Returns a HashCode CString
-//============================================================================
-inline Standard_Integer HashCode (const Standard_CString Value)
+ //! Search for RGBA double-buffered visual
+ static int TheDoubleBuff[] =
+ {
+ GLX_RGBA,
+ GLX_DEPTH_SIZE, 16,
+ GLX_DOUBLEBUFFER,
+ None
+ };
+
+};
+
+IMPLEMENT_STANDARD_HANDLE (Xw_Window, Aspect_Window)
+IMPLEMENT_STANDARD_RTTIEXT(Xw_Window, Aspect_Window)
+
+// =======================================================================
+// function : Xw_Window
+// purpose :
+// =======================================================================
+Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
+ const Standard_CString theTitle,
+ const Standard_Integer thePxLeft,
+ const Standard_Integer thePxTop,
+ const Standard_Integer thePxWidth,
+ const Standard_Integer thePxHeight)
+: Aspect_Window(),
+ myDisplay (theXDisplay),
+ myXWindow (0),
+ myXLeft (thePxLeft),
+ myYTop (thePxTop),
+ myXRight (thePxLeft + thePxWidth),
+ myYBottom (thePxTop + thePxHeight),
+ myIsOwnWin (Standard_True)
{
-Standard_Integer i,n,aHashCode = 0;
-union {
- char charPtr[80];
- int intPtr[20];
-} u;
-
- n = strlen(Value);
-
- if( n > 0 ) {
- if( n < 80 ) {
- n = (n+3)/4;
- u.intPtr[n-1] = 0;
- strcpy(u.charPtr,Value);
- } else {
- n = 20;
- strncpy(u.charPtr,Value,80);
- }
-
- for( i=0 ; i<n ; i++ ) {
- aHashCode = aHashCode ^ u.intPtr[i];
- }
+ int aDummy = 0;
+ if (thePxWidth <= 0 || thePxHeight <= 0)
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, Coordinate(s) out of range");
+ }
+ else if (theXDisplay.IsNull())
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, X Display connection is undefined");
+ return;
+ }
+ else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, GLX extension is unavailable");
+ return;
}
-//printf(" HashCode of '%s' is %d\n",Value,aHashCode);
+ Display* aDisp = myDisplay->GetDisplay();
+ int aScreen = DefaultScreen(aDisp);
+ Window aParent = RootWindow (aDisp, aScreen);
- return Abs(aHashCode) + 1;
-}
+ XVisualInfo* aVisInfo = glXChooseVisual (aDisp, aScreen, TheDoubleBuff);
+ if (aVisInfo == NULL)
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, couldn't find compatible Visual (RGBA, double-buffered)");
+ return;
+ }
-void Xw_Window::PrintError() {
-Standard_CString ErrorMessag ;
-Standard_Integer ErrorNumber ;
-Standard_Integer ErrorGravity ;
+ unsigned long aMask = 0;
+ XSetWindowAttributes aWinAttr;
+ memset(&aWinAttr, 0, sizeof(XSetWindowAttributes));
+ aWinAttr.event_mask = ExposureMask | StructureNotifyMask;
+ aMask |= CWEventMask;
+ aWinAttr.colormap = XCreateColormap(aDisp, aParent, aVisInfo->visual, AllocNone);
+ aWinAttr.border_pixel = 0;
+ aWinAttr.override_redirect = False;
+
+ myXWindow = XCreateWindow(aDisp, aParent,
+ myXLeft, myYTop, thePxWidth, thePxHeight,
+ 0, aVisInfo->depth,
+ InputOutput,
+ aVisInfo->visual,
+ CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &aWinAttr);
+ XFree (aVisInfo); aVisInfo = NULL;
+ if (myXWindow == 0)
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, Unable to create window");
+ return;
+ }
- status = XW_SUCCESS ;
- ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
- Xw_print_error() ;
+ // if parent - desktop
+ XSizeHints aSizeHints;
+ aSizeHints.x = myXLeft;
+ aSizeHints.y = myYTop;
+ aSizeHints.flags = PPosition;
+ aSizeHints.width = thePxWidth;
+ aSizeHints.height = thePxHeight;
+ aSizeHints.flags |= PSize;
+ XSetStandardProperties (aDisp, myXWindow, theTitle, theTitle, None,
+ NULL, 0, &aSizeHints);
+
+ /*XTextProperty aTitleProperty;
+ aTitleProperty.encoding = None;
+ char* aTitle = (char* )theTitle;
+ Xutf8TextListToTextProperty(aDisp, &aTitle, 1, XUTF8StringStyle, &aTitleProperty);
+ XSetWMName (aDisp, myXWindow, &aTitleProperty);
+ XSetWMProperties(aDisp, myXWindow, &aTitleProperty, &aTitleProperty, NULL, 0, NULL, NULL, NULL);*/
+
+ XFlush (aDisp);
}
-//-Aliases
-
-//-Global data definitions
-
-//-Constructors
-
-Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
+// =======================================================================
+// function : Xw_Window
+// purpose :
+// =======================================================================
+Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
+ const Window theXWin)
: Aspect_Window(),
- myDisplayConnection (theDisplayConnection)
+ myDisplay (theXDisplay),
+ myXWindow (theXWin),
+ myXLeft (0),
+ myYTop (0),
+ myXRight (512),
+ myYBottom (512),
+ myIsOwnWin (Standard_False)
{
- Init();
-}
-
+ int aDummy = 0;
+ if (theXWin == 0)
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, given invalid X window");
+ return;
+ }
+ else if (theXDisplay.IsNull())
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, X Display connection is undefined");
+ return;
+ }
+ else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
+ {
+ myXWindow = 0;
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, GLX extension is unavailable");
+ return;
+ }
-//=======================================================================
-//function : Xw_Window
-//purpose :
-//=======================================================================
-Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
- const Standard_Integer aPart1,
- const Standard_Integer aPart2,
- const Quantity_NameOfColor BackColor)
-: Aspect_Window(),
- myDisplayConnection (theDisplayConnection)
-{
- Init();
- Aspect_Handle aWindow = (aPart1 << 16) | (aPart2 & 0xFFFF);
- SetWindow (aWindow, BackColor);
-}
+ Display* aDisp = myDisplay->GetDisplay();
+
+ XWindowAttributes aWinAttr;
+ XGetWindowAttributes (aDisp, myXWindow, &aWinAttr);
+ const int aScreen = DefaultScreen (aDisp);
+ const long aVisInfoMask = VisualIDMask | VisualScreenMask;
+ XVisualInfo aVisInfoTmp;
+ aVisInfoTmp.visualid = aWinAttr.visual->visualid;
+ aVisInfoTmp.screen = aScreen;
+ int aNbItems = 0;
+ XVisualInfo* aVisInfo = XGetVisualInfo (aDisp, aVisInfoMask, &aVisInfoTmp, &aNbItems);
+ if (aVisInfo == NULL)
+ {
+ Aspect_WindowDefinitionError::Raise ("Xw_Window, Visual is unavailable");
+ return;
+ }
+ XFree (aVisInfo);
-//=======================================================================
-//function : Xw_Window
-//purpose :
-//=======================================================================
-Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
- const Aspect_Handle aWindow,
- const Quantity_NameOfColor BackColor)
-: Aspect_Window(),
- myDisplayConnection (theDisplayConnection)
-{
- Init();
- SetWindow (aWindow, BackColor);
+ DoResize();
}
-//=======================================================================
-//function : Xw_Window
-//purpose :
-//=======================================================================
-Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
- const Standard_CString theTitle,
- const Standard_Integer thePxLeft,
- const Standard_Integer thePxTop,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight,
- const Quantity_NameOfColor theBackColor,
- const Aspect_Handle theParent)
-: Aspect_Window (),
- myDisplayConnection (theDisplayConnection)
+// =======================================================================
+// function : Destroy
+// purpose :
+// =======================================================================
+void Xw_Window::Destroy()
{
- Init();
-
- Standard_Integer aParentSizeX = 1;
- Standard_Integer aParentSizeY = 1;
-
- Aspect_Handle aRoot, aColormap, *aDisplay;
- Xw_TypeOfVisual aVisualClass;
- Standard_Integer aVisualDepth;
- Xw_get_display_info (MyExtendedDisplay,
- &aDisplay, &aRoot, &aColormap, &aVisualClass, &aVisualDepth);
- Xw_get_screen_size (MyExtendedDisplay, &aParentSizeX, &aParentSizeY);
- if (theParent)
+ if (myIsOwnWin && myXWindow != 0 && !myDisplay.IsNull())
{
- XWindowAttributes anAttributes;
- if(XGetWindowAttributes ((Display* )aDisplay, theParent, &anAttributes))
- {
- aParentSizeX = anAttributes.width;
- aParentSizeY = anAttributes.height;
- }
+ XDestroyWindow (myDisplay->GetDisplay(), myXWindow);
}
- Quantity_Parameter aQCenterX, aQCenterY, aQSizeX, aQSizeY;
- Aspect_Convert::ConvertCoordinates (aParentSizeX, aParentSizeY,
- thePxLeft, thePxTop, theWidth, theHeight,
- aQCenterX, aQCenterY, aQSizeX, aQSizeY);
- SetWindow (theTitle, aQCenterX, aQCenterY, aQSizeX, aQSizeY,
- theBackColor, theParent);
}
-void Xw_Window::Init()
+// =======================================================================
+// function : XWindow
+// purpose :
+// =======================================================================
+Window Xw_Window::XWindow() const
{
- MyXWindow = 0 ;
- MyXParentWindow = 0 ;
-#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
- MyExtendedDisplay = NULL;
-#else
- MyExtendedDisplay = Xw_set_display (myDisplayConnection->GetDisplay());
-#endif
- MyExtendedWindow = NULL ;
- MyVisualClass = Xw_TOV_TRUECOLOR;
+ return myXWindow;
}
-//=======================================================================
-//function : SetWindow
-//purpose :
-//=======================================================================
-
-void Xw_Window::SetWindow (const Aspect_Handle aWindow,
- const Quantity_NameOfColor BackColor)
+// =======================================================================
+// function : IsMapped
+// purpose :
+// =======================================================================
+Standard_Boolean Xw_Window::IsMapped() const
{
- Aspect_Handle window,root,colormap,pixmap ;
- Xw_TypeOfVisual visualclass ;
- int visualdepth,visualid ;
-
- MyXWindow = aWindow ;
- MyXParentWindow = aWindow ;
-
- if( !MyXWindow ) {
- PrintError() ;
+ if (myXWindow == 0)
+ {
+ return false;
}
-
- MyExtendedWindow =
- Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False);
-
- status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
- &root,&colormap,&visualclass,
- &visualdepth,&visualid);
- if( !status ) {
- PrintError() ;
+ else if (IsVirtual())
+ {
+ return Standard_True;
}
- SetBackground(BackColor) ;
+ XFlush (myDisplay->GetDisplay());
+ XWindowAttributes aWinAttr;
+ XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
+ return aWinAttr.map_state == IsUnviewable
+ || aWinAttr.map_state == IsViewable;
}
-//=======================================================================
-//function : SetWindow
-//purpose :
-//=======================================================================
-
-void Xw_Window::SetWindow (const Standard_CString Title,
- const Quantity_Parameter Xc,
- const Quantity_Parameter Yc,
- const Quantity_Parameter Width,
- const Quantity_Parameter Height,
- const Quantity_NameOfColor BackColor,
- const Aspect_Handle Parent)
+// =======================================================================
+// function : Map
+// purpose :
+// =======================================================================
+void Xw_Window::Map() const
{
- Standard_Integer istransparent = Standard_False ;
-
- MyXParentWindow = Parent ;
- MyXWindow = 0 ;
-
- MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow,
- (float)Xc,(float)Yc,(float)Width,(float)Height,
- (Standard_PCharacter)Title,istransparent) ;
- if( !MyXWindow ) {
- PrintError() ;
+ if (IsVirtual() || myXWindow == 0)
+ {
+ return;
}
- MyExtendedWindow =
- Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent);
-
- SetBackground(BackColor) ;
-
- if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ;
-
-}
-
-void Xw_Window::Map () const {
-#ifdef RIC120302
- if( MyXWindow == MyXParentWindow ) return;
-#endif
- if (IsVirtual()) return;
- status = Xw_set_window_state (MyExtendedWindow, XW_MAP);
- if( !status ) {
- PrintError() ;
- }
-}
-
-void Xw_Window::Unmap () const {
-#ifdef RIC120302
- if( MyXWindow == MyXParentWindow ) return;
-#endif
- status = Xw_set_window_state (MyExtendedWindow, XW_ICONIFY);
- if( !status ) {
- PrintError() ;
- }
-}
-
-Aspect_TypeOfResize Xw_Window::DoResize () const {
-XW_RESIZETYPE state ;
-
- state = Xw_resize_window (MyExtendedWindow);
-// if( state == Aspect_TOR_UNKNOWN ) {
- if( state == XW_TOR_UNKNOWN ) {
- PrintError() ;
- }
-
- return (Aspect_TypeOfResize(state)) ;
+ XMapWindow (myDisplay->GetDisplay(), myXWindow);
+ XFlush (myDisplay->GetDisplay());
}
-Standard_Boolean Xw_Window::DoMapping () const {
-int pxc,pyc,width,height;
-XW_WINDOWSTATE state;
-
- state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&width,&height);
-
- return IsMapped();
-}
-
-void Xw_Window::Destroy () {
-Standard_Boolean destroy =
- ( MyXWindow == MyXParentWindow ) ? Standard_False : Standard_True;
-
- status = Xw_close_window (MyExtendedWindow,destroy);
- if( !status ) {
- PrintError() ;
- }
-
- MyXWindow = 0 ;
- MyExtendedWindow = NULL ;
-}
-
-void Xw_Window::SetCursor (const Standard_Integer anId, const Quantity_NameOfColor aColor) const {
-Quantity_Color Color(aColor) ;
-Standard_Real r,g,b ;
-
- Color.Values(r,g,b,Quantity_TOC_RGB) ;
-
- status = Xw_set_hard_cursor (MyExtendedWindow,(int)anId,0,
- (float)r,
- (float)g,
- (float)b) ;
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-Standard_Boolean Xw_Window::IsMapped () const {
- if (IsVirtual()) {
- return Standard_True;
+// =======================================================================
+// function : Unmap
+// purpose :
+// =======================================================================
+void Xw_Window::Unmap() const
+{
+ if (IsVirtual() || myXWindow == 0)
+ {
+ return;
}
-XW_WINDOWSTATE state;
- state = Xw_get_window_state (MyExtendedWindow);
- switch (state) {
- case XW_WS_UNKNOWN:
- return Standard_False;
- case XW_ICONIFY:
- return Standard_False;
- case XW_PUSH:
- return Standard_True;
- case XW_MAP:
- return Standard_True;
-#ifndef DEB
- default:
- return Standard_False;
-#endif
- }
- return Standard_False;
-}
-
-Standard_Real Xw_Window::Ratio () const {
-int width, height;
-
- status = Xw_get_window_size (MyExtendedWindow,&width,&height);
- if( !status ) {
- Xw_print_error() ;
- }
-
- return ((Standard_Real)width/height) ;
-}
-
-void Xw_Window::Size (Standard_Integer &Width, Standard_Integer &Height) const {
-int width, height;
- status = Xw_get_window_size (MyExtendedWindow,&width,&height);
- if( !status ) {
- Xw_print_error() ;
- }
-
- Width = width ;
- Height = height ;
-}
-
-void Xw_Window::Position (Standard_Integer &X1, Standard_Integer &Y1, Standard_Integer &X2, Standard_Integer &Y2) const {
-XW_WINDOWSTATE state = XW_WS_UNKNOWN ;
-int pxc, pyc;
-int width, height;
-
- state = Xw_get_window_position (MyExtendedWindow,
- &pxc,&pyc,&width,&height);
- if( state == XW_WS_UNKNOWN ) {
- Xw_print_error() ;
- }
-
- X1 = pxc - width/2 ; Y1 = pyc - height/2 ;
- X2 = X1 + width - 1 ; Y2 = Y1 + height - 1 ;
-}
-
-Aspect_Handle Xw_Window::XWindow () const {
-
- return (MyXWindow);
+ XIconifyWindow (myDisplay->GetDisplay(), myXWindow, DefaultScreen(myDisplay->GetDisplay()));
}
-void Xw_Window::XWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const {
-
- aPart1 = (Standard_Integer)((MyXWindow >> 16 ) & 0xffff);
- aPart2 = (Standard_Integer)(MyXWindow & 0xffff);
-}
+// =======================================================================
+// function : DoResize
+// purpose :
+// =======================================================================
+Aspect_TypeOfResize Xw_Window::DoResize() const
+{
+ if (myXWindow == 0)
+ {
+ return Aspect_TOR_UNKNOWN;
+ }
-// RIC120302
-Aspect_Handle Xw_Window::XParentWindow () const {
+ XFlush (myDisplay->GetDisplay());
+ XWindowAttributes aWinAttr;
+ XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
+ if (aWinAttr.map_state == IsUnmapped)
+ {
+ return Aspect_TOR_UNKNOWN;
+ }
- return (MyXParentWindow);
+ Standard_Integer aMask = 0;
+ Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
-}
-
-void Xw_Window::XParentWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const {
+ if (Abs (aWinAttr.x - myXLeft ) > 2) aMask |= 1;
+ if (Abs ((aWinAttr.x + aWinAttr.width) - myXRight ) > 2) aMask |= 2;
+ if (Abs (aWinAttr.y - myYTop ) > 2) aMask |= 4;
+ if (Abs ((aWinAttr.y + aWinAttr.height) - myYBottom) > 2) aMask |= 8;
+ switch (aMask)
+ {
+ case 0: aMode = Aspect_TOR_NO_BORDER; break;
+ case 1: aMode = Aspect_TOR_LEFT_BORDER; break;
+ case 2: aMode = Aspect_TOR_RIGHT_BORDER; break;
+ case 4: aMode = Aspect_TOR_TOP_BORDER; break;
+ case 5: aMode = Aspect_TOR_LEFT_AND_TOP_BORDER; break;
+ case 6: aMode = Aspect_TOR_TOP_AND_RIGHT_BORDER; break;
+ case 8: aMode = Aspect_TOR_BOTTOM_BORDER; break;
+ case 9: aMode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER; break;
+ case 10: aMode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER; break;
+ default: break;
+ }
- aPart1 = (Standard_Integer)((MyXParentWindow >> 16 ) & 0xffff);
- aPart2 = (Standard_Integer)(MyXParentWindow & 0xffff);
+ *((Standard_Integer* )&myXLeft ) = aWinAttr.x;
+ *((Standard_Integer* )&myXRight ) = aWinAttr.x + aWinAttr.width;
+ *((Standard_Integer* )&myYTop ) = aWinAttr.y;
+ *((Standard_Integer* )&myYBottom ) = aWinAttr.y + aWinAttr.height;
+ return aMode;
}
-// RIC120302
-
-Aspect_Handle Xw_Window::XPixmap () const {
-Aspect_Handle window,pixmap,root,colormap ;
-Xw_TypeOfVisual visualclass ;
-int visualdepth,visualid ;
- status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
- &root,&colormap,&visualclass,&visualdepth,&visualid) ;
-
- return (pixmap);
+// =======================================================================
+// function : DoMapping
+// purpose :
+// =======================================================================
+Standard_Boolean Xw_Window::DoMapping() const
+{
+ return Standard_True; // IsMapped()
}
-Standard_Boolean Xw_Window::PointerPosition (Standard_Integer& X, Standard_Integer& Y) const {
-Standard_Boolean cstatus ;
-int x,y ;
-
- cstatus = Xw_get_cursor_position(MyExtendedWindow,&x,&y) ;
- X = x ;
- Y = y ;
+// =======================================================================
+// function : Ratio
+// purpose :
+// =======================================================================
+Quantity_Ratio Xw_Window::Ratio() const
+{
+ if (myXWindow == 0)
+ {
+ return 1.0;
+ }
- return (cstatus);
+ XFlush (myDisplay->GetDisplay());
+ XWindowAttributes aWinAttr;
+ XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
+ return Quantity_Ratio(aWinAttr.width) / Quantity_Ratio(aWinAttr.height);
}
-Xw_TypeOfVisual Xw_Window::VisualClass () const {
-
- return (MyVisualClass);
-
+// =======================================================================
+// function : Position
+// purpose :
+// =======================================================================
+void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
+ Standard_Integer& X2, Standard_Integer& Y2) const
+{
+ //
}
-Standard_Boolean Xw_Window::BackgroundPixel ( Standard_Integer &aPixel ) const {
-unsigned long pixel ;
-
- status = Xw_get_background_pixel(MyExtendedWindow,&pixel) ;
- if( !status ) PrintError() ;
-
- aPixel = Standard_Integer(pixel);
+// =======================================================================
+// function : Size
+// purpose :
+// =======================================================================
+void Xw_Window::Size (Standard_Integer& theWidth,
+ Standard_Integer& theHeight) const
+{
+ if (myXWindow == 0)
+ {
+ return;
+ }
- return status;
+ XFlush (myDisplay->GetDisplay());
+ XWindowAttributes aWinAttr;
+ XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
+ theWidth = aWinAttr.width;
+ theHeight = aWinAttr.height;
}
-
-Standard_Address Xw_Window::ExtendedWindow () const {
-
- return (MyExtendedWindow);
-
-}
+#endif // Win32 or Mac OS X