当前位置: 首页>>代码示例>>C++>>正文


C++ QX11Info类代码示例

本文整理汇总了C++中QX11Info的典型用法代码示例。如果您正苦于以下问题:C++ QX11Info类的具体用法?C++ QX11Info怎么用?C++ QX11Info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QX11Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createOgreWindowIdForQWidget

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;
}
开发者ID:AlanSmithee1984,项目名称:Open3DGraphicsAdventureEngine,代码行数:30,代码来源:ogreutils.cpp

示例2: XWithdrawWindow

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;
}
开发者ID:jschwartzenberg,项目名称:kicker,代码行数:26,代码来源:dockcontainer.cpp

示例3: XUngrabPointer

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();
}
开发者ID:thibautquentinjacob,项目名称:BespinMod,代码行数:30,代码来源:resizecorner.cpp

示例4: xshmimg

QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget)
    : xshmimg(0), xshmpm(0)
{
    if (!X11->use_mitshm) {
        image = QImage(width, height, format);
        // follow good coding practice and set xshminfo attributes, though values not used in this case
        xshminfo.readOnly = true;
        xshminfo.shmaddr = 0;
        xshminfo.shmid = 0;
        xshminfo.shmseg = 0;
        return;
    }

    QX11Info info = widget->x11Info();

    int dd = info.depth();
    Visual *vis = (Visual*) info.visual();

    xshmimg = XShmCreateImage(X11->display, vis, dd, ZPixmap, 0, &xshminfo, width, height);
    if (!xshmimg) {
        qWarning("QNativeImage: Unable to create shared XImage.");
        return;
    }

    bool ok;
    xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height,
                            IPC_CREAT | 0777);
    ok = xshminfo.shmid != -1;
    if (ok) {
        xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
        xshminfo.shmaddr = xshmimg->data;
        ok = (xshminfo.shmaddr != (char*)-1);
        if (ok)
            image = QImage((uchar *)xshmimg->data, width, height, systemFormat());
    }
    xshminfo.readOnly = false;
    if (ok)
        ok = XShmAttach(X11->display, &xshminfo);
    if (!ok) {
        qWarning() << "QNativeImage: Unable to attach to shared memory segment.";
        if (xshmimg->data) {
            free(xshmimg->data);
            xshmimg->data = 0;
        }
        XDestroyImage(xshmimg);
        xshmimg = 0;
        if (xshminfo.shmaddr)
            shmdt(xshminfo.shmaddr);
        if (xshminfo.shmid != -1)
            shmctl(xshminfo.shmid, IPC_RMID, 0);
        return;
    }
    xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data,
                              &xshminfo, width, height, dd);
    if (!xshmpm) {
        qWarning() << "QNativeImage: Unable to create shared Pixmap.";
    }
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例5: setAttribute

	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;
	}
开发者ID:babochingu,项目名称:andrew-phd,代码行数:54,代码来源:OgreWidget.cpp

示例6: x11Info

/**
 * @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 ) );
}
开发者ID:sartraher,项目名称:exodus,代码行数:56,代码来源:ogrewidget.cpp

示例7: XInternAtom

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;
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例8: x11Info

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();
}
开发者ID:ShrademnThill,项目名称:ogre-construction-set,代码行数:47,代码来源:OgreWidget.cpp

示例9: parent

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 "";
}
开发者ID:Gohla,项目名称:Diversia,代码行数:17,代码来源:OgreWidget.cpp

示例10: x11Info

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();
}
开发者ID:Orwel,项目名称:Modelisation_Aeronautique,代码行数:40,代码来源:ogrewidget.cpp

示例11: defined

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;
}
开发者ID:quinsmpang,项目名称:Tools,代码行数:42,代码来源:OgreWidget.cpp

示例12: QPixmap

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);
}
开发者ID:nwpc,项目名称:diagnose-playground,代码行数:42,代码来源:cario_qimage_mainwindow.cpp

示例13: parentWidget

    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_;

    }
开发者ID:Ilikia,项目名称:naali,代码行数:76,代码来源:ExternalRenderWindow.cpp

示例14: main

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);
        }
    }
//.........这里部分代码省略.........
开发者ID:fluxer,项目名称:kde-workspace,代码行数:101,代码来源:random.cpp

示例15: x11Info

	/**
	* @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(
//.........这里部分代码省略.........
开发者ID:JasonForrest,项目名称:Modules,代码行数:101,代码来源:qogrewidget.cpp


注:本文中的QX11Info类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。