void QWaylandEventThread::waylandDisplayConnect()
{
    m_display = wl_display_connect(NULL);
    if (m_display == NULL) {
        qErrnoWarning(errno, "Failed to create display");
        ::exit(1);
    }
    m_displayLock->unlock();

    m_fileDescriptor = wl_display_get_fd(m_display);

    m_readNotifier = new QSocketNotifier(m_fileDescriptor, QSocketNotifier::Read, this);
    connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readWaylandEvents()));
}
Exemple #2
0
bool GatoSocket::transmit(const QByteArray &pkt)
{
	int written = ::write(fd, pkt.constData(), pkt.size());
	if (written < 0) {
		qErrnoWarning("Could not write to L2 socket");
		close();
		return false;
	} else if (written < pkt.size()) {
		qWarning("Could not write full packet to L2 socket");
		return true;
	} else {
		return true;
	}
}
void KeePassXmlStreamReader::parseFile(){
    while(xmlReader.readNextStartElement()){
        if(xmlReader.name() == "database"){
            qDebug("Found database tag. Assuming KeePassX file format. Continuing with KeePassX specific parsing...");
            parseDatabase();
        }else if(xmlReader.name() == "PwmanXmlList"){
            qDebug("Found PwmanXmlList tag. Assuming pwman3 file format. Continuing with pwman3 specific parsing...");
            parsePwmanList();
        }
        else{
            qErrnoWarning("No Database found!");
        }
    }
    qDebug("Leaving parseFile...");
}
// Create a dummy GL context (see QOpenGLTemporaryContext).
static inline HGLRC createDummyGLContext(HDC dc)
{
    if (!dc)
        return 0;
    PIXELFORMATDESCRIPTOR pixelFormDescriptor;
    initPixelFormatDescriptor(&pixelFormDescriptor);
    pixelFormDescriptor.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_GENERIC_FORMAT;
    pixelFormDescriptor.iPixelType = PFD_TYPE_RGBA;
    const int pixelFormat = ChoosePixelFormat(dc, &pixelFormDescriptor);
    if (!pixelFormat) {
        qErrnoWarning("%s: ChoosePixelFormat failed.", __FUNCTION__);
        return 0;
    }
    if (!SetPixelFormat(dc, pixelFormat, &pixelFormDescriptor)) {
        qErrnoWarning("%s: SetPixelFormat failed.", __FUNCTION__);
        return 0;
    }
    HGLRC rc = wglCreateContext(dc);
    if (!rc) {
        qErrnoWarning("%s: wglCreateContext failed.", __FUNCTION__);
        return 0;
    }
    return rc;
}
Exemple #5
0
void Nodeftp::add_ftp_user(QString email)
{
    qDebug() << "Nodeftp::add_user : "******"/ftp/" + directory;
        if (!QDir(userdirectory).exists()) QDir().mkdir(userdirectory);


        CFtpServer::CUserEntry *pUser = FtpServer->AddUser( email.toAscii(), token.toAscii(), userdirectory.toAscii() );
        if( pUser )
        {
            printf( "-User successfully created ! :)\r\n" );
            pUser->SetMaxNumberOfClient( 5 ); // 0 Unlimited

    /*        pUser->SetPrivileges( CFtpServer::READFILE | CFtpServer::WRITEFILE |
                CFtpServer::LIST | CFtpServer::DELETEFILE | CFtpServer::CREATEDIR |
                CFtpServer::DELETEDIR );
    */

            pUser->SetPrivileges(CFtpServer::WRITEFILE | CFtpServer::READFILE | CFtpServer::LIST);

    #ifdef CFTPSERVER_ENABLE_EXTRACMD // See "CFtpServer/config.h". not defined by default
            pUser->SetExtraCommand( CFtpServer::ExtraCmd_EXEC );
            // Security Warning ! Only here for example.
            // the last command allow the user to call the 'system()' C function!
    #endif

        }
        else qErrnoWarning( "-Unable to create pUser" );
    }
    else qErrnoWarning( "-Failed to create user" );
}
/*!
    Executes the service.

    When the exec() function is called, it will parse the \l
    {serviceSpecificArguments} {service specific arguments} passed in
    \c argv, perform the required actions, and exit.

    If none of the arguments is recognized as service specific, exec()
    will first call the createApplication() function, then executeApplication() and
    finally the start() function. In the end, exec()
    returns while the service continues in its own process waiting for
    commands from the service controller.

    \sa QtServiceController
*/
int QtService::exec(const std::map<QString, QVariant> &args)
{

    d_ptr->args = args;
    int ec = d_ptr->run();
    if (ec == -1)
        qErrnoWarning("The service could not be executed.");
    return ec;

#if defined(Q_OS_UNIX)
    if (::getenv("QtService_RUN")) {
        // Means we're the detached, real service process.
        int ec = d_ptr->run(true, d_ptr->args);
        if (ec == -1)
            qErrnoWarning("The service failed to run.");
        return ec;
    }
#endif
    if (!d_ptr->start()) {
        fprintf(stderr, "The service %s could not start\n Run with argument -h for help.\n", serviceName().toLatin1().constData());
        return -4;
    }
    return 0;
}
Exemple #7
0
QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
{
    RECT rect = {0,0,0,0};
    style &= ~(WS_OVERLAPPED); // Not permitted, see docs.
    if (!AdjustWindowRectEx(&rect, style, FALSE, exStyle))
        qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__);
    const QMargins result(qAbs(rect.left), qAbs(rect.top),
                          qAbs(rect.right), qAbs(rect.bottom));
    if (QWindowsContext::verboseWindows)
        qDebug().nospace() << __FUNCTION__ << " style= 0x"
                 << QString::number(style, 16)
                 << " exStyle=0x" << QString::number(exStyle, 16) << ' ' << rect << ' ' << result;

    return result;
}
void EventDispatcherEPollPrivate::wake_up_handler()
{
    eventfd_t value;
    int res;
    do {
        res = eventfd_read(m_event_fd, &value);
    } while (Q_UNLIKELY(-1 == res && EINTR == errno));

    if (Q_UNLIKELY(-1 == res)) {
        qErrnoWarning("%s: eventfd_read() failed", Q_FUNC_INFO);
    }

    if (Q_UNLIKELY(!m_wakeups.testAndSetRelease(1, 0))) {
        qCritical("%s: internal error, testAndSetRelease(1, 0) failed!", Q_FUNC_INFO);
    }
}
QFontEngineWin::~QFontEngineWin()
{
    if (designAdvances)
        free(designAdvances);

    if (widthCache)
        free(widthCache);

    // make sure we aren't by accident still selected
    SelectObject(shared_dc(), (HFONT)GetStockObject(SYSTEM_FONT));

    if (!stockFont) {
        if (!DeleteObject(hfont))
            qErrnoWarning("QFontEngineWin: failed to delete non-stock font...");
    }
}
/*! \internal

  This function is called whenever there is activity on the mouse device.
  By default, it reads up to 10 mouse move packets and calls mouseChanged()
  for each of them.
*/
void QQnxMouseHandler::socketActivated()
{
    // _mouse_packet is a QNX structure. devi-hid is nice enough to translate
    // the raw byte data from mouse devices into generic format for us.
    _mouse_packet packet;

    int iteration = 0;

    // read mouse events in batches of 10. Since we're getting quite a lot
    // of mouse events, it's better to do them in batches than to return to the
    // event loop every time.
    do {
        int bytesRead = QT_READ(mouseFD, &packet, sizeof(packet));
        if (bytesRead == -1) {
            // EAGAIN means that there are no more mouse events to read
            if (errno != EAGAIN)
                qErrnoWarning(errno, "QQnxMouseHandler: Unable to read from socket");
            return;
        }

        // bytes read should always be equal to the size of a packet.
        Q_ASSERT(bytesRead == sizeof(packet));

        // translate the coordinates from the QNX data structure to Qt coordinates
        // note the swapped y axis
        QPoint pos = mousePos;
        pos += QPoint(packet.dx, -packet.dy);

        // QNX only tells us relative mouse movements, not absolute ones, so limit the
        // cursor position manually to the screen
        limitToScreen(pos);

        // translate the QNX mouse button bitmask to Qt buttons
        int buttons = Qt::NoButton;

        if (packet.hdr.buttons & _POINTER_BUTTON_LEFT)
            buttons |= Qt::LeftButton;
        if (packet.hdr.buttons & _POINTER_BUTTON_MIDDLE)
            buttons |= Qt::MidButton;
        if (packet.hdr.buttons & _POINTER_BUTTON_RIGHT)
            buttons |= Qt::RightButton;

        // call mouseChanged() - this does all the magic to actually move the on-screen
        // mouse cursor.
        mouseChanged(pos, buttons, 0);
    } while (++iteration < 11);
}
QString EnvVarHelper::getOwnLibPath(QString ownPath) {
    QString ownLibPath;

#ifdef LINUX_DESKTOP
    if (QFile::exists(ownPath + "/../lib")) {
        ownLibPath = ownPath + "/../lib";
    } else if (QFile::exists(ownPath + "/lib")) {
        ownLibPath = ownPath + "/lib";
    } else if (QFile::exists("lib")) {
        ownLibPath = "lib";
    } else {
        qErrnoWarning("Couldn't find own lib directory.");
    }
#endif

    return ownLibPath;
}
Exemple #12
0
void QClipboard::setMimeData(QMimeData *src, Mode mode)
{
    if (mode != Clipboard)
        return;
    QClipboardData *d = clipboardData();

    if (!(d->iData && d->iData->mimeData() == src)) {
        d->releaseIData();
        d->iData = new QOleDataObject(src);
    }

    if (OleSetClipboard(d->iData) != S_OK) {
        d->releaseIData();
        qErrnoWarning("QClipboard::setMimeData: Failed to set data on clipboard");
        return;
    }
}
QPixmap kMancalaRenderer::renderPixmap(QString name, const QSize size) {
    QPixmap p(size);
    p.fill(Qt::transparent);

    QPainter painter(&p);

    if ( !elementExists(name)) {
      qErrnoWarning("Element doesn't exist");
      return QPixmap();
    }

	qDebug() << "rendering Pixmap" << name;
    render(&painter, name, QRectF(0,0,size.width(), size.height()));
    painter.end();
	qDebug() << "rendering Pixmap done" << name;

    return p;
}
void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness)
{
#ifndef Q_OS_WINCE
    qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness;
    if (QWindowsContext::shcoredll.isValid()) {
        const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness);
        if (FAILED(hr))
            qWarning() << "SetProcessDpiAwareness failed:" << QWindowsContext::comErrorString(hr);
    } else {
        if (dpiAwareness != QtWindows::ProcessDpiUnaware && QWindowsContext::user32dll.setProcessDPIAware) {
            if (!QWindowsContext::user32dll.setProcessDPIAware())
                qErrnoWarning("SetProcessDPIAware() failed");
        }
    }
