/**
 * Creates a product-maker and starts it in a new thread.
 *
 * @retval 0    Success.
 * @retval 1    Usage failure. \c nplStart() called.
 * @retval 2    O/S failure. \c nplStart() called.
 */
static int spawnProductMaker(
    const pthread_attr_t* const attr,           /**< [in] Thread-creation
                                                  *  attributes */
    Fifo* const                 fifo,           /**< [in] Pointer to FIFO from
                                                  *  which to get data */
    LdmProductQueue* const      productQueue,   /**< [in] LDM product-queue into
                                                  *  which to put data-products
                                                  *  */
    ProductMaker** const        productMaker,   /**< [out] Pointer to pointer to
                                                  *  returned product-maker */
    pthread_t* const            thread)         /**< [out] Pointer to pointer
                                                  *  to created thread */
{
    ProductMaker*   pm;
    int             status = pmNew(fifo, productQueue, &pm);

    if (0 != status) {
        NPL_ADD0("Couldn't create new LDM product-maker");
        status = 1;
    }
    else {
        pthread_t   thrd;

        if (0 != (status = pthread_create(&thrd, attr, pmStart, pm))) {
            NPL_ERRNUM0(status, "Couldn't start product-maker thread");
            status = 1;
        }
        else {
            *productMaker = pm;
            *thread = thrd;
        }
    }

    return status;
}
Exemple #2
0
// static
HPOINTER QPixmap::toPmHPOINTER(const QIcon &icon, bool isPointer,
                               int hotX, int hotY, bool embedRealAlpha,
                               bool isMini)
{
    if (icon.isNull())
        return NULLHANDLE;

    // get the system icon size
    int w = WinQuerySysValue(HWND_DESKTOP, isPointer ? SV_CXPOINTER : SV_CXICON);
    int h = WinQuerySysValue(HWND_DESKTOP, isPointer ? SV_CYPOINTER : SV_CYICON);
    if (!isPointer && isMini) {
        w = w / 2;
        h = h / 2;
    }

    // obtain the closest (but never larger) icon size we have
    QSize size = icon.actualSize(QSize(w, h));

    QPixmap pm = icon.pixmap(size);
    if (pm.isNull())
        return NULLHANDLE;

    // if we got a smaller pixmap then center it inside the box matching the
    // system size instead of letting WinCreatePointerIndirect() scale (this
    // covers a usual case when we get 32/16 px pixmaps on a 120 DPI system
    // where the icon size is 40/20 px respectively): scaling such small images
    // looks really ugly.
    if (!pm.isNull() && (pm.width() < w || pm.height() < h)) {
        Q_ASSERT(pm.width() <= w && pm.height() <= h);
        QPixmap pmNew(w, h);
        pmNew.fill(Qt::transparent);
        QPainter painter(&pmNew);
        int dx = (w - pm.width()) / 2;
        int dy = (h - pm.height()) / 2;
        painter.drawPixmap(dx, dy, pm);
        pm = pmNew;
        hotX += dx;
        hotY += dy;
    }

    POINTERINFO info;
    info.fPointer = isPointer;
    info.xHotspot = hotX;
    info.yHotspot = pm.height() - hotY - 1;
    info.hbmColor = pm.toPmHBITMAP(&info.hbmPointer, embedRealAlpha);
    info.hbmMiniPointer = NULLHANDLE;
    info.hbmMiniColor = NULLHANDLE;

    HPOINTER hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &info);

    GpiDeleteBitmap(info.hbmPointer);
    GpiDeleteBitmap(info.hbmColor);

    return hIcon;
}
Exemple #3
0
static void *heartbeatDeamon(void *vptr)
/* Send out a beat every now and again to hub. */
{
struct paraMessage *pm;
while (alive)
    {
    sleep(MINUTE/4);
    findNow();
    pm = pmNew(0,0);
    pmSet(pm, "heartbeat");
    hubMessagePut(pm);
    }
return NULL;
}