示例#1
0
void DockContainer::embed( WId id )
{
    if( id == _embeddedWinId || id == 0)
        return;
    QRect geom = KWindowSystem::windowInfo(id,NET::WMFrameExtents).frameGeometry();

    // does the same as KWindowSystem::prepareForSwallowing()
	QX11Info info;
    XWithdrawWindow( QX11Info::display(), id, info.screen() );
    while( KWindowSystem::windowInfo(id, NET::XAWMState).mappingState() != NET::Withdrawn );

    XReparentWindow( QX11Info::display(), id, winId(), 0, 0 );

    // resize if window is bigger than frame
    if( (geom.width() > width()) ||
        (geom.height() > height()) )
        XResizeWindow( QX11Info::display(), id, width(), height() );
    else
        XMoveWindow(QX11Info::display(), id,
                    (sz() -  geom.width())/2 - border(),
                    (sz() - geom.height())/2 - border());
    XMapWindow( QX11Info::display(), id );
    XUngrabButton( QX11Info::display(), AnyButton, AnyModifier, winId() );

    _embeddedWinId = id;
}
Ogre::String createOgreWindowIdForQWidget(QWidget* pWidget)
{
    Q_ASSERT(pWidget != NULL);
    Ogre::String winId;

#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
    // positive integer for W32 (HWND handle) - According to Ogre Docs
    winId = Ogre::StringConverter::toString((unsigned long)(pWidget->winId()));
#endif

#if defined(Q_WS_X11)
    // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX - According to Ogre Docs
    QX11Info info = pWidget->x11Info();
    winId = Ogre::StringConverter::toString((unsigned long) (info.display()));
    winId += ":";
    winId += Ogre::StringConverter::toString((unsigned int) (info.screen()));
    winId += ":";
    winId += Ogre::StringConverter::toString((unsigned long) (pWidget->winId()));

//        winId += ":";
//        winId += Ogre::StringConverter::toString((unsigned long)(info.visual()));

    Display* display = QX11Info::display();
    Q_ASSERT(display);
    XSync(display, False);

#endif

    return winId;
}
void
ResizeCorner::mousePressEvent ( QMouseEvent *mev )
{
    if (mev->button() == Qt::LeftButton)
    {
        // complex way to say: client->performWindowOperation(KDecoration::ResizeOp);
        // stolen... errr "adapted!" from QSizeGrip
        QX11Info info;
        QPoint p = mev->globalPos();
        XEvent xev;
        xev.xclient.type = ClientMessage;
        xev.xclient.message_type = netMoveResize;
        xev.xclient.display = QX11Info::display();
        xev.xclient.window = client->windowId();
        xev.xclient.format = 32;
        xev.xclient.data.l[0] = p.x();
        xev.xclient.data.l[1] = p.y();
        xev.xclient.data.l[2] = 4; // _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHTMove
        xev.xclient.data.l[3] = Button1;
        xev.xclient.data.l[4] = 0;
        XUngrabPointer(QX11Info::display(), QX11Info::appTime());
        XSendEvent(QX11Info::display(), QX11Info::appRootWindow(info.screen()), False,
                    SubstructureRedirectMask | SubstructureNotifyMask, &xev);
    }
        
    else if (mev->button() == Qt::RightButton)
        { hide(); QTimer::singleShot(5000, this, SLOT(show())); }
    else if (mev->button() == Qt::MidButton)
        hide();
}
示例#4
0
	void OgreWidget::initialise(const Ogre::NameValuePairList *miscParams)
	{
		//These attributes are the same as those use in a QGLWidget
		setAttribute(Qt::WA_PaintOnScreen);
		setAttribute(Qt::WA_NoSystemBackground);

		//Parameters to pass to Ogre::Root::createRenderWindow()
		Ogre::NameValuePairList params;

		//If the user passed in any parameters then be sure to copy them into our own parameter set.
		//NOTE: Many of the parameters the user can supply (left, top, border, etc) will be ignored
		//as they are overridden by Qt. Some are still useful (such as FSAA).
		if(miscParams != 0)
		{
			params.insert(miscParams->begin(), miscParams->end());
		}

		//The external windows handle parameters are platform-specific
		Ogre::String externalWindowHandleParams;

		//Accept input focus
		setFocusPolicy(Qt::StrongFocus);

	#if defined(Q_WS_WIN)
		//positive integer for W32 (HWND handle) - According to Ogre Docs
		externalWindowHandleParams = Ogre::StringConverter::toString((unsigned int)(winId()));
	#endif

	#if defined(Q_WS_X11)
		//poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX - According to Ogre Docs
		QX11Info info = x11Info();
		externalWindowHandleParams  = Ogre::StringConverter::toString((unsigned long)(info.display()));
		externalWindowHandleParams += ":";
		externalWindowHandleParams += Ogre::StringConverter::toString((unsigned int)(info.screen()));
		externalWindowHandleParams += ":";
		externalWindowHandleParams += Ogre::StringConverter::toString((unsigned long)(winId()));
		//externalWindowHandleParams += ":";
		//externalWindowHandleParams += Ogre::StringConverter::toString((unsigned long)(info.visual()));
	#endif

		//Add the external window handle parameters to the existing params set.
	#if defined(Q_WS_WIN)		
		params["externalWindowHandle"] = externalWindowHandleParams;
	#endif

	#if defined(Q_WS_X11)
		params["parentWindowHandle"] = externalWindowHandleParams;
	#endif

		//Finally create our window.
		m_pOgreRenderWindow = Ogre::Root::getSingletonPtr()->createRenderWindow("OgreWindow", width(), height(), false, &params);

		mIsInitialised = true;
	}
示例#5
0
/**
 * @brief setup the rendering context
 * @author Kito Berg-Taylor
 */
void OgreWidget::initializeGL()
{
 //== Creating and Acquiring Ogre Window ==//
 
  // Get the parameters of the window QT created
  Ogre::String winHandle;
  #ifdef WIN32
  // Windows code
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #else
  // Unix code
  QX11Info info = x11Info();
  winHandle  = Ogre::StringConverter::toString((unsigned long)(info.display()));
  winHandle += ":";
  winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
  winHandle += ":";
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #endif
 
  Ogre::NameValuePairList params;
  params["parentWindowHandle"] = winHandle;
 
  mOgreWindow = mOgreRoot->createRenderWindow( "QOgreWidget_RenderWindow",
                           this->width(),
                           this->height(),
                           false,
                           &params );
 
  mOgreWindow->setActive(true);
  WId ogreWinId = 0x0;
  mOgreWindow->getCustomAttribute( "WINDOW", &ogreWinId );
 
  assert( ogreWinId );
 
  this->create( ogreWinId );
  setAttribute( Qt::WA_PaintOnScreen, true );
  setAttribute( Qt::WA_NoBackground );
 
  //== Ogre Initialization ==//
  Ogre::SceneType scene_manager_type = Ogre::ST_EXTERIOR_CLOSE;
 
  mSceneMgr = mOgreRoot->createSceneManager( scene_manager_type );
  mSceneMgr->setAmbientLight( Ogre::ColourValue(1,1,1) );
 
  mCamera = mSceneMgr->createCamera( "QOgreWidget_Cam" );
  mCamera->setPosition( Ogre::Vector3(0,1,0) );
  mCamera->lookAt( Ogre::Vector3(0,0,0) );
  mCamera->setNearClipDistance( 1.0 );
 
  Ogre::Viewport *mViewport = mOgreWindow->addViewport( mCamera );
  mViewport->setBackgroundColour( Ogre::ColourValue( 0.8,0.8,1 ) );
}
void  OgreWidget::initOgreSystem()
{
  m_ogreRoot = new Ogre::Root();

  Ogre::RenderSystem * renderSystem = m_ogreRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
  m_ogreRoot->setRenderSystem(renderSystem);
  m_ogreRoot->initialise(false);

  m_sceneManager = m_ogreRoot->createSceneManager(Ogre::ST_GENERIC);

  Ogre::NameValuePairList viewConfig;
  Ogre::String widgetHandle;

#ifdef Q_WS_WIN
  widgetHandle = Ogre::StringConverter::toString((size_t)winId());
  viewConfig["externalWindowHandle"] = widgetHandle;
#else
  QX11Info xInfo = x11Info();

  widgetHandle = Ogre::StringConverter::toString(reinterpret_cast<unsigned long>(xInfo.display())) +
      ":" + Ogre::StringConverter::toString(static_cast<unsigned int>(xInfo.screen())) +
      ":" + Ogre::StringConverter::toString(static_cast<unsigned long>(parentWidget()->winId()));
  viewConfig["parentWindowHandle"] = widgetHandle;
#endif

  m_renderWindow = m_ogreRoot->createRenderWindow("Ogre rendering window", width(), height(), false, &viewConfig);

#ifndef Q_WS_WIN
  WId window_id;
  m_renderWindow->getCustomAttribute("WINDOW", &window_id);
  create(window_id);
#endif

  m_camera = new Camera(m_sceneManager->createCamera("myCamera"));

  m_camera->reset();
  m_camera->getCamera()->setAspectRatio(Ogre::Real(width()) / Ogre::Real(height()));
  m_camera->getCamera()->setNearClipDistance(Ogre::Real(0.1));

  m_viewport = m_renderWindow->addViewport(m_camera->getCamera());
  m_viewport->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));

  m_selectionBuffer = new SelectionBuffer(m_sceneManager, m_renderWindow);

  initResources();
  initScene();
}
示例#7
0
void WindowManager::startDrag(QWidget *widget, const QPoint& position)
{
    if (!(enabled() && widget)) {
        return;
    }
    if (QWidget::mouseGrabber()) {
        return;
    }

    // ungrab pointer
    if (useWMMoveResize()) {
        #if defined Q_WS_X11 && QT_VERSION < 0x050000
        #ifndef ENABLE_KDE_SUPPORT
        static const Atom constNetMoveResize = XInternAtom(QX11Info::display(), "_NET_WM_MOVERESIZE", False);
        //...Taken from bespin...
        // stolen... errr "adapted!" from QSizeGrip
        QX11Info info;
        XEvent xev;
        xev.xclient.type = ClientMessage;
        xev.xclient.message_type = constNetMoveResize;
        xev.xclient.display = QX11Info::display();
        xev.xclient.window = widget->window()->winId();
        xev.xclient.format = 32;
        xev.xclient.data.l[0] = position.x();
        xev.xclient.data.l[1] = position.y();
        xev.xclient.data.l[2] = 8; // NET::Move
        xev.xclient.data.l[3] = Button1;
        xev.xclient.data.l[4] = 0;
        XUngrabPointer(QX11Info::display(), QX11Info::appTime());
        XSendEvent(QX11Info::display(), QX11Info::appRootWindow(info.screen()), False,
                   SubstructureRedirectMask | SubstructureNotifyMask, &xev);
        #else
        XUngrabPointer(QX11Info::display(), QX11Info::appTime());
        NETRootInfo rootInfo(QX11Info::display(), NET::WMMoveResize);
        rootInfo.moveResizeRequest(widget->window()->winId(), position.x(), position.y(), NET::Move);
        #endif // !ENABLE_KDE_SUPPORT
        #endif
    }

    if (!useWMMoveResize() && !_cursorOverride) {
        qApp->setOverrideCursor(Qt::DragMoveCursor);
        _cursorOverride = true;
    }

    _dragInProgress = true;
    return;
}
示例#8
0
Diversia::Util::String OgreWidget::getWidgetHandle()
{
#if DIVERSIA_PLATFORM == DIVERSIA_PLATFORM_WIN32
    return Ogre::StringConverter::toString( (size_t)( (HWND)winId() ) );
#elif DIVERSIA_PLATFORM == DIVERSIA_PLATFORM_LINUX
    QWidget* q_parent = dynamic_cast <QWidget *> ( parent() );
    QX11Info xInfo = x11Info();

    return Ogre::StringConverter::toString( (unsigned long)xInfo.display() ) +
        ":" + Ogre::StringConverter::toString( (unsigned int)xInfo.screen() ) +
        ":" + Ogre::StringConverter::toString( (unsigned long)q_parent->winId() );
#else
    DivAssert( 0, "Cannot get widget handle, unsupported OS" );
#endif

    return "";
}
示例#9
0
Ogre::NameValuePairList OgreWidget::getWinParams()
{
	Ogre::NameValuePairList params;

#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
	params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId()));
#else
#if QT_VERSION < 0x050000
	const QX11Info info = this->x11Info();
	Ogre::String winHandle;
	winHandle = Ogre::StringConverter::toString((unsigned long)(info.display()));
	winHandle += ":";
	winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
	winHandle += ":";
	winHandle += Ogre::StringConverter::toString((unsigned long)(this->winId()));
	winHandle += ":";
	winHandle += Ogre::StringConverter::toString((unsigned long)(info.visual()));

	params["externalWindowHandle"] = winHandle;

#elif QT_VERSION >= 0x050100 && defined(Q_WS_X11)
	const QX11Info info = this->x11Info();
	Ogre::String winHandle;
	winHandle = Ogre::StringConverter::toString((unsigned long)(info.display()));
	winHandle += ":";
	winHandle += Ogre::StringConverter::toString((unsigned int)(info.appScreen()));
	winHandle += ":";
	winHandle += Ogre::StringConverter::toString((unsigned long)(this->winId()));

	params["externalWindowHandle"] = winHandle;
#else // only for the time between Qt 5.0 and Qt 5.1 when QX11Info was not included
	params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId()));
#endif
#endif

#if defined(Q_OS_MAC)
	params["macAPI"] = "cocoa";
	params["macAPICocoaUseNSView"] = "true";
#endif

	return params;
}
void CarioQImageMainWindow::on_create_image_by_xlib_button_clicked()
{
    int height = ui->label->height();
    int width = ui->label->width();

    QPixmap *pixmap = new QPixmap(width, height);

    QPainter painter(pixmap);
    QPaintDevice *pd = painter.device();
    if(pd->devType() == QInternal::Pixmap)
    {
        QPixmap *pixmap_inner = (QPixmap*) pd;
        Drawable d = (Drawable) pixmap_inner->handle();
        QX11Info xinfo = pixmap_inner->x11Info();
        int width = pixmap_inner->width();
        int height = pixmap_inner->height();

        cairo_surface_t * pCairoSurface =
                cairo_xlib_surface_create_with_xrender_format
                    (xinfo.display(),
                     d,
                     ScreenOfDisplay(xinfo.display(), xinfo.screen()),
                     XRenderFindVisualFormat (xinfo.display(), (Visual*) xinfo.visual()),
                     width,
                     height);

        cairo_t* pCairoContext = cairo_create(pCairoSurface);
        cairo_surface_destroy(pCairoSurface);
        if(pCairoContext)
        {
            cairo_set_source_rgb (pCairoContext, 0.627, 0, 0);
            cairo_set_font_size (pCairoContext, 24.0);

            cairo_move_to (pCairoContext, 10.0, 34.0);
            cairo_show_text (pCairoContext, "Hello, world\nUsing Image X11 Surface");

            cairo_destroy(pCairoContext);
        }
    }

    ui->label->setPixmap(*pixmap);
}
void OgreWidget::initOgreSystem()
{
    ogreRoot = new Ogre::Root();

    Ogre::RenderSystem *renderSystem = ogreRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    ogreRoot->setRenderSystem(renderSystem);
    ogreRoot->initialise(false);

    ogreSceneManager = ogreRoot->createSceneManager(Ogre::ST_GENERIC);

    Ogre::NameValuePairList viewConfig;
    Ogre::String widgetHandle;
#ifdef Q_WS_WIN
    widgetHandle = Ogre::StringConverter::toString((size_t)((HWND)winId()));
#else
    QWidget *q_parent = dynamic_cast <QWidget *> (parent());
    QX11Info xInfo = x11Info();

    widgetHandle = Ogre::StringConverter::toString ((unsigned long)xInfo.display()) +
        ":" + Ogre::StringConverter::toString ((unsigned int)xInfo.screen()) +
        ":" + Ogre::StringConverter::toString ((unsigned long)q_parent->winId());

#endif
    viewConfig["externalWindowHandle"] = widgetHandle;
    ogreRenderWindow = ogreRoot->createRenderWindow("Ogre rendering window",
                width(), height(), false, &viewConfig);

    ogreCamera = ogreSceneManager->createCamera("myCamera");
    Ogre::Vector3 camPos(0, 50,150);
        ogreCamera->setPosition(camPos);
        ogreCamera->lookAt(0,50,0);
    emit cameraPositionChanged(camPos);

    ogreViewport = ogreRenderWindow->addViewport(ogreCamera);
    ogreViewport->setBackgroundColour(Ogre::ColourValue(0,0,255));
    ogreCamera->setAspectRatio(Ogre::Real(width()) / Ogre::Real(height()));

        setupNLoadResources();
        createScene();
}
示例#12
0
int kScreenSaverMain( int argc, char** argv, KScreenSaverInterface& screenSaverInterface )
{
    KLocale::setMainCatalog("libkscreensaver");
    KCmdLineArgs::init(argc, argv, screenSaverInterface.aboutData());


    KCmdLineOptions options;

    options.add("setup", ki18n("Setup screen saver"));

    options.add("window-id wid", ki18n("Run in the specified XWindow"));

    options.add("root", ki18n("Run in the root XWindow"));

    options.add("demo", ki18n("Start screen saver in demo mode"), "default");

    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    // Set a useful default icon.
    app.setWindowIcon(KIcon("preferences-desktop-screensaver"));


    if (!pipe(termPipe))
    {
#ifndef Q_WS_WIN
        struct sigaction sa;
        sa.sa_handler = termHandler;
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = 0;
        sigaction(SIGTERM, &sa, 0);
#endif
        QSocketNotifier *sn = new QSocketNotifier(termPipe[0], QSocketNotifier::Read, &app);
        QObject::connect(sn, SIGNAL(activated(int)), &app, SLOT(quit()));
    }

#ifdef Q_WS_X11
    oldXErrorHandler = XSetErrorHandler(xErrorHandler);
#endif
    KCrash::setCrashHandler( crashHandler );
    KGlobal::locale()->insertCatalog("klock");
    KGlobal::locale()->insertCatalog("kscreensaver");

    DemoWindow *demoWidget = 0;
    Window saveWin = 0;
    KScreenSaver *target;

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if (args->isSet("setup"))
    {
       QDialog *dlg = screenSaverInterface.setup();
       args->clear();
       dlg->exec();
       delete dlg;
       return 0;
    }

    if (args->isSet("window-id"))
    {
#ifdef Q_WS_WIN
        saveWin = (HWND)(args->getOption("window-id").toULong());
#else
        saveWin = args->getOption("window-id").toInt();
#endif
    }

#ifdef Q_WS_X11 //FIXME
    if (args->isSet("root"))
    {
		QX11Info inf;
        saveWin = RootWindow(QX11Info::display(), inf.screen());
    }
#endif

    if (args->isSet("demo"))
    {
        saveWin = 0;
    }

    if (saveWin == 0)
    {
        demoWidget = new DemoWindow();
        demoWidget->setAttribute(Qt::WA_NoSystemBackground);
        demoWidget->setAttribute(Qt::WA_PaintOnScreen);
        demoWidget->show();
        app.processEvents();
        saveWin = demoWidget->winId();
    }

    target = screenSaverInterface.create( saveWin );
    target->setAttribute(Qt::WA_PaintOnScreen);
    target->show();

    if (demoWidget)
    {
        target->installEventFilter( demoWidget );
    }

    args->clear();
    app.exec();

    delete target;
    delete demoWidget;

    return 0;
}
示例#13
0
    Ogre::RenderWindow* ExternalRenderWindow::CreateRenderWindow(const std::string &name,  int width, int height, int left, int top, bool fullscreen)
    {
        bool stealparent 
            ((parentWidget())? true : false);

        QWidget *nativewin 
            ((stealparent)? parentWidget() : this);

        Ogre::NameValuePairList params;
        Ogre::String winhandle;

#ifdef Q_WS_WIN
        // According to Ogre Docs
        // positive integer for W32 (HWND handle)
        winhandle = Ogre::StringConverter::toString 
            ((unsigned int) 
             (nativewin-> winId ()));

        //Add the external window handle parameters to the existing params set.
        params["externalWindowHandle"] = winhandle;

#endif

#ifdef Q_WS_MAC
    // qt docs say it's a HIViewRef on carbon,
    // carbon docs say HIViewGetWindow gets a WindowRef out of it

#if 0
    HIViewRef vref = (HIViewRef) nativewin-> winId ();
    WindowRef wref = HIViewGetWindow(vref);
        winhandle = Ogre::StringConverter::toString(
           (unsigned long) (HIViewGetRoot(wref)));
#else
        // according to
        // http://www.ogre3d.org/forums/viewtopic.php?f=2&t=27027 does
        winhandle = Ogre::StringConverter::toString(
                     (unsigned long) nativewin->winId());
#endif
        //Add the external window handle parameters to the existing params set.
        params["externalWindowHandle"] = winhandle;
#endif

#ifdef Q_WS_X11
        // GLX - According to Ogre Docs:
        // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
        QX11Info info =  x11Info ();

        winhandle  = Ogre::StringConverter::toString 
            ((unsigned long)
             (info.display ()));
        winhandle += ":";

        winhandle += Ogre::StringConverter::toString 
            ((unsigned int)
             (info.screen ()));
        winhandle += ":";
        
        winhandle += Ogre::StringConverter::toString 
            ((unsigned long)
             nativewin-> winId());

        //Add the external window handle parameters to the existing params set.
        params["parentWindowHandle"] = winhandle;
#endif

        // Window position to params
        if (left != -1)
            params["left"] = ToString(left);
        if (top != -1)
            params["top"] = ToString(top);

        render_window_ = Ogre::Root::getSingletonPtr()-> createRenderWindow(name, width, height, fullscreen, &params);

        return render_window_;

    }
示例#14
0
int main(int argc, char *argv[])
{
	KCmdLineArgs::init(argc, argv, appName, "kscreensaver", ki18n("Random screen saver"), 
                KDE_VERSION_STRING, ki18n(description));


	KCmdLineOptions options;

	options.add("setup", ki18n("Setup screen saver"));

	options.add("window-id wid", ki18n("Run in the specified XWindow"));

	options.add("root", ki18n("Run in the root XWindow"));

	KCmdLineArgs::addCmdLineOptions(options);

	KApplication app;

	WId windowId = 0;

	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	if (args->isSet("setup"))
	{
		KRandomSetup setup;
		setup.exec();
		exit(0);
	}

	if (args->isSet("window-id"))
	{
		windowId = args->getOption("window-id").toInt();
	}

#ifdef Q_WS_X11
	if (args->isSet("root"))
	{
		QX11Info info;
		windowId = RootWindow(QX11Info::display(), info.screen());
	}
#endif
	args->clear();
	const KService::List lst = KServiceTypeTrader::self()->query( "ScreenSaver");
        KService::List availableSavers;

	KConfig type("krandom.kssrc", KConfig::NoGlobals);
        const KConfigGroup configGroup = type.group("Settings");
	const bool opengl = configGroup.readEntry("OpenGL", false);
	const bool manipulatescreen = configGroup.readEntry("ManipulateScreen", false);
        // TODO replace this with TryExec=fortune in the desktop files
        const bool fortune = !KStandardDirs::findExe("fortune").isEmpty();
        foreach( const KService::Ptr& service, lst ) {
            //QString file = KStandardDirs::locate("services", service->entryPath());
            //kDebug() << "Looking at " << file;
            const QString saverType = service->property("X-KDE-Type").toString();
            foreach (const QString &type, saverType.split(QLatin1Char(';'))) {
                //kDebug() << "saverTypes is "<< type;
                if (type == QLatin1String("ManipulateScreen")) {
                    if (!manipulatescreen)
                        goto fail;
                } else if (type == QLatin1String("OpenGL")) {
                    if (!opengl)
                        goto fail;
                } else if (type == QLatin1String("Fortune")) {
                    if (!fortune)
                        goto fail;
                }
            }
            availableSavers.append(service);
          fail: ;
        }

	KRandomSequence rnd;
	const int indx = rnd.getLong(availableSavers.count());
        const KService::Ptr service = availableSavers.at(indx);
        const QList<KServiceAction> actions = service->actions();

	QString cmd;
	if (windowId)
            cmd = exeFromActionGroup(actions, "InWindow");
        if (cmd.isEmpty() && windowId == 0)
            cmd = exeFromActionGroup(actions, "Root");
        if (cmd.isEmpty())
            cmd = service->exec();

    QHash<QChar, QString> keyMap;
    keyMap.insert('w', QString::number(windowId));
    const QStringList words = KShell::splitArgs(KMacroExpander::expandMacrosShellQuote(cmd, keyMap));
    if (!words.isEmpty()) {
        QString exeFile = KStandardDirs::findExe(words.first());
        if (!exeFile.isEmpty()) {
            char **sargs = new char *[words.size() + 1];
            int i = 0;
            for (; i < words.size(); i++)
                sargs[i] = qstrdup(words[i].toLocal8Bit().constData());
            sargs[i] = 0;

            execv(exeFile.toLocal8Bit(), sargs);
        }
    }

	// If we end up here then we couldn't start a saver.
	// If we have been supplied a window id or root window then blank it.
#ifdef Q_WS_X11
	QX11Info info;
	Window win = windowId ? windowId : RootWindow(QX11Info::display(), info.screen());
	XSetWindowBackground(QX11Info::display(), win,
			BlackPixel(QX11Info::display(), info.screen()));
	XClearWindow(QX11Info::display(), win);
#endif
}
示例#15
0
void OgreWidget::create_render_window ()
{
    if (win_) return;

    bool stealparent (parentWidget() != NULL);
    QWidget *nativewin ((stealparent)? parentWidget () : this);

    Ogre::NameValuePairList params;
    Ogre::String winhandle;

#ifdef Q_WS_WIN
    // According to Ogre Docs
    // positive integer for W32 (HWND handle)
    winhandle = Ogre::StringConverter::toString 
        ((unsigned int) 
         (nativewin-> winId ()));

    //Add the external window handle parameters to the existing params set.
    params["externalWindowHandle"] = winhandle;
#endif

#ifdef Q_WS_X11
    // GLX - According to Ogre Docs:
    // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
    QX11Info info = x11Info ();

    winhandle  = Ogre::StringConverter::toString 
        ((unsigned long)
         (info.display ()));
    winhandle += ":";

    winhandle += Ogre::StringConverter::toString 
        ((unsigned int)
         (info.screen ()));
    winhandle += ":";
    
    winhandle += Ogre::StringConverter::toString 
        ((unsigned long)
         nativewin-> winId());
         //(isHidden ()) ? 
         //nativewin-> effectiveWinId () : 
         //nativewin-> winId ());

    //Add the external window handle parameters to the existing params set.
    params["parentWindowHandle"] = winhandle;
#endif

    win_ = root_-> createRenderWindow ("View", width(), height(), false, &params);

    // take over ogre window
    // needed with parent windows
    if (stealparent)
    {
        WId ogre_winid = 0x0;
#ifndef Q_WS_WIN
        win_-> getCustomAttribute ("WINDOW", &ogre_winid);
#else
        win_-> getCustomAttribute ("HWND", &ogre_winid);
#endif
        assert (ogre_winid);
        create (ogre_winid);
    }
}
示例#16
0
	/**
	* @brief setup the rendering context
	* @author Kito Berg-Taylor
	*/
	void OgreWidget::initializeGL()
	{
		//== Creating and Acquiring Ogre Window ==//

		// Get the parameters of the window QT created
		Ogre::String winHandle;
	#ifdef WIN32
		// Windows code
		winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
	#elif MACOS
		// Mac code, tested on Mac OSX 10.6 using Qt 4.7.4 and Ogre 1.7.3
		Ogre::String winHandle  = Ogre::StringConverter::toString(winId());
	#else
		// Unix code
		QX11Info info = x11Info();
		winHandle  = Ogre::StringConverter::toString((unsigned long)(info.display()));
		winHandle += ":";
		winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
		winHandle += ":";
		winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
	#endif

		Ogre::NameValuePairList params;
	#ifndef MACOS
		// code for Windows and Linux
		params["parentWindowHandle"] = winHandle;
		_mOgreWindow = _mOgreRoot->createRenderWindow(	"QOgreWidget_RenderWindow",
														this->width(),
														this->height(),
														false,
														&params);

		_mOgreWindow->setActive(true);
		WId ogreWinId = 0x0;
		_mOgreWindow->getCustomAttribute("WINDOW", &ogreWinId);

		assert(ogreWinId);

		// bug fix, extract geometry
		QRect geo = this->frameGeometry();

		// create new window
		this->create(ogreWinId);

		// set geometrie infos to new window
		this->setGeometry(geo);

	#else
		// code for Mac
		params["externalWindowHandle"] = winHandle;
		params["macAPI"] = "cocoa";
		params["macAPICocoaUseNSView"] = "true";
		mOgreWindow = mOgreRoot->createRenderWindow("QOgreWidget_RenderWindow",
													width(), height(), false, &params);
		mOgreWindow->setActive(true);
		makeCurrent();
	#endif

		setAttribute(Qt::WA_PaintOnScreen, true);
		setAttribute(Qt::WA_NoBackground);

		//== Ogre Initialization ==//
		Ogre::SceneType scene_manager_type = Ogre::ST_EXTERIOR_CLOSE;

		_mSceneMgr = _mOgreRoot->createSceneManager(scene_manager_type);
		_mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));

		_mCamera = _mSceneMgr->createCamera("QOgreWidget_Cam");
		_mCamera->setPosition(Ogre::Vector3(0, 0, 80));
		_mCamera->lookAt(Ogre::Vector3(0, 0, -300));
		_mCamera->setNearClipDistance(1.0f);

		Ogre::Viewport *mViewport = _mOgreWindow->addViewport(_mCamera);
		mViewport->setBackgroundColour(Ogre::ColourValue(0.1f, 0.1f, 1.0f));




		/*
		Ogre::ConfigFile cf;
		cf.load("resources.cfg");

		// Go through all sections & settings in the file
		Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

		Ogre::String secName, typeName, archName;
		while (seci.hasMoreElements())
		{
			secName = seci.peekNextKey();
			Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
			Ogre::ConfigFile::SettingsMultiMap::iterator i;
			for (i = settings->begin(); i != settings->end(); ++i)
			{
				typeName = i->first;
				archName = i->second;
				Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
					archName, typeName, secName);
			}
		}

		// load resources
		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		//-------------------------------------------------------------------------------------
		// Create the scene
		Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");

		Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		headNode->attachObject(ogreHead);

		// Set ambient light
		mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

		// Create a light
		Ogre::Light* l = mSceneMgr->createLight("MainLight");
		l->setPosition(20,80,50);
		*/
	}
示例#17
0
void RenderWindow::CreateRenderWindow(QWidget *targetWindow, const QString &name, int width, int height, int left, int top, bool fullscreen, Framework *fw)
{
    Ogre::NameValuePairList params;

#ifdef ANDROID
    fullscreen = true;

    /// \todo This should not be done here, but doing it in Tundra's main seems to be unreliable and lead to crashes
    JavaVM* vm = Framework::JavaVMInstance();
    JNIEnv* env;
    vm->AttachCurrentThread(&env, 0);
    if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK)
    {
	LogError("CreateRenderWindow: GetEnv failed");
	return;
    }
    Framework::SetJniEnvInstance(env);

    if (!env)
    {    
	LogError("CreateRenderWindow: Null Java environment, can not call Java methods");
	return;
    }

    jobject result = env->CallStaticObjectMethod(qtApplicationClass, getSurfaceMethod);
    if (!result)
    {
        LogError("CreateRenderWindow: Surface was null");
	return;
    }  

/*
    jclass clsID = env->GetObjectClass(result);
    jmethodID msgMethodID;
    const char* localstr = NULL;
    jclass javaClassClsID = env->FindClass("java/lang/Class");
    msgMethodID = env->GetMethodID(javaClassClsID, "getName", "()Ljava/lang/String;");
    if(msgMethodID == NULL)
        LogInfo("Null getName method");
    else 
    {
        jstring clsName = (jstring)env->CallObjectMethod(clsID, msgMethodID);
        localstr = env->GetStringUTFChars(clsName, NULL);
        LogInfo("Surface class name: " + QString(localstr));
    }
*/

    LogInfo("CreateRenderWindow: calling ANativeWindow_fromSurface");
    ANativeWindow* window = ANativeWindow_fromSurface(env, result);

    params["externalWindowHandle"] = Ogre::StringConverter::toString((int)window);
#endif

    /** See http://www.ogre3d.org/tikiwiki/RenderWindowParameters
        @note All the values must be strings. Assigning int/bool etc. directly to the map produces a empty string value!
        @bug Check if the keys and values are valid from Ogre::RenderSystem::getConfigOptions(). If you feed carbage to the map outside the accepted values
        (eg. FSAA) you may crash when the render window is created. Additionally if the map keys are case sensitive we might have bugs below (eg. vsync vs. VSync)! */
    if (fw->CommandLineParameters("--vsyncFrequency").length() > 0) // "Display frequency rate; only applies if fullScreen is set."
        params["displayFrequency"] = fw->CommandLineParameters("--vsyncFrequency").first().toStdString();
    if (fw->CommandLineParameters("--vsync").length() > 0) // "Synchronize buffer swaps to monitor vsync, eliminating tearing at the expense of a fixed frame rate"
        params["vsync"] = fw->CommandLineParameters("--vsync").first().toStdString();
    else if (fw->Config()->HasKey(ConfigAPI::FILE_FRAMEWORK, ConfigAPI::SECTION_RENDERING, "vsync"))
    {
        QString value = fw->Config()->Get(ConfigAPI::FILE_FRAMEWORK, ConfigAPI::SECTION_RENDERING, "vsync", "").toString();
        if (!value.isEmpty())
            params["vsync"] = value.toStdString();
    }
    if (fw->CommandLineParameters("--antialias").length() > 0) // "Full screen antialiasing factor"
        params["FSAA"] = fw->CommandLineParameters("--antialias").first().toStdString();
    else if (fw->Config()->HasKey(ConfigAPI::FILE_FRAMEWORK, ConfigAPI::SECTION_RENDERING, "antialias"))
    {
        // Accepted FSAA values can be more than just a number, allow any string from config file. 
        QString value = fw->Config()->Get(ConfigAPI::FILE_FRAMEWORK, ConfigAPI::SECTION_RENDERING, "antialias", "").toString();
        if (!value.isEmpty())
            params["FSAA"] = value.toStdString();
    }
        
#ifdef WIN32
    if (targetWindow)
        params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned int)targetWindow->winId());
#endif

#ifdef Q_WS_MAC
    Ogre::String winhandle;

    QWidget* nativewin = targetWindow;

    while(nativewin && nativewin->parentWidget())
        nativewin = nativewin->parentWidget();

    // according to
    // http://www.ogre3d.org/forums/viewtopic.php?f=2&t=27027 does
    winhandle = Ogre::StringConverter::toString(
        (unsigned long)nativewin ? nativewin->winId() : 0);

    //Add the external window handle parameters to the existing params set.
    params["externalWindowHandle"] = winhandle;
    
    /* According to http://doc.qt.nokia.com/stable/qwidget.html#winId
       "On Mac OS X, the type returned depends on which framework Qt was linked against. 
       -If Qt is using Carbon, the {WId} is actually an HIViewRef. 
       -If Qt is using Cocoa, {WId} is a pointer to an NSView."
      Ogre needs to know that a NSView handle will be passed to its' externalWindowHandle parameter,
      otherwise it assumes that NSWindow will be used 
    */
    params["macAPI"] = "cocoa";
    params["macAPICocoaUseNSView"] = "true";