#else // !Q_OS_WINCE
    Q_UNUSED(dpiAwareness)
#endif
}
void QFontEngineQPF::remapFontData()
{
    off_t newFileSize = ::lseek(fd, 0, SEEK_END);
    if (newFileSize == (off_t)-1) {
#ifdef DEBUG_FONTENGINE
        perror("QFontEngineQPF::remapFontData: lseek failed");
#endif
        fontData = 0;
        return;
    }

#ifndef QT_NO_MREMAP
    fontData = static_cast<uchar *>(::mremap(const_cast<uchar *>(fontData), dataSize, newFileSize, MREMAP_MAYMOVE));
    if (!fontData || fontData == (const uchar *)MAP_FAILED) {
#  if defined(DEBUG_FONTENGINE)
        perror("QFontEngineQPF::remapFontData(): mremap failed");
#  endif
        fontData = 0;
    }

    if (!fontData)
#endif // QT_NO_MREMAP
    {
        int status = ::munmap((void *)fontData, dataSize);
        if (status != 0)
            qErrnoWarning(status, "QFontEngineQPF::remapFomrData: munmap failed!");

        fontData = (const uchar *)::mmap(0, newFileSize, PROT_READ | (renderingFontEngine ? PROT_WRITE : 0),
                                         MAP_SHARED, fd, 0);
        if (!fontData || fontData == (const uchar *)MAP_FAILED) {
#  if defined(DEBUG_FONTENGINE)
            perror("mmap failed");
#  endif
            fontData = 0;
            return;
        }
    }

    dataSize = newFileSize;
    glyphDataSize = newFileSize - glyphDataOffset;
#if defined(DEBUG_FONTENGINE)
    qDebug() << "remapped the font file to" << newFileSize << "bytes";
#endif
}
Exemple #16
0
void QClipboard::clear(Mode mode)
{
    if (mode != Clipboard) return;

    QClipboardData *d = clipboardData();

    d->releaseIData();

    if (OleSetClipboard(0) != S_OK) {
        qErrnoWarning("QClipboard::clear: Failed to clear data on clipboard");
        return;
    }
#if defined(Q_OS_WINCE)
    // As WinCE does not support notifications we send the signal here
    // We will get no event when the clipboard changes outside...
    emit dataChanged();
    emit changed(Clipboard);
#endif
}
Exemple #17
0
void Nodeftp::ftp_init()
{
    // If you only want to listen on the TCP Loopback interface,
    // replace 'INNADDR_ANY' by 'inet_addr("127.0.0.1")'.
    if( FtpServer->StartListening( INADDR_ANY, m_port ) ) {
        qDebug( "FTP : Server is listening !" );

        if( FtpServer->StartAccepting() ) {

            qDebug( "FTP : Server successfuly started !" );
            populate();

        } else
            qDebug( "FTP : Unable to accept incoming connections" );

    } else
        qErrnoWarning( "FTP : Unable to listen" );

}
void QWindowsClipboard::registerViewer()
{
    m_clipboardViewer = QWindowsContext::instance()->
        createDummyWindow(QStringLiteral("Qt5ClipboardView"), L"Qt5ClipboardView",
                          qClipboardViewerWndProc, WS_OVERLAPPED);

    // Try format listener API (Vista onwards) first.
    if (QWindowsContext::user32dll.addClipboardFormatListener && QWindowsContext::user32dll.removeClipboardFormatListener) {
        m_formatListenerRegistered = QWindowsContext::user32dll.addClipboardFormatListener(m_clipboardViewer);
        if (!m_formatListenerRegistered)
            qErrnoWarning("AddClipboardFormatListener() failed.");
    }

    if (!m_formatListenerRegistered)
        m_nextClipboardViewer = SetClipboardViewer(m_clipboardViewer);

    qCDebug(lcQpaMime) << __FUNCTION__ << "m_clipboardViewer:" << m_clipboardViewer
        << "format listener:" << m_formatListenerRegistered
        << "next:" << m_nextClipboardViewer;
}
Exemple #19
0
bool NDArray::setShape(QList<int> shp)
{
    int M = shp.size();
    int tot = 1;
    for (int i=0; i<M; ++i)
        tot *= shp[i];
    if (tot != m_size) {
        qErrnoWarning("NDArray::setShape() - new shape must be same number of elements.");
        return false;
    }

    // Update shape
    m_shapelst = shp;
    m_ndim = M;

    int *shpd = m_shape.data();
    for (int i=0; i<M; ++i)
        shpd[i] = shp[i];

    return true;
}
bool EventDispatcherEPollPrivate::disableSocketNotifiers(bool disable)
{
	epoll_event e;

	SocketNotifierHash::ConstIterator it = this->m_notifiers.constBegin();
	while (it != this->m_notifiers.constEnd()) {
		QSocketNotifier* notifier = it.key();
		HandleData* info          = it.value();
		int fd                    = static_cast<int>(notifier->socket());

		e.events  = disable ? 0 : info->sni.events;
		e.data.fd = fd;
		int res = epoll_ctl(this->m_epoll_fd, EPOLL_CTL_MOD, fd, &e);
		if (Q_UNLIKELY(res != 0)) {
			qErrnoWarning("%s: epoll_ctl() failed", Q_FUNC_INFO);
		}

		++it;
	}

	return true;
}
bool QFontEngineDirectWrite::canRender(const QChar *string, int len)
{
    QVarLengthArray<UINT32> codePoints(len);
    int actualLength = 0;
    for (int i=0; i<len; ++i, actualLength++)
        codePoints[actualLength] = getChar(string, i, len);

    QVarLengthArray<UINT16> glyphIndices(actualLength);
    HRESULT hr = m_directWriteFontFace->GetGlyphIndices(codePoints.data(), actualLength,
                                                        glyphIndices.data());
    if (FAILED(hr)) {
        qErrnoWarning(hr, "QFontEngineDirectWrite::canRender: GetGlyphIndices failed");
        return false;
    } else {
        for (int i=0; i<glyphIndices.size(); ++i) {
            if (glyphIndices.at(i) == 0)
                return false;
        }

        return true;
    }
}
Exemple #22
0
QWindowsFontEngine::~QWindowsFontEngine()
{
    if (designAdvances)
        free(designAdvances);

    if (widthCache)
        free(widthCache);

    // make sure we aren't by accident still selected
    SelectObject(m_fontEngineData->hdc, QWindowsFontDatabase::systemFont());

    if (!DeleteObject(hfont))
        qErrnoWarning("%s: QFontEngineWin: failed to delete font...", __FUNCTION__);
    qCDebug(lcQpaFonts) << __FUNCTION__ << _name;

    if (!uniqueFamilyName.isEmpty()) {
        if (QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration()) {
            QPlatformFontDatabase *pfdb = pi->fontDatabase();
            static_cast<QWindowsFontDatabase *>(pfdb)->derefUniqueFont(uniqueFamilyName);
        }
    }
}
QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont, LOGFONT lf)
{
    //qDebug("regular windows font engine created: font='%s', size=%d", name, lf.lfHeight);

    _name = name;

    cmap = 0;
    hfont = _hfont;
    logfont = lf;
    HDC hdc = shared_dc();
    SelectObject(hdc, hfont);
    this->stockFont = stockFont;
    fontDef.pixelSize = -lf.lfHeight;

    lbearing = SHRT_MIN;
    rbearing = SHRT_MIN;
    synthesized_flags = -1;
    lineWidth = -1;
    x_height = -1;

    BOOL res = GetTextMetrics(hdc, &tm);
    fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
    if (!res) {
        qErrnoWarning("QFontEngineWin: GetTextMetrics failed");
        ZeroMemory(&tm, sizeof(TEXTMETRIC));
    }

    cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000;
    getCMap();

    widthCache = 0;
    widthCacheSize = 0;
    designAdvances = 0;
    designAdvancesSize = 0;

    if (!resolvedGetCharWidthI)
        resolveGetCharWidthI();
}
Exemple #24
0
// Create some pre-defined Windows controls by class name
static WId createInternalWindow(const QString &name)
{
    WId result = 0;
#ifdef Q_OS_WIN
    if (name == QLatin1String("BUTTON") || name == QLatin1String("COMBOBOX")
        || name == QLatin1String("EDIT") || name.startsWith(QLatin1String("RICHEDIT"))) {
        const HWND hwnd =
            CreateWindowEx(0, reinterpret_cast<const wchar_t *>(name.utf16()),
                          L"NativeCtrl", WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                          0, 0, GetModuleHandle(NULL), NULL);
        if (hwnd) {
            SetWindowText(hwnd, L"Demo");
            result = WId(hwnd);
        } else {
            qErrnoWarning("Cannot create window \"%s\"", qPrintable(name));
        }
    }
#else // Q_OS_WIN
    Q_UNUSED(name)
#endif
    return result;
}
Exemple #25
0
void QClipboard::setMimeData(QMimeData *src, Mode mode)
{
    if (mode != Clipboard)
        return;
    QClipboardData *d = clipboardData();

    if (!(d->iData && d->iData->mimeData() == src)) {
        d->releaseIData();
        d->iData = new QOleDataObject(src);
    }

    if (OleSetClipboard(d->iData) != S_OK) {
        d->releaseIData();
        qErrnoWarning("QClipboard::setMimeData: Failed to set data on clipboard");
        return;
    }
#if defined(Q_OS_WINCE)
    // As WinCE does not support notifications we send the signal here
    // We will get no event when the clipboard changes outside...
    emit dataChanged();
    emit changed(Clipboard);
#endif
}
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
{
    QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);

    // ### Caching?
    for(int i=0; i<glyphs->numGlyphs; i++)
        glyphIndices[i] = UINT16(glyphs->glyphs[i]);

    QVarLengthArray<DWRITE_GLYPH_METRICS> glyphMetrics(glyphIndices.size());
    HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(glyphIndices.data(),
                                                              glyphIndices.size(),
                                                              glyphMetrics.data());
    if (SUCCEEDED(hr)) {
        for (int i = 0; i < glyphs->numGlyphs; ++i)
            glyphs->advances[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth);
        if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
            for (int i = 0; i < glyphs->numGlyphs; ++i)
                glyphs->advances[i] = glyphs->advances[i].round();
        }
    } else {
        qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__);
    }
}
glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g)
{
    if (m_directWriteFontFace == 0)
        return glyph_metrics_t();

    UINT16 glyphIndex = g;

    DWRITE_GLYPH_METRICS glyphMetrics;
    HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetrics);
    if (SUCCEEDED(hr)) {
        QFixed advanceWidth = DESIGN_TO_LOGICAL(glyphMetrics.advanceWidth);
        QFixed leftSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.leftSideBearing);
        QFixed rightSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.rightSideBearing);
        QFixed advanceHeight = DESIGN_TO_LOGICAL(glyphMetrics.advanceHeight);
        QFixed verticalOriginY = DESIGN_TO_LOGICAL(glyphMetrics.verticalOriginY);
        QFixed topSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.topSideBearing);
        QFixed bottomSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.bottomSideBearing);

        if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
            advanceWidth = advanceWidth.round();
            advanceHeight = advanceHeight.round();
        }

        QFixed width = advanceWidth - leftSideBearing - rightSideBearing;
        QFixed height = advanceHeight - topSideBearing - bottomSideBearing;
        return glyph_metrics_t(leftSideBearing,
                               -verticalOriginY + topSideBearing,
                               width,
                               height,
                               advanceWidth,
                               advanceHeight);
    } else {
        qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__);
    }

    return glyph_metrics_t();
}
bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
                                                 int *nglyphs, QFontEngine::ShaperFlags flags) const
{
    if (*nglyphs < len) {
        *nglyphs = len;
        return false;
    }

    QVarLengthArray<UINT32> codePoints(len);
    int actualLength = 0;
    if (flags & QFontEngine::RightToLeft) {
        for (int i = 0; i < len; ++i)
            codePoints[actualLength++] = QChar::mirroredChar(getChar(str, i, len));
    } else {
        for (int i = 0; i < len; ++i)
            codePoints[actualLength++] = getChar(str, i, len);
    }

    QVarLengthArray<UINT16> glyphIndices(actualLength);
    HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength,
                                                         glyphIndices.data());
    if (FAILED(hr)) {
        qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__);
        return false;
    }

    for (int i = 0; i < actualLength; ++i)
        glyphs->glyphs[i] = glyphIndices.at(i);

    *nglyphs = actualLength;
    glyphs->numGlyphs = actualLength;

    if (!(flags & GlyphIndicesOnly))
        recalcAdvances(glyphs, 0);

    return true;
}
Exemple #29
0
QWaylandDisplay::QWaylandDisplay(void)
    : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0)
{
    display = this;
    qRegisterMetaType<uint32_t>("uint32_t");

    mDisplay = wl_display_connect(NULL);
    if (mDisplay == NULL) {
        qErrnoWarning(errno, "Failed to create display");
        qFatal("No wayland connection available.");
    }

    wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this);

#ifdef QT_WAYLAND_GL_SUPPORT
    mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
#endif

#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
    mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
#endif

    blockingReadEvents();

#ifdef QT_WAYLAND_GL_SUPPORT
    mEglIntegration->initialize();
#endif

    connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));

    mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);

    mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this);
    connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents()));

    waitForScreens();
}
void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
{
    qCDebug(lcQpaMime) << __FUNCTION__ <<  mode << *mimeData;
    if (mode != QClipboard::Clipboard)
        return;

    const bool newData = !m_data || m_data->mimeData() != mimeData;
    if (newData) {
        releaseIData();
        if (mimeData)
            m_data = new QWindowsOleDataObject(mimeData);
    }

    const HRESULT src = OleSetClipboard(m_data);
    if (src != S_OK) {
        QString mimeDataFormats = mimeData ?
            mimeData->formats().join(QStringLiteral(", ")) : QString(QStringLiteral("NULL"));
        qErrnoWarning("OleSetClipboard: Failed to set mime data (%s) on clipboard: %s",
                      qPrintable(mimeDataFormats),
                      QWindowsContext::comErrorString(src).constData());
        releaseIData();
        return;
    }
}