From Jutta Sauer, "We added a raise window method to GraphicsWindow. And added two

implementations for Win32 and X11.

"
This commit is contained in:
Robert Osfield
2008-08-15 17:32:26 +00:00
parent b6886cdbb2
commit dceb3cbe88
5 changed files with 52 additions and 2 deletions

View File

@@ -89,6 +89,9 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
/** Get focus on if the pointer is in this window.*/
virtual void grabFocusIfPointerInWindow() { osg::notify(osg::NOTICE)<<"GraphicsWindow::grabFocusIfPointerInWindow(..) not implemented."<<std::endl; }
/** Raise the window to the top.*/
virtual void raiseWindow() { osg::notify(osg::NOTICE)<<"GraphicsWindow::raiseWindow(..) not implemented."<<std::endl; }
/** Mouse cursor types, the same ones already present with ancient glut ... */
enum MouseCursor {
InheritCursor,
@@ -241,6 +244,7 @@ class GraphicsWindowEmbedded : public GraphicsWindow
virtual void swapBuffersImplementation() {}
virtual void grabFocus() {}
virtual void grabFocusIfPointerInWindow() {}
virtual void raiseWindow() {}
};
struct GraphicsWindowFunctionProxy

View File

@@ -79,6 +79,9 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow
/** Override from GUIActionAdapter.*/
virtual void requestWarpPointer(float x,float y);
/** Raise specified window */
virtual void raiseWindow();
/** Set the name of the window */
virtual void setWindowName(const std::string& /*name*/);

View File

@@ -109,6 +109,9 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
/** Get focus on if the pointer is in this window.*/
virtual void grabFocusIfPointerInWindow();
/** Raise specified window */
virtual void raiseWindow();
// Override from GUIActionAdapter
virtual void requestWarpPointer(float x,float y);

View File

@@ -2374,3 +2374,13 @@ extern "C" void graphicswindow_Win32(void)
{
osg::GraphicsContext::setWindowingSystemInterface(osgViewer::Win32WindowingSystem::getInterface());
}
void GraphicsWindowWin32::raiseWindow()
{
SetWindowPos(_hwnd, HWND_TOPMOST, _traits->x, _traits->y, _traits->width, _traits->height, SWP_NOMOVE|SWP_NOSIZE);
SetWindowPos(_hwnd, HWND_NOTOPMOST, _traits->x, _traits->y, _traits->width, _traits->height, SWP_NOMOVE|SWP_NOSIZE);
}

View File

@@ -668,8 +668,8 @@ bool GraphicsWindowX11::createWindow()
_traits->y,
_traits->width, _traits->height, 0,
_visualInfo->depth, InputOutput,
_visualInfo->visual, mask, &swatt );
_visualInfo->visual, mask, &swatt );
if (!_window)
{
osg::notify(osg::NOTICE)<<"Error: Unable to create Window."<<std::endl;
@@ -1744,3 +1744,33 @@ extern "C" void graphicswindow_X11(void)
{
osg::GraphicsContext::setWindowingSystemInterface(new X11WindowingSystemInterface);
}
void GraphicsWindowX11::raiseWindow()
{
Display* display = getDisplayToUse();
XWindowAttributes winAttrib;
Window root_return, parent_return, *children;
unsigned int nchildren, i=0;
XTextProperty windowName;
bool xraise = false;
XQueryTree(display, _parent, &root_return, &parent_return, &children, &nchildren);
while (!xraise && i<nchildren)
{
XGetWMName(display,children[i++],&windowName);
if ((windowName.nitems != 0) && (strcmp(_traits->windowName.c_str(),(const char *)windowName.value) == 0)) xraise = true;
}
if (xraise) XRaiseWindow(display,_window);
else
{
XGetWindowAttributes(display, _window, &winAttrib);
XReparentWindow(display, _window, _parent, winAttrib.x, winAttrib.y);
}
XFree(children);
XFlush(display);
XSync(display,0);
}