#endif

#ifdef Q_WS_X11
    QWidget *parent = targetWindow;
    while(parent && parent->parentWidget())
        parent = parent->parentWidget();

    // GLX - According to Ogre Docs:
    // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
    QX11Info info = targetWindow->x11Info();

    Ogre::String winhandle = Ogre::StringConverter::toString((unsigned long)(info.display()));
    winhandle += ":" + Ogre::StringConverter::toString((unsigned int)(info.screen()));
    winhandle += ":" + Ogre::StringConverter::toString((unsigned long)parent ? parent->winId() : 0);

    //Add the external window handle parameters to the existing params set.
    params["parentWindowHandle"] = winhandle;
#endif

    // Window position to params
    if (left != -1)
        params["left"] = Ogre::StringConverter::toString(left);
    if (top != -1)
        params["top"] = Ogre::StringConverter::toString(top);

#ifdef WIN32
    if (fw->HasCommandLineParameter("--perfHud"))
    {
        params["useNVPerfHUD"] = "true";
        params["Rendering Device"] = "NVIDIA PerfHUD";
    }
#endif

    renderWindow = Ogre::Root::getSingletonPtr()->createRenderWindow(name.toStdString().c_str(), width, height, fullscreen, &params);
    renderWindow->setDeactivateOnFocusChange(false);

    // Currently do not create UI overlay on Android to save fillrate
#ifndef ANDROID
    CreateRenderTargetOverlay(width, height);
#endif
}
示例#18
0
    void OgreWidget::init() {
        //These attributes are the same as those use in a QGLWidget
        setAttribute(Qt::WA_PaintOnScreen);
        setAttribute(Qt::WA_NoSystemBackground);

        //Parameters to pass to Ogre::Root::createRenderWindow()
        Ogre::NameValuePairList params;
        params["useNVPerfHUD"] = "true";

        //The external windows handle parameters are platform-specific
        Ogre::String externalWindowHandleParams;

        //Accept input focus
        setFocusPolicy(Qt::StrongFocus);

#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
        //positive integer for W32 (HWND handle) - According to Ogre Docs
        externalWindowHandleParams = Ogre::StringConverter::toString((size_t)(winId()));
#endif

#if defined(Q_WS_X11)
        //poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX - According to Ogre Docs
        QX11Info info = x11Info();
        externalWindowHandleParams  = Ogre::StringConverter::toString((unsigned long)(info.display()));
        externalWindowHandleParams += ":";
        externalWindowHandleParams += Ogre::StringConverter::toString((unsigned int)(info.screen()));
        externalWindowHandleParams += ":";
        externalWindowHandleParams += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
        //    winHandle += Ogre::StringConverter::toString((unsigned long)(this->window()->winId()));
           //params["parentWindowHandle"] = winHandle;
#endif

        //Add the external window handle parameters to the existing params set.
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
        params["externalWindowHandle"] = externalWindowHandleParams;
#endif

#if defined(Q_WS_X11)
        params["parentWindowHandle"] = externalWindowHandleParams;
#endif

#if defined(Q_WS_MAC)
        params["macAPI"] = "cocoa";
        params["macAPICocoaUseNSView"] = "true";
#endif


         //Finally create our window.
        mOgreWindow = this->mOgreRoot->createRenderWindow(
                "OgreWindow" + QString::number(ogrewidgetCpt++).toStdString()
                , 640, 480, false, &params);

        mOgreWindow->setActive(true);
        WId ogreWinId = 0x0;
        mOgreWindow->getCustomAttribute( "WINDOW", &ogreWinId );


        //assert( ogreWinId );

#if defined(Q_WS_X11)
        // TAG: Build on linux
        create( ogreWinId );
#endif
        // Create the free camera (FIXME no encapsulation)
        if(mCamera == NULL){

            Ogre::Camera* cam1 = mSceneMgr->createCamera("firstCamera");
            cam1->setPosition(Ogre::Vector3(0, 2, 6));
            cam1->lookAt(Ogre::Vector3(0, 2, 0));
            cam1->setNearClipDistance(0.01); // 10 mm
            cam1->setFarClipDistance(5000); // 1km
            mCamera = cam1;
        }


        mViewport = mOgreWindow->addViewport( mCamera );
        mViewport->setBackgroundColour( Ogre::ColourValue( 0.5,0.5,1 ) );
        mViewport->setOverlaysEnabled(true);
        mIsInit = true;
        resized = true;


        ogreFreeCamera = new OgreFreeCamera(mCamera);

        connect(this,SIGNAL(keyPressed(QKeyEvent*)),ogreFreeCamera,SLOT(keyPressEvent(QKeyEvent*)));
        connect(this,SIGNAL(keyReleased(QKeyEvent*)),ogreFreeCamera,SLOT(keyReleaseEvent(QKeyEvent*)));
        connect(this,SIGNAL(mouseMoved(QMouseEvent*)),ogreFreeCamera,SLOT(mouseMoveEvent(QMouseEvent*)));
        connect(this,SIGNAL(mousePressed(QMouseEvent*)),ogreFreeCamera,SLOT(mousePressEvent(QMouseEvent*)));
        connect(this,SIGNAL(mouseReleased(QMouseEvent*)),ogreFreeCamera,SLOT(mouseReleaseEvent(QMouseEvent*)));
        connect(this,SIGNAL(entered(QEvent*)),ogreFreeCamera,SLOT(enterViewPortEvent(QEvent*)));
        connect(this,SIGNAL(leaved(QEvent*)),ogreFreeCamera,SLOT(leaveViewPortEvent(QEvent*)));
        connect(this,SIGNAL(stepped()),ogreFreeCamera,SLOT(step()));

    }
