diff --git a/src/Draw/Draw_Viewer.cxx b/src/Draw/Draw_Viewer.cxx index ec9848f662..66c3573c2d 100644 --- a/src/Draw/Draw_Viewer.cxx +++ b/src/Draw/Draw_Viewer.cxx @@ -941,12 +941,29 @@ Draw_Display Draw_Viewer::MakeDisplay (const Standard_Integer id) const //function : Select //purpose : //======================================================================= + void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_Integer& Y, Standard_Integer& Button, Standard_Boolean wait) { 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(); -#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) +#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) if (!wait) { if (id >=0 && id < MAXVIEW) { if (myViews[id]) myViews[id]->Wait(wait); diff --git a/src/Draw/Draw_Window.cxx b/src/Draw/Draw_Window.cxx index 9c51b2be7f..1faf835416 100644 --- a/src/Draw/Draw_Window.cxx +++ b/src/Draw/Draw_Window.cxx @@ -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 XSetWMNormalHints(Draw_WindowDisplay,win,&myHints); + Atom aDeleteWindowAtom = Draw_DisplayConnection->GetAtom (Aspect_XA_DELETE_WINDOW); + XSetWMProtocols (Draw_WindowDisplay, win, &aDeleteWindowAtom, 1); + if (Draw_VirtualWindows) { myUseBuffer = Standard_True; @@ -567,6 +570,25 @@ Standard_Boolean Draw_Window::DefineColor(const Standard_Integer i, const char* 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 //purpose : @@ -793,9 +815,17 @@ void ProcessEvent(Draw_Window& win, XEvent& xev) XComposeStatus stat; 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 : win.WExpose(); break; @@ -1372,6 +1402,11 @@ LRESULT APIENTRY DrawWindow::DrawProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARA switch (wMsg) { + case WM_CLOSE: + { + localObjet->Hide(); + return 0; // do nothing - window destruction should be performed by application + } case WM_PAINT: { PAINTSTRUCT ps; @@ -1679,6 +1714,22 @@ TCollection_AsciiString DrawWindow::GetTitle() const 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 diff --git a/src/Draw/Draw_Window.hxx b/src/Draw/Draw_Window.hxx index 55c9629763..adbbd13161 100644 --- a/src/Draw/Draw_Window.hxx +++ b/src/Draw/Draw_Window.hxx @@ -120,6 +120,8 @@ class Draw_Window void SetTitle (const TCollection_AsciiString& theTitle); TCollection_AsciiString GetTitle() const; + //! Return true if window is displayed on the screen. + bool IsMapped() const; void DisplayWindow(); void Hide(); void Destroy(); @@ -285,6 +287,8 @@ class Draw_Window void SetTitle (const TCollection_AsciiString& theTitle); TCollection_AsciiString GetTitle() const; + //! Return true if window is displayed on the screen. + bool IsMapped() const; void DisplayWindow(); void Hide(); void Destroy(); @@ -448,6 +452,8 @@ public: __Draw_API TCollection_AsciiString GetTitle() const; //Affichage + //! Return true if window is displayed on the screen. + bool IsMapped() const; __Draw_API void DisplayWindow(); __Draw_API void Hide(); __Draw_API void Destroy(); diff --git a/src/Draw/Draw_Window_1.mm b/src/Draw/Draw_Window_1.mm index cb3c72964e..e59b69890a 100644 --- a/src/Draw/Draw_Window_1.mm +++ b/src/Draw/Draw_Window_1.mm @@ -327,6 +327,21 @@ Standard_Boolean Draw_Window::DefineColor (const Standard_Integer&, Standard_CSt return Standard_True; // unused } +//======================================================================= +//function : IsMapped +//purpose : +//======================================================================= +bool Draw_Window::IsMapped() const +{ + if (Draw_VirtualWindows + || myWindow == NULL) + { + return false; + } + + return [myWindow isVisible]; +} + //======================================================================= //function : DisplayWindow //purpose :