Beispiel #1
0
int InitGAL (void)
{
    int i;
    int w, h, depth;
    char engine [LEN_ENGINE_NAME + 1];
    char mode [LEN_MODE + 1];

    if (GetMgEtcValue ("system", "gal_engine", engine, LEN_ENGINE_NAME) < 0 )
        return ERR_CONFIG_FILE;
    
    if (GAL_VideoInit (engine, 0)) {
        GAL_VideoQuit ();
        fprintf (stderr, "NEWGAL: Does not find matched engine: %s.\n", engine);
        return ERR_NO_MATCH;
    }

    if (GetMgEtcValue (engine, "defaultmode", mode, LEN_MODE) < 0)
        return ERR_CONFIG_FILE;

    w = atoi (mode);
    h = atoi (strchr (mode, 'x') + 1);
    depth = atoi (strrchr (mode, '-') + 1);

    if (!(__gal_screen = GAL_SetVideoMode (w, h, depth, GAL_HWPALETTE))) {
        GAL_VideoQuit ();
        fprintf (stderr, "NEWGAL: Set video mode failure.\n");
        return ERR_GFX_ENGINE;
    }

#ifdef _LITE_VERSION
    if (w != __gal_screen->w || h != __gal_screen->h) {
        fprintf (stderr, "The resolution specified in MiniGUI.cfg is not the same as "
                         "the actual resolution: %dx%d.\n" 
                         "This may confuse the clients. Please change it.\n", 
                         __gal_screen->w, __gal_screen->h);
        GAL_VideoQuit ();
        return ERR_GFX_ENGINE;
    }
#endif

    for (i = 0; i < 17; i++) {
        SysPixelIndex [i] = GAL_MapRGB (__gal_screen->format, 
                        SysPixelColor [i].r, SysPixelColor [i].g, SysPixelColor [i].b);
    }

    return 0;
}
static BOOL LoadCursorRes (void)
{
    int number;
    int i;
    PCURSOR tempcsr;
    char *temp;
    char szValue [12];

    __mg_csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT, &__mg_csrimgpitch);

    if (GetMgEtcValue (CURSORSECTION, "cursornumber", szValue, 10) < 0)
        goto error;

    number = atoi (szValue);
    if (number < 0) goto error;
    number = number < (MAX_SYSCURSORINDEX + 1) ? number : (MAX_SYSCURSORINDEX + 1);

    // realloc for shared resource
    mgSharedRes = realloc (mgSharedRes, mgSizeRes + __mg_csrimgsize +
                    number * (sizeof (HCURSOR) + sizeof (CURSOR) + 2*__mg_csrimgsize));
    if (mgSharedRes == NULL) {
        perror ("realloc shared memory for system cursor");
        return FALSE;
    }

    // set cursor number
    ((PG_RES)mgSharedRes)->csrnum    = number;
    // set cursor data offset
    ((PG_RES)mgSharedRes)->svdbitsoffset = mgSizeRes;
    mgSizeRes += __mg_csrimgsize;
    ((PG_RES)mgSharedRes)->csroffset = mgSizeRes;

    // pointer to begin of cursor struct, 
    // and reserve a space for handles for system cursors.
    temp = (char*)mgSharedRes + mgSizeRes + sizeof (PCURSOR) * number;

    for (i = 0; i < number; i++) {
        if ( !(tempcsr = sysres_load_system_cursor (i)) )
            goto error;

        memcpy (temp, tempcsr, sizeof(CURSOR));        
        temp += sizeof(CURSOR);
        memcpy (temp, tempcsr->AndBits, __mg_csrimgsize);
        temp += __mg_csrimgsize; 
        memcpy (temp, tempcsr->XorBits, __mg_csrimgsize);
        temp += __mg_csrimgsize; 
        free (tempcsr->AndBits);
        free (tempcsr->XorBits);
        free (tempcsr);
    }

    mgSizeRes += (sizeof (HCURSOR) + sizeof(CURSOR) + 2 * __mg_csrimgsize) * number;
    return TRUE;

error:
    return FALSE;
}
Beispiel #3
0
static void GetTimeout (void)
{
    char szValue [11];
    int mytimeoutusec, myrepeatusec;

    timeoutusec = DEF_USEC_TIMEOUT;
    repeatusec = DEF_REPEAT_TIME;

    if (GetMgEtcValue (EVENTPARA, EVENTPARA_REPEATUSEC, szValue, 10) < 0)
        return;
    myrepeatusec = atoi(szValue);

    if( GetMgEtcValue (EVENTPARA, EVENTPARA_TIMEOUTUSEC, szValue, 10) < 0 )
        return;
    mytimeoutusec = atoi(szValue);

    if (myrepeatusec >= 0 && mytimeoutusec > 0) {
        timeoutusec = mytimeoutusec;
        repeatusec = myrepeatusec;
    }
}
Beispiel #4
0
static void GetDblclickTime(void)
{
    char szValue[11];
    int ms;

    dblclicktime = DEF_MSEC_DBLCLICK / 10;

    if( GetMgEtcValue (MOUSEPARA, MOUSEPARA_DBLCLICKTIME, szValue, 10) < 0 )
        return;

    ms = atoi(szValue);

    if (ms > 0 && ms < 1000) {
        dblclicktime = ms / 10;
    }
}
Beispiel #5
0
/***************************Bitmap Support***************************/
static BOOL LoadBitmapRes (void)
{
    int i, nBmpNr, size;
    char *temp;
    BITMAP bmp;
    char szValue [12];

    if (GetMgEtcValue ("bitmapinfo", "bitmapnumber", szValue, 10) < 0)
        return FALSE;

    nBmpNr = atoi(szValue);
    if (nBmpNr <= 0) return FALSE;
    nBmpNr = nBmpNr < SYSBMP_ITEM_NUMBER ? nBmpNr : SYSBMP_ITEM_NUMBER;

    ((PG_RES)mgSharedRes)->bmpnum    = nBmpNr;
    ((PG_RES)mgSharedRes)->bmpoffset = mgSizeRes;

    for (i = 0; i < nBmpNr; i++) {
        sprintf (szValue, "bitmap%d", i);
        if (!LoadSystemBitmap (&bmp, szValue))
            return FALSE;

#ifdef _USE_NEWGAL
        size = bmp.bmHeight * bmp.bmPitch;
#else
        size = bmp.bmHeight * bmp.bmWidth * BYTESPERPHYPIXEL;
#endif
        if ((mgSharedRes = realloc (mgSharedRes, mgSizeRes + size + sizeof (BITMAP))) == NULL) {
            UnloadBitmap (&bmp);
            perror ("realloc shared memory for system bitmap");
            return FALSE;
        }

        temp= (char*)mgSharedRes + mgSizeRes;
        memcpy (temp, &bmp, sizeof(BITMAP));
        temp += sizeof (BITMAP);
        memcpy (temp, bmp.bmBits, size);

        mgSizeRes += size;
        mgSizeRes += sizeof (BITMAP);

        UnloadBitmap (&bmp);
    }

    return TRUE;
}
Beispiel #6
0
int mg_InitIAL (void)
{
    int  i;
#ifndef __NOUNIX__
    char* env_value;
#endif
    char engine [LEN_ENGINE_NAME + 1];
    char mdev [MAX_PATH + 1];
    char mtype[LEN_MTYPE_NAME + 1];

    if (NR_INPUTS == 0)
        return ERR_NO_ENGINE;

#ifndef __NOUNIX__
    if ((env_value = getenv ("MG_IAL_ENGINE"))) {
        strncpy (engine, env_value, LEN_ENGINE_NAME);
        engine [LEN_ENGINE_NAME] = '\0';
    }
    else
#endif
#ifndef _MG_MINIMALGDI
    if (GetMgEtcValue ("system", "ial_engine", engine, LEN_ENGINE_NAME) < 0)
        return ERR_CONFIG_FILE;
#else /* _MG_MINIMALGDI */
#   ifdef _MGGAL_PCXVFB
    strcpy(engine, "pc_xvfb");
#   else
    strcpy(engine, "dummy");
#   endif
#endif /* _MG_MINIMALGDI */

#ifndef __NOUNIX__
    if ((env_value = getenv ("MG_MDEV"))) {
        strncpy (mdev, env_value, MAX_PATH);
        mdev [MAX_PATH] = '\0';
    }
    else
#endif
    if (GetMgEtcValue ("system", "mdev", mdev, MAX_PATH) < 0)
        return ERR_CONFIG_FILE;

#ifndef __NOUNIX__
    if ((env_value = getenv ("MG_MTYPE"))) {
        strncpy (mtype, env_value, LEN_MTYPE_NAME);
        mtype [LEN_MTYPE_NAME] = '\0';
    }
    else
#endif
    if (GetMgEtcValue ("system", "mtype", mtype, LEN_MTYPE_NAME) < 0)
        return ERR_CONFIG_FILE;

    fprintf (stderr, "IAL: Look find the request engine: %d.\n",  NR_INPUTS);
    for (i = 0; i < NR_INPUTS; i++) {
        fprintf (stderr, "IAL: Look find the request engine: %s.\n", inputs[i].id);
        if (strncmp (engine, inputs[i].id, strlen(inputs[i].id)) == 0) {
	  fprintf (stderr, "IAL: Look find the request engine: %s.\n", inputs[i].id);
            __mg_cur_input = inputs + i;
            break;
        }
    }
   
    if (__mg_cur_input == NULL) {
      fprintf (stderr, "IAL: Does not find the request engine: %s. %s/%d\n", engine, __FUNCTION__,__LINE__);
        if (NR_INPUTS) {
            __mg_cur_input = inputs;
            fprintf (stderr, "IAL: Use the first engine: %s\n", __mg_cur_input->id);
        }
        else
            return ERR_NO_MATCH;
    }

    strcpy (__mg_cur_input->mdev, mdev);

    if (!IAL_InitInput (__mg_cur_input, mdev, mtype)) {
        fprintf (stderr, "IAL: Init IAL engine failure.\n");
        return ERR_INPUT_ENGINE;
    }

#ifdef _DEBUG
    fprintf (stderr, "IAL: Use %s engine.\n", __mg_cur_input->id);
#endif

    return 0;
}
Beispiel #7
0
static BOOL LoadIconRes (void)
{
    int i, nIconNr;
    size_t size_bits16, size_bits32;
    PICON picon1,picon2;
    char* temp;
    char szValue [12];

    size_bits16 = BYTESPERPHYPIXEL * 16 * 16;
    size_bits32 = BYTESPERPHYPIXEL * 32 * 32;

    if (GetMgEtcValue ("iconinfo", "iconnumber", szValue, 10) < 0 )
        return FALSE;
    nIconNr = atoi(szValue);
    if (nIconNr <= 0) return FALSE;
    nIconNr = nIconNr < SYSICO_ITEM_NUMBER ? nIconNr : SYSICO_ITEM_NUMBER;

    //realloc for shared resource
    mgSharedRes = realloc (mgSharedRes, 
            mgSizeRes + nIconNr * (sizeof(ICON) + size_bits16 + size_bits32) * 2);
    if (mgSharedRes == NULL) {
        perror ("realloc shared memory for system icon");
        return FALSE;
    }

    //set icon number
    ((PG_RES)mgSharedRes)->iconnum    = nIconNr;
    //set icon data offset
    ((PG_RES)mgSharedRes)->iconoffset = mgSizeRes;
    //point to begin of icon struct
    temp= (char*)mgSharedRes + mgSizeRes;

    for (i = 0; i < nIconNr; i++) {
        sprintf (szValue, "icon%d", i);
        picon1 = (PICON)LoadSystemIcon (szValue, 0);
        picon2 = (PICON)LoadSystemIcon (szValue, 1);

        if (picon1 == 0 || picon2 == 0)
            return FALSE;

        memcpy (temp, picon1, sizeof(ICON));
        temp += sizeof(ICON);
        memcpy (temp, picon1->AndBits, size_bits32);
        temp += size_bits32;
        memcpy (temp, picon1->XorBits, size_bits32);
        temp += size_bits32;

        memcpy (temp, picon2, sizeof(ICON));
        temp += sizeof(ICON);
        memcpy (temp, picon2->AndBits, size_bits16);
        temp += size_bits16;
        memcpy (temp, picon2->XorBits, size_bits16);
        temp += size_bits16;

        DestroyIcon ((HICON)picon1);
        DestroyIcon ((HICON)picon2);
    }

    //set mgSizeRes to new
    mgSizeRes += (sizeof(ICON) + size_bits32 + size_bits16) * nIconNr * 2;
    return TRUE;
}