本文整理汇总了C++中QX11Info::screen方法的典型用法代码示例。如果您正苦于以下问题:C++ QX11Info::screen方法的具体用法?C++ QX11Info::screen怎么用?C++ QX11Info::screen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QX11Info
的用法示例。
在下文中一共展示了QX11Info::screen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: embed
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;
}
示例2: 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;
}
示例3: if
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: initialise
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, ¶ms);
mIsInitialised = true;
}
示例5: initializeGL
/**
* @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,
¶ms );
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 ) );
}
示例6: initOgreSystem
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: startDrag
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: 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 "";
}
示例9: getWinParams
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;
}
示例10: on_create_image_by_xlib_button_clicked
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);
}
示例11: initOgreSystem
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: kScreenSaverMain
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 );
}
//.........这里部分代码省略.........
示例13: CreateRenderWindow
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, ¶ms);
return render_window_;
}
示例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);
}
}
//.........这里部分代码省略.........
示例15: create_render_window
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, ¶ms);
// 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);
}
}