📄 qscreenvnc_qws.cpp
字号:
Destroys this QVNCScreen object.*/QVNCScreen::~QVNCScreen(){ delete d_ptr;}/*! \reimp*/void QVNCScreen::setDirty(const QRect& rect){ d_ptr->setDirty(rect);}void QVNCScreenPrivate::setDirty(const QRect& rect, bool force){ if (rect.isEmpty()) return; if (subscreen) subscreen->setDirty(rect); if (!vncServer || !vncServer->isConnected()) return; const QRect r = rect.translated(-q_ptr->offset()); int x1 = r.x() / MAP_TILE_SIZE; int y1 = r.y() / MAP_TILE_SIZE; for (int y = y1; y <= r.bottom() / MAP_TILE_SIZE && y < dirty->mapHeight; y++) for (int x = x1; x <= r.right() / MAP_TILE_SIZE && x < dirty->mapWidth; x++) dirty->setDirty(x, y, force); vncServer->setDirty();}static int getDisplayId(const QString &spec){ QRegExp regexp(QLatin1String(":(\\d+)\\b")); if (regexp.lastIndexIn(spec) != -1) { const QString capture = regexp.cap(1); return capture.toInt(); } return 0;}/*! \reimp*/bool QVNCScreen::connect(const QString &displaySpec){ QString dspec = displaySpec; if (dspec.startsWith(QLatin1String("vnc:"), Qt::CaseInsensitive)) dspec = dspec.mid(QString(QLatin1String("vnc:")).size()); else if (dspec.compare(QLatin1String("vnc"), Qt::CaseInsensitive) == 0) dspec = QString(); const QString displayIdSpec = QString(QLatin1String(" :%1")).arg(displayId); if (dspec.endsWith(displayIdSpec)) dspec = dspec.left(dspec.size() - displayIdSpec.size()); QStringList args = dspec.split(QLatin1Char(':'), QString::SkipEmptyParts); QRegExp refreshRegexp(QLatin1String("^refreshrate=(\\d+)$")); int index = args.indexOf(refreshRegexp); if (index >= 0) { d_ptr->refreshRate = refreshRegexp.cap(1).toInt(); args.removeAt(index); dspec = args.join(QLatin1String(":")); } QString driver = dspec; int colon = driver.indexOf(QLatin1Char(':')); if (colon >= 0) driver.truncate(colon); QScreen *screen; if (QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive)) { const int id = getDisplayId(dspec); screen = qt_get_screen(id, dspec.toLatin1().constData()); d_ptr->subscreen = screen; } else { // create virtual screen#if Q_BYTE_ORDER == Q_BIG_ENDIAN QScreen::setFrameBufferLittleEndian(false);#endif d = qgetenv("QWS_DEPTH").toInt(); if (!d) d = 16; QByteArray str = qgetenv("QWS_SIZE"); if(!str.isEmpty()) { sscanf(str.constData(), "%dx%d", &w, &h); dw = w; dh = h; } else { dw = w = 640; dh = h = 480; } const QStringList args = displaySpec.split(QLatin1Char(':'), QString::SkipEmptyParts); if (args.contains(QLatin1String("paintonscreen"), Qt::CaseInsensitive)) d_ptr->doOnScreenSurface = true; QRegExp depthRegexp(QLatin1String("^depth=(\\d+)$")); if (args.indexOf(depthRegexp) != -1) d = depthRegexp.cap(1).toInt(); QRegExp sizeRegexp(QLatin1String("^size=(\\d+)x(\\d+)$")); if (args.indexOf(sizeRegexp) != -1) { dw = w = sizeRegexp.cap(1).toInt(); dh = h = sizeRegexp.cap(2).toInt(); } // Handle display physical size spec. QRegExp mmWidthRegexp(QLatin1String("^mmWidth=?(\\d+)$")); if (args.indexOf(mmWidthRegexp) != -1) { const int mmWidth = mmWidthRegexp.cap(1).toInt(); if (mmWidth > 0) d_ptr->dpiX = dw * 25.4 / mmWidth; } QRegExp mmHeightRegexp(QLatin1String("^mmHeight=?(\\d+)$")); if (args.indexOf(mmHeightRegexp) != -1) { const int mmHeight = mmHeightRegexp.cap(1).toInt(); if (mmHeight > 0) d_ptr->dpiY = dh * 25.4 / mmHeight; } QRegExp dpiRegexp(QLatin1String("^dpi=(\\d+)(?:,(\\d+))?$")); if (args.indexOf(dpiRegexp) != -1) { const qreal dpiX = dpiRegexp.cap(1).toFloat(); const qreal dpiY = dpiRegexp.cap(2).toFloat(); if (dpiX > 0) d_ptr->dpiX = dpiX; d_ptr->dpiY = (dpiY > 0 ? dpiY : dpiX); } QWSServer::setDefaultMouse("None"); QWSServer::setDefaultKeyboard("None"); } d_ptr->configure(); // XXX qt_screen = this; return true;}/*! \reimp*/void QVNCScreen::disconnect(){ if (d_ptr->subscreen) { d_ptr->subscreen->disconnect(); } else {#ifndef QT_NO_QWS_MULTIPROCESS if (d_ptr->shm) d_ptr->shm->detach();#endif }}/*! \reimp*/bool QVNCScreen::initDevice(){ if (!d_ptr->subscreen && d == 4) { screencols = 16; int val = 0; for (int idx = 0; idx < 16; idx++, val += 17) { screenclut[idx] = qRgb(val, val, val); } } d_ptr->vncServer = new QVNCServer(this, displayId); d_ptr->vncServer->setRefreshRate(d_ptr->refreshRate); switch (depth()) {#ifdef QT_QWS_DEPTH_32 case 32: d_ptr->dirty = new QVNCDirtyMapOptimized<quint32>(this); break;#endif#ifdef QT_QWS_DEPTH_16 case 16: d_ptr->dirty = new QVNCDirtyMapOptimized<quint16>(this); break;#endif#ifdef QT_QWS_DEPTH_8 case 8: d_ptr->dirty = new QVNCDirtyMapOptimized<quint8>(this); break;#endif default: qWarning("QVNCScreen::initDevice: No support for screen depth %d", depth()); d_ptr->dirty = 0; return false; } if (d_ptr->subscreen) return d_ptr->subscreen->initDevice();#ifndef QT_NO_QWS_CURSOR qt_screencursor = new QVNCCursor(this);#endif#ifdef QT_BUILD_INTERNAL if (qgetenv("QT_VNC_NO_DISABLEPAINTING").toInt() <= 0)#endif // No need to do painting while there's no clients attached QWSServer::instance()->enablePainting(false); return true;}/*! \reimp*/void QVNCScreen::shutdownDevice(){ delete d_ptr->vncServer; if (d_ptr->subscreen) { d_ptr->subscreen->shutdownDevice(); } else {#ifndef QT_NO_QWS_MULTIPROCESS if (d_ptr->shm) d_ptr->shm->destroy();#endif } delete d_ptr->dirty;}/*! \reimp*/void QVNCScreen::setMode(int w, int h, int d){ if (d_ptr->subscreen) { d_ptr->subscreen->setMode(w, h, d); } else { QScreen::dw = QScreen::w = w; QScreen::dh = QScreen::h = h; QScreen::d = d; } d_ptr->configure(); setDirty(region().boundingRect());}/*! \reimp*/bool QVNCScreen::supportsDepth(int depth) const{ if (d_ptr->subscreen) return d_ptr->subscreen->supportsDepth(depth); return false;}/*! \reimp*/void QVNCScreen::save(){ if (d_ptr->subscreen) d_ptr->subscreen->save(); QScreen::save();}/*! \reimp*/void QVNCScreen::restore(){ if (d_ptr->subscreen) d_ptr->subscreen->restore(); QScreen::restore();}/*! \reimp*/void QVNCScreen::blank(bool on){ if (d_ptr->subscreen) d_ptr->subscreen->blank(on);}/*! \reimp*/bool QVNCScreen::onCard(const unsigned char *ptr) const{ if (d_ptr->subscreen) return d_ptr->subscreen->onCard(ptr); return false;}/*! \reimp*/bool QVNCScreen::onCard(const unsigned char *ptr, ulong &offset) const{ if (d_ptr->subscreen) return d_ptr->subscreen->onCard(ptr, offset); return false;}/*! \reimp*/bool QVNCScreen::isInterlaced() const{ if (d_ptr->subscreen) return d_ptr->subscreen->isInterlaced(); return false;}/*! \reimp*/int QVNCScreen::memoryNeeded(const QString &str){ if (d_ptr->subscreen) return d_ptr->subscreen->memoryNeeded(str); else return QScreen::memoryNeeded(str);}/*! \reimp*/int QVNCScreen::sharedRamSize(void *ptr){ if (d_ptr->subscreen) return d_ptr->subscreen->sharedRamSize(ptr); else return QScreen::sharedRamSize(ptr);}/*! \reimp*/void QVNCScreen::haltUpdates(){ if (d_ptr->subscreen) d_ptr->subscreen->haltUpdates(); else QScreen::haltUpdates();}/*! \reimp*/void QVNCScreen::resumeUpdates(){ if (d_ptr->subscreen) d_ptr->subscreen->resumeUpdates();}/*! \reimp*/void QVNCScreen::exposeRegion(QRegion r, int changing){ if (d_ptr->subscreen) { d_ptr->subscreen->exposeRegion(r, changing); const QVector<QRect> rects = (region() & r).rects(); for (int i = 0; i < rects.size(); ++i) setDirty(rects.at(i)); } else { QScreen::exposeRegion(r, changing); }}/*! \reimp*/void QVNCScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion){ if (d_ptr->subscreen) d_ptr->subscreen->blit(img, topLeft, region); else QScreen::blit(img, topLeft, region);}/*! \reimp*/void QVNCScreen::solidFill(const QColor &color, const QRegion ®ion){ if (d_ptr->subscreen) d_ptr->subscreen->solidFill(color, region); else QScreen::solidFill(color, region);}/*! \reimp*/QWSWindowSurface* QVNCScreen::createSurface(QWidget *widget) const{ if (d_ptr->subscreen) return d_ptr->subscreen->createSurface(widget);#ifndef QT_NO_PAINTONSCREEN // XXX: will not work together with transparent windows until full // compositioning is implemented if (d_ptr->doOnScreenSurface) { if (widget->d_func()->isOpaque() && (depth() == 16 || depth() == 32)) return new QWSOnScreenSurface(widget); }#endif return QScreen::createSurface(widget);}/*! \reimp*/QList<QScreen*> QVNCScreen::subScreens() const{ if (d_ptr->subscreen) return d_ptr->subscreen->subScreens(); return QScreen::subScreens();}/*! \reimp*/QRegion QVNCScreen::region() const{ if (d_ptr->subscreen) return d_ptr->subscreen->region(); return QScreen::region();}#endif // QT_NO_QWS_VNC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -