mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0028333: Draw Harness - whatis command hangs when selection is activated with no opened view
Added new method Draw_Window::IsMapped() for checked window state. Draw_Window using XLib now does not exit application on closing window. The method Draw_Viewer::Select() (called by whatis command) has been corrected so as not to enter the loop if no views are initialized.
This commit is contained in:
parent
e59839c8c2
commit
7c441da0d1
@ -941,12 +941,29 @@ Draw_Display Draw_Viewer::MakeDisplay (const Standard_Integer id) const
|
|||||||
//function : Select
|
//function : Select
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_Integer& Y,
|
void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_Integer& Y,
|
||||||
Standard_Integer& Button, Standard_Boolean wait)
|
Standard_Integer& Button, Standard_Boolean wait)
|
||||||
{
|
{
|
||||||
if (Draw_Batch) return;
|
if (Draw_Batch) return;
|
||||||
|
id = X = Y = Button = 0;
|
||||||
|
Standard_Boolean hasView = Standard_False;
|
||||||
|
for (int aViewIter = 0; aViewIter < MAXVIEW; ++aViewIter)
|
||||||
|
{
|
||||||
|
if (myViews[aViewIter] != NULL
|
||||||
|
&& myViews[aViewIter]->IsMapped())
|
||||||
|
{
|
||||||
|
hasView = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasView)
|
||||||
|
{
|
||||||
|
std::cerr << "No selection is possible with no open views\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
Flush();
|
Flush();
|
||||||
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||||
if (!wait) {
|
if (!wait) {
|
||||||
if (id >=0 && id < MAXVIEW) {
|
if (id >=0 && id < MAXVIEW) {
|
||||||
if (myViews[id]) myViews[id]->Wait(wait);
|
if (myViews[id]) myViews[id]->Wait(wait);
|
||||||
|
@ -371,6 +371,9 @@ void Draw_Window::Init(Standard_Integer X, Standard_Integer Y,
|
|||||||
// advise to the window manager to place it where I need
|
// advise to the window manager to place it where I need
|
||||||
XSetWMNormalHints(Draw_WindowDisplay,win,&myHints);
|
XSetWMNormalHints(Draw_WindowDisplay,win,&myHints);
|
||||||
|
|
||||||
|
Atom aDeleteWindowAtom = Draw_DisplayConnection->GetAtom (Aspect_XA_DELETE_WINDOW);
|
||||||
|
XSetWMProtocols (Draw_WindowDisplay, win, &aDeleteWindowAtom, 1);
|
||||||
|
|
||||||
if (Draw_VirtualWindows)
|
if (Draw_VirtualWindows)
|
||||||
{
|
{
|
||||||
myUseBuffer = Standard_True;
|
myUseBuffer = Standard_True;
|
||||||
@ -567,6 +570,25 @@ Standard_Boolean Draw_Window::DefineColor(const Standard_Integer i, const char*
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsMapped
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
bool Draw_Window::IsMapped() const
|
||||||
|
{
|
||||||
|
if (Draw_VirtualWindows
|
||||||
|
|| win == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
XFlush (Draw_WindowDisplay);
|
||||||
|
XWindowAttributes aWinAttr;
|
||||||
|
XGetWindowAttributes (Draw_WindowDisplay, win, &aWinAttr);
|
||||||
|
return aWinAttr.map_state == IsUnviewable
|
||||||
|
|| aWinAttr.map_state == IsViewable;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DisplayWindow
|
//function : DisplayWindow
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -793,9 +815,17 @@ void ProcessEvent(Draw_Window& win, XEvent& xev)
|
|||||||
XComposeStatus stat;
|
XComposeStatus stat;
|
||||||
char chainekey[10];
|
char chainekey[10];
|
||||||
|
|
||||||
|
switch (xev.type)
|
||||||
switch (xev.type) {
|
{
|
||||||
|
case ClientMessage:
|
||||||
|
{
|
||||||
|
if (xev.xclient.data.l[0] == (int )Draw_DisplayConnection->GetAtom (Aspect_XA_DELETE_WINDOW))
|
||||||
|
{
|
||||||
|
// just hide the window
|
||||||
|
win.Hide();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
case Expose :
|
case Expose :
|
||||||
win.WExpose();
|
win.WExpose();
|
||||||
break;
|
break;
|
||||||
@ -1372,6 +1402,11 @@ LRESULT APIENTRY DrawWindow::DrawProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
switch (wMsg)
|
switch (wMsg)
|
||||||
{
|
{
|
||||||
|
case WM_CLOSE:
|
||||||
|
{
|
||||||
|
localObjet->Hide();
|
||||||
|
return 0; // do nothing - window destruction should be performed by application
|
||||||
|
}
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
@ -1679,6 +1714,22 @@ TCollection_AsciiString DrawWindow::GetTitle() const
|
|||||||
return TCollection_AsciiString (aTitleW);
|
return TCollection_AsciiString (aTitleW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsMapped
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
bool Draw_Window::IsMapped() const
|
||||||
|
{
|
||||||
|
if (Draw_VirtualWindows
|
||||||
|
|| win == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG aWinStyle = GetWindowLongW (win, GWL_STYLE);
|
||||||
|
return (aWinStyle & WS_VISIBLE) != 0
|
||||||
|
&& (aWinStyle & WS_MINIMIZE) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
| DisplayWindow
|
| DisplayWindow
|
||||||
|
@ -120,6 +120,8 @@ class Draw_Window
|
|||||||
void SetTitle (const TCollection_AsciiString& theTitle);
|
void SetTitle (const TCollection_AsciiString& theTitle);
|
||||||
TCollection_AsciiString GetTitle() const;
|
TCollection_AsciiString GetTitle() const;
|
||||||
|
|
||||||
|
//! Return true if window is displayed on the screen.
|
||||||
|
bool IsMapped() const;
|
||||||
void DisplayWindow();
|
void DisplayWindow();
|
||||||
void Hide();
|
void Hide();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
@ -285,6 +287,8 @@ class Draw_Window
|
|||||||
void SetTitle (const TCollection_AsciiString& theTitle);
|
void SetTitle (const TCollection_AsciiString& theTitle);
|
||||||
TCollection_AsciiString GetTitle() const;
|
TCollection_AsciiString GetTitle() const;
|
||||||
|
|
||||||
|
//! Return true if window is displayed on the screen.
|
||||||
|
bool IsMapped() const;
|
||||||
void DisplayWindow();
|
void DisplayWindow();
|
||||||
void Hide();
|
void Hide();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
@ -448,6 +452,8 @@ public:
|
|||||||
__Draw_API TCollection_AsciiString GetTitle() const;
|
__Draw_API TCollection_AsciiString GetTitle() const;
|
||||||
|
|
||||||
//Affichage
|
//Affichage
|
||||||
|
//! Return true if window is displayed on the screen.
|
||||||
|
bool IsMapped() const;
|
||||||
__Draw_API void DisplayWindow();
|
__Draw_API void DisplayWindow();
|
||||||
__Draw_API void Hide();
|
__Draw_API void Hide();
|
||||||
__Draw_API void Destroy();
|
__Draw_API void Destroy();
|
||||||
|
@ -327,6 +327,21 @@ Standard_Boolean Draw_Window::DefineColor (const Standard_Integer&, Standard_CSt
|
|||||||
return Standard_True; // unused
|
return Standard_True; // unused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsMapped
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
bool Draw_Window::IsMapped() const
|
||||||
|
{
|
||||||
|
if (Draw_VirtualWindows
|
||||||
|
|| myWindow == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [myWindow isVisible];
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DisplayWindow
|
//function : DisplayWindow
|
||||||
//purpose :
|
//purpose :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user