示例#19
0
/**
*@brief Ogre3Dのレンダリングの表示のウィジェットのコンストラクタ
* @param parent 親ウィジェット
*/
OgreWidget::OgreWidget(QWidget *parent) :
#ifdef Q_OS_WIN
QWidget(parent,Qt::WindowFlags(Qt::MSWindowsOwnDC))
#else
QWidget(parent)
#endif
{
	QTextCodec* tc = QTextCodec::codecForLocale();
	

	setAttribute(Qt::WA_PaintOnScreen);
	setAutoFillBackground(true);
	setAttribute(Qt::WA_NoBackground);
	setAttribute(Qt::WA_InputMethodEnabled);

	setMouseTracking(true);

	setFocusPolicy(Qt::WheelFocus);

	//setAcceptDrops(true);
	setContextMenuPolicy( Qt::PreventContextMenu );

	setMaximumSize(windowSizeX, windowSizeY);
	setMinimumSize(windowSizeX, windowSizeY);

	//setSizeIncrement(1024, 768);

	//update();


}


/**
*@brief Ogre3Dのレンダリングの表示のウィジェットのデストラクタ
*/
OgreWidget::~OgreWidget(void)
{

}


/**
*@brief レンダリング初期化
*/
void OgreWidget::initOgre()
{
	
	{
		Ogre::String winHandle;
#ifdef Q_OS_WIN

		winHandle = Ogre::StringConverter::toString((size_t)((HWND)winId()));
		

		//winHandle += Ogre::StringConverter::toString((unsigned long)(winId()));
#else
		QX11Info info = this->x11Info();
		winHandle  = Ogre::StringConverter::toString((unsigned long)(info.display()));
		winHandle += ":";
		winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
		winHandle += ":";
		winHandle += Ogre::StringConverter::toString((unsigned long)(window()->winId()));
#endif
		mOgreRTCApplication = OgreRTCApplication::getSingletonPtr();
		WId ogreWinId = mOgreRTCApplication->initRenderWindow(winHandle, windowSizeX, windowSizeY);

#ifdef Q_OS_WIN
#else
		QRect geo = this->frameGeometry();
		create(ogreWinId);
		setGeometry(geo);
#endif

		//mOgreApp->start();
		mOgreRTCApplication->update(100);
	}
示例#20
0
文件: main.cpp 项目: sempuki/code
Ogre::RenderWindow *QOgreUIView::CreateRenderWindow ()
{
    bool stealparent 
        ((parentWidget())? true : false);

    QWidget *nativewin 
        ((stealparent)? parentWidget() : this);

    Ogre::NameValuePairList params;
    Ogre::String winhandle;

#ifdef Q_WS_WIN
    // According to Ogre Docs
    // positive integer for W32 (HWND handle)
    winhandle = Ogre::StringConverter::toString 
        ((unsigned int) 
         (nativewin-> winId ()));

    //Add the external window handle parameters to the existing params set.
    params["externalWindowHandle"] = winhandle;
#endif

#ifdef Q_WS_X11
    // GLX - According to Ogre Docs:
    // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
    QX11Info info =  x11Info ();

    winhandle  = Ogre::StringConverter::toString 
        ((unsigned long)
         (info.display ()));
    winhandle += ":";

    winhandle += Ogre::StringConverter::toString 
        ((unsigned int)
         (info.screen ()));
    winhandle += ":";
    
    winhandle += Ogre::StringConverter::toString 
        ((unsigned long)
         nativewin-> winId());

    //Add the external window handle parameters to the existing params set.
    params["parentWindowHandle"] = winhandle;
#endif

    QSize size (nativewin-> size());
    win_ = Ogre::Root::getSingletonPtr()-> 
        createRenderWindow ("View", size.width(), size.height(), false, &params);

    // take over ogre window
    // needed with parent windows
    if (stealparent)
    {
        WId ogre_winid = 0x0;
#ifndef Q_WS_WIN
        win_-> getCustomAttribute ("WINDOW", &ogre_winid);
#else
        win_-> getCustomAttribute ("HWND", &ogre_winid);
#endif
        assert (ogre_winid);
        create (ogre_winid);
    }

    return win_;
}
示例#21
0
void RenderWindow::CreateRenderWindow(QWidget *targetWindow, const QString &name, int width, int height, int left, int top, bool fullscreen)
{
    Ogre::NameValuePairList params;

#ifdef WIN32
    params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned int)targetWindow->winId());
#endif

#ifdef Q_WS_MAC
// qt docs say it's a HIViewRef on carbon,
// carbon docs say HIViewGetWindow gets a WindowRef out of it
    Ogre::String winhandle;

    QWidget* nativewin = targetWindow;

    while(nativewin->parentWidget())
        nativewin = nativewin->parentWidget();
#if 0
    HIViewRef vref = (HIViewRef) nativewin-> winId ();
    WindowRef wref = HIViewGetWindow(vref);
    winhandle = Ogre::StringConverter::toString(
       (unsigned long) (HIViewGetRoot(wref)));
#else
    // according to
    // http://www.ogre3d.org/forums/viewtopic.php?f=2&t=27027 does
    winhandle = Ogre::StringConverter::toString(
                 (unsigned long) nativewin->winId());
#endif
    //Add the external window handle parameters to the existing params set.
    params["externalWindowHandle"] = winhandle;
#endif

#ifdef Q_WS_X11
    QWidget *parent = targetWindow;
    while(parent->parentWidget())
        parent = parent->parentWidget();

    // GLX - According to Ogre Docs:
    // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
    QX11Info info = targetWindow->x11Info();

    Ogre::String winhandle = Ogre::StringConverter::toString((unsigned long)(info.display()));
    winhandle += ":" + Ogre::StringConverter::toString((unsigned int)(info.screen()));
    winhandle += ":" + Ogre::StringConverter::toString((unsigned long)parent->winId());

    //Add the external window handle parameters to the existing params set.
    params["parentWindowHandle"] = winhandle;
#endif

    // Window position to params
    if (left != -1)
        params["left"] = ToString(left);
    if (top != -1)
        params["top"] = ToString(top);

#ifdef USE_NVIDIA_PERFHUD
    params["useNVPerfHUD"] = "true";
    params["Rendering Device"] = "NVIDIA PerfHUD";
#endif

    renderWindow = Ogre::Root::getSingletonPtr()->createRenderWindow(name.toStdString().c_str(), width, height, fullscreen, &params);
    renderWindow->setDeactivateOnFocusChange(false);

    CreateRenderTargetOverlay(width, height);
}