diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index d845b62ab..e4762feb7 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -994,7 +994,7 @@ bool GraphicsWindowX11::createWindow() XFlush( _eventDisplay ); XSync( _eventDisplay, 0 ); rescanModifierMapping(); - + return true; } @@ -2151,31 +2151,61 @@ extern "C" void graphicswindow_X11(void) osg::GraphicsContext::setWindowingSystemInterface(new X11WindowingSystemInterface); } - void GraphicsWindowX11::raiseWindow() { Display* display = getDisplayToUse(); - XWindowAttributes winAttrib; + if(!display) return; - 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 && iwindowName.c_str(),(const char *)windowName.value) == 0)) xraise = true; + // fill an XEvent struct to send + XEvent xev; + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = True; + xev.xclient.window = _window; + xev.xclient.message_type = stateAtom; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; + xev.xclient.data.l[1] = stateAbove; + xev.xclient.data.l[2] = 0; + + XSendEvent(display, RootWindow(display, DefaultScreen(display)), + False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } - if (xraise) XRaiseWindow(display,_window); else { - XGetWindowAttributes(display, _window, &winAttrib); - XReparentWindow(display, _window, _parent, winAttrib.x, winAttrib.y); + // one or both of _NET_WM_STATE and _NET_WM_STATE_ABOVE aren't supported + // try to use XRaiseWindow + XWindowAttributes winAttrib; + + Window root_return, parent_return, *children; + unsigned int nchildren, i=0; + XTextProperty windowName; + bool xraise = false; + + // get the window tree around our current window + XQueryTree(display, _parent, &root_return, &parent_return, &children, &nchildren); + while (!xraise && iwindowName.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); } - XFree(children); XFlush(display); XSync(display,0);