⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qapplication_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
void QWSDisplay::requestFocus(int winId, bool get){    QWSRequestFocusCommand cmd;    cmd.simpleData.windowid = winId;    cmd.simpleData.flag = get;    if (d->directServerConnection())        qwsServer->d_func()->request_focus(&cmd);    else        d->sendCommand(cmd);}void QWSDisplay::setIdentity(const QString &appName){    QWSIdentifyCommand cmd;#ifdef QT_NO_QWS_MULTIPROCESS    const int id = -1;#else    const int id = QWSDisplay::Data::clientLock ? QWSDisplay::Data::clientLock->id() : -1;#endif    cmd.setId(appName, id);    if (d->directServerConnection())        qwsServer->d_func()->set_identity(&cmd);    else        d->sendCommand(cmd);}void QWSDisplay::nameRegion(int winId, const QString& n, const QString &c){    QWSRegionNameCommand cmd;    cmd.simpleData.windowid = winId;    cmd.setName(n, c);    if (d->directServerConnection())        qwsServer->d_func()->name_region(&cmd);    else        d->sendCommand(cmd);}void QWSDisplay::requestRegion(int winId, const QString &surfaceKey,                               const QByteArray &surfaceData,                               const QRegion &region){    if (d->directServerConnection()) {        qwsServer->d_func()->request_region(winId, surfaceKey,                                            surfaceData, region);    } else {        QWSRegionCommand cmd;        cmd.setData(winId, surfaceKey, surfaceData, region);        d->sendSynchronousCommand(cmd);    }}void QWSDisplay::repaintRegion(int winId, int windowFlags, bool opaque, QRegion r){    if (d->directServerConnection()) {        qwsServer->d_func()->repaint_region(winId, windowFlags, opaque, r);    } else {        QVector<QRect> ra = r.rects();        /*          for (int i = 0; i < ra.size(); i++) {          QRect r(ra[i]);          qDebug("rect: %d %d %d %d", r.x(), r.y(), r.right(), r.bottom());          }        */        QWSRepaintRegionCommand cmd;    /* XXX QWSRegionCommand is padded out in a compiler dependent way.       Zeroed out to avoid valgrind reporting uninitialized memory usage.       */#ifdef QT_DEBUG        memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind#endif        cmd.simpleData.windowid = winId;        cmd.simpleData.windowFlags = windowFlags;        cmd.simpleData.opaque = opaque;        cmd.simpleData.nrectangles = ra.count();        cmd.setData(reinterpret_cast<const char *>(ra.constData()),                    ra.count() * sizeof(QRect), false);        d->sendSynchronousCommand(cmd);    }}void QWSDisplay::moveRegion(int winId, int dx, int dy){    QWSRegionMoveCommand cmd;    cmd.simpleData.windowid = winId;    cmd.simpleData.dx = dx;    cmd.simpleData.dy = dy;    if (d->directServerConnection()) {        qwsServer->d_func()->move_region(&cmd);    } else {        d->sendSynchronousCommand(cmd);    }//    d->offsetPendingExpose(winId, QPoint(cmd.simpleData.dx, cmd.simpleData.dy));}void QWSDisplay::destroyRegion(int winId){    QWSRegionDestroyCommand cmd;    cmd.simpleData.windowid = winId;    if (d->directServerConnection()) {        qwsServer->d_func()->destroy_region(&cmd);    } else {        d->sendCommand(cmd);    }}#ifndef QT_NO_QWS_INPUTMETHODSvoid QWSDisplay::sendIMUpdate(int type, int winId, int widgetid){    QWSIMUpdateCommand cmd;    cmd.simpleData.windowid = winId;    cmd.simpleData.widgetid = widgetid;    cmd.simpleData.type = type;      if (d->directServerConnection()) {        qwsServer->d_func()->im_update(&cmd);    } else {        d->sendCommand(cmd);    }}void QWSDisplay::sendIMResponse(int winId, int property, const QVariant &result){    QWSIMResponseCommand cmd;    cmd.simpleData.windowid = winId;    cmd.simpleData.property = property;    cmd.setResult(result);    if (d->directServerConnection()) {        qwsServer->d_func()->im_response(&cmd);    } else {        d->sendCommand(cmd);    }}void QWSDisplay::resetIM(){    sendIMUpdate(QWSInputMethod::Reset, -1, -1);}void QWSDisplay::sendIMMouseEvent(int index, bool isPress){    QWSIMMouseCommand cmd;    cmd.simpleData.index = index;    cmd.simpleData.state = isPress ? QWSServer::MousePress : QWSServer::MouseRelease;    if (d->directServerConnection()) {        qwsServer->d_func()->send_im_mouse(&cmd);    } else {        d->sendCommand(cmd);    }}#endifint QWSDisplay::takeId(){    return d->takeId();}bool QWSDisplay::initLock(const QString &filename, bool create){    if (!lock) {        lock = new QLock(filename, 'd', create);        if (!lock->isValid()) {            delete lock;            lock = 0;            return false;        }    }    return true;}void QWSDisplay::setSelectionOwner(int winId, const QTime &time){    QWSSetSelectionOwnerCommand cmd;    cmd.simpleData.windowid = winId;    cmd.simpleData.hour = time.hour();    cmd.simpleData.minute = time.minute();    cmd.simpleData.sec = time.second();    cmd.simpleData.ms = time.msec();    d->sendCommand(cmd);}void QWSDisplay::convertSelection(int winId, int selectionProperty, const QString &mimeTypes){#ifdef QT_NO_QWS_PROPERTIES    Q_UNUSED(mimeTypes);#else    // ### we need the atom/property thingy like in X here    addProperty(winId, QT_QWS_PROPERTY_CONVERTSELECTION);    setProperty(winId, QT_QWS_PROPERTY_CONVERTSELECTION,                 int(QWSPropertyManager::PropReplace), mimeTypes.toLatin1());#endif    QWSConvertSelectionCommand cmd;    cmd.simpleData.requestor = winId;    cmd.simpleData.selection = selectionProperty;    cmd.simpleData.mimeTypes = QT_QWS_PROPERTY_CONVERTSELECTION;    d->sendCommand(cmd);}void QWSDisplay::defineCursor(int id, const QBitmap &curs, const QBitmap &mask,                            int hotX, int hotY){    QImage cursImg = curs.toImage();    QImage maskImg = mask.toImage();    QWSDefineCursorCommand cmd;    cmd.simpleData.width = curs.width();    cmd.simpleData.height = curs.height();    cmd.simpleData.hotX = hotX;    cmd.simpleData.hotY = hotY;    cmd.simpleData.id = id;    // must copy each scanline since there might be gaps between them    const int height = curs.height();    const int width = curs.width();    const int dst_bpl = (width + 7) / 8;    int dataLen = dst_bpl * height;    uchar *data = new uchar[dataLen*2];    uchar *dst = data;    int src_bpl = cursImg.bytesPerLine();    const uchar *cursSrc = cursImg.bits();    for (int i = 0; i < height; ++i) {        memcpy(dst, cursSrc + i*src_bpl, dst_bpl);        dst += dst_bpl;    }    src_bpl = maskImg.bytesPerLine();    const uchar *maskSrc = maskImg.bits();    for (int i = 0; i < height; ++i) {        memcpy(dst, maskSrc + i*src_bpl, dst_bpl);        dst += dst_bpl;    }    cmd.setData(reinterpret_cast<char*>(data), dataLen*2);    delete [] data;    d->sendCommand(cmd);}void QWSDisplay::destroyCursor(int id){    QWSDefineCursorCommand cmd;    cmd.simpleData.width = 0;    cmd.simpleData.height = 0;    cmd.simpleData.hotX = 0;    cmd.simpleData.hotY = 0;    cmd.simpleData.id = id;    cmd.setData(0, 0);    d->sendCommand(cmd);}#ifndef QT_NO_SOUNDvoid QWSDisplay::playSoundFile(const QString& f){    QWSPlaySoundCommand cmd;    cmd.setFileName(f);    d->sendCommand(cmd);}#endif#ifndef QT_NO_COPvoid QWSDisplay::registerChannel(const QString& channel){    QWSQCopRegisterChannelCommand reg;    reg.setChannel(channel);    qt_fbdpy->d->sendCommand(reg);}void QWSDisplay::sendMessage(const QString &channel, const QString &msg,                   const QByteArray &data){    QWSQCopSendCommand com;    com.setMessage(channel, msg, data);    qt_fbdpy->d->sendCommand(com);}void QWSDisplay::flushCommands(){    qt_fbdpy->d->flushCommands();}/*  caller deletes result*/QWSQCopMessageEvent* QWSDisplay::waitForQCopResponse(){    qt_fbdpy->d->waitForQCopResponse();    QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(qt_fbdpy->d->dequeue());    Q_ASSERT(e->type == QWSEvent::QCopMessage);    return e;}#endifvoid QWSDisplay::sendFontCommand(int type, const QByteArray &fontName){    QWSFontCommand cmd;    cmd.simpleData.type = type;    cmd.setFontName(fontName);    d->sendCommand(cmd);}void QWSDisplay::setWindowCaption(QWidget *w, const QString &c){    if (w->isWindow()) {        nameRegion(w->internalWinId(), w->objectName(), c);        static_cast<QETWidget *>(w)->repaintDecoration(qApp->desktop()->rect(), true);    }}void QWSDisplay::selectCursor(QWidget *w, unsigned int cursId){    if (cursId != qt_last_cursor)    {        QWidget *top = w->window();        qt_last_cursor = cursId;        QWSSelectCursorCommand cmd;        cmd.simpleData.windowid = top->internalWinId();        cmd.simpleData.id = cursId;        d->sendCommand(cmd);        d->flush();    }}void QWSDisplay::setCursorPosition(int x, int y){    QWSPositionCursorCommand cmd;    cmd.simpleData.newX = x;    cmd.simpleData.newY = y;    d->sendCommand(cmd);    d->flush();}void QWSDisplay::grabMouse(QWidget *w, bool grab){    QWidget *top = w->window();    QWSGrabMouseCommand cmd;#ifdef QT_DEBUG    memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind#endif    cmd.simpleData.windowid = top->winId();    cmd.simpleData.grab = grab;    d->sendCommand(cmd);    d->flush();}void QWSDisplay::grabKeyboard(QWidget *w, bool grab){    QWidget *top = w->window();    QWSGrabKeyboardCommand cmd;#ifdef QT_DEBUG    memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind#endif    cmd.simpleData.windowid = top->winId();    cmd.simpleData.grab = grab;    d->sendCommand(cmd);    d->flush();}QList<QWSWindowInfo> QWSDisplay::windowList(){    QList<QWSWindowInfo> ret;    if(d->directServerConnection()) {        QList<QWSInternalWindowInfo*> * qin=QWSServer::windowList();        for (int i = 0; i < qin->count(); ++i) {            QWSInternalWindowInfo * qwi = qin->at(i);            QWSWindowInfo tmp;            tmp.winid = qwi->winid;            tmp.clientid = qwi->clientid;            tmp.name = QString(qwi->name);            ret.append(tmp);        }        qDeleteAll(*qin);        delete qin;    }    return ret;}int QWSDisplay::windowAt(const QPoint &p){    //### currently only implemented for the server process    int ret = 0;    if(d->directServerConnection()) {        QWSWindow *win = qwsServer->windowAt(p);        if (win)            return win->winId();    }    return ret;}void QWSDisplay::setRawMouseEventFilter(void (*filter)(QWSMouseEvent *)){    if (qt_fbdpy)        qt_fbdpy->d->setMouseFilter(filter);}#ifdef QT_QWS_DYNAMIC_TRANSFORMATION#ifdef QT_QWS_TRANSFORMEDextern void qws_setScreenTransformation(int);extern void qws_mapPixmaps(bool from);#endifvoid QWSDisplay::setTransformation(int t){#ifdef QT_QWS_TRANSFORMED    QApplicationPrivate *ap = QApplicationPrivate::instance();    const QRect maxWindowRect = ap->maxWindowRect(qt_screen);    bool isFullScreen = maxWindowRect == QRect(0, 0, qt_screen->width(), qt_screen->height());    QPixmapCache::clear();    QFontCache::instance->clear();    qws_mapPixmaps(true);    qws_setScreenTransformation(t);    qws_mapPixmaps(false);    if (qt_fbdpy->d_func()->directServerConnection()) {        qwsServer->d_func()->resetEngine();        qwsServer->d_func()->refresh();    }    QSize olds = qApp->desktop()->size();    qApp->desktop()->resize(qt_screen->width(), qt_screen->height());    // ## why post the resize event?    qApp->postEvent(qApp->desktop(), new QResizeEvent(qApp->desktop()->size(), olds));    emit QApplication::desktop()->resized(0);    QWidgetList  list = QApplication::topLevelWidgets();    for (int i = list.size()-1; i >= 0; --i) {        QWidget *w = (QWidget*)list[i];        if ((w->windowType() == Qt::Desktop)) {            //nothing        } else if (w->testAttribute(Qt::WA_WState_FullScreen)) {            w->resize(qt_screen->width(), qt_screen->height());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -