Bug on Elsa Gloria graphic card.

From: Yves BLUSSEAU <yves.blusseau_at_sncf.fr>
Date: Wed, 03 Nov 1999 10:17:18 +0100

I have found a big bug running X applications on my PWS 433 and X1000
(4.0F) with an Elsa Gloria graphic card.

Sometime when I scroll big windows the drawing is made outside the
window borders (all over the screen).
Could someone try the following program (on a platform with an Elsa
Gloria) and send me feeback by mail (yves.blusseau_at_sncf.fr).
Launch the program with this parameters:

bug -N 256 -S 128 -B 0 -C 255

and scroll smoothly.

Compile the program with this options:

cc -o bug bug.c -lX11 -lXt -lXm

The Program (bug.c):

/********************************************************************************/
/* */
/* bug.c */
/* Programme de test des cartes graphiques */
/* */
/* developpe le 13/10/1999 par D.Deman (SII Sannois) */
/* pour l'agence AIGF-MC de la S.N.C.F */
/* */
/********************************************************************************/

/*
 * Ce programme affiche dans une fenetre deroulante un texte
 * et dans une autre un rectangle gradue
 */

/*
 * Options de la ligne de Commande :
 *
 * -N nombre nombre de cartouche
 * -S pixels taille des cartouches en pixels
 * -B pixels taille de la bordure
 *
 * -F fonte fonte du texte de la zone de texte
 *
 * -C couleur couleur du trace
 *
 * -h liste des options
 */

#include <X11/X.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/BulletinB.h>
#include <Xm/Separator.h>
#include <Xm/Scale.h>
#include <Xm/RowColumn.h>
#include <Xm/BulletinB.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/List.h>
#include <Xm/ScrolledW.h>
#include <Xm/DrawingA.h>
#include <stdio.h>

Widget top;
Widget scw;
Widget con;
Widget txt;
Widget drw;
Widget lbl;

GC gc;
XGCValues gcv;
unsigned long gcm;
Display *disp;
Window win;
XFontStruct *fnt;
XmFontList flst;

int larg;
int size;
int bord;
long coul;

int haut;

char *str;
XmString xlbl;
char lab[1024];

int Erreur = 0;

int (*err_hnd)(Display *,XErrorEvent *);

int my_err_hnd(Display *d,XErrorEvent *err)
{
        Erreur = 1;
        return err->error_code;
}

void TxtExposeHnd()
{
        XmTextPosition p;


        int i;
        int j;
        int l;
        int k;
        int n;

        /* nombre de caracteres */
        i = (larg * size + 2 * bord - 10 /* pour la marge */ ) / fnt->max_bounds.width;
        /* while ( (i+1) * fnt->max_bounds.width > larg * size + 2 * bord - 10) i--; */

        /* libelle du label */
        memset(lab,'\0',1023);
        sprintf(lab,
                "Dessin : %d x %d + 2 x %d = %d --- Texte : %d x %d = %d",
                                        larg,size,bord,
                                        larg*size+2*bord,
                                        i,fnt->max_bounds.width,
                                        i*fnt->max_bounds.width );
        xlbl = XmStringCreateSimple( lab );

        /* nombre de lignes */
        j=1;
        l=0;
        while ( j < i )
        {
                j*=10;
                l++;
        }


        /* hauteur de la zone texte */
        haut = (l+1) * (fnt->ascent + fnt->descent) + 10 /* pour la marge */ ;

        /* contenu de la zone texte */
        str = (char *) calloc ( (i+2) * l + 1 ,sizeof(char) );
        memset(str,' ',(i+1)*l);

        for (j=1;j<l;j++)
                str[ j * (i+1) -1 ] = '\n';
        str[ (i+1)*l + 1 ] = '\0';

        for (j=0;j<i;j++)
        {

                str[j]='0' + (j+1)%10;
                k=1;
                if ( (j+1)%10 == 0)
                for ( n=1 ; n<l ; n ++)
                {
                        k *= 10;
                        str[ n * (i+1) + j ] = '0' + ((j+1)/k)%10 ;
                }
        }
}

void DrwExposeHnd (Widget w, void *tag, XEvent *event)
{
        int i;
        char *str;


        str = (char *) calloc( 1024 , sizeof(char) );
        /* dessin dans la zone */

        win = XtWindow(drw);
        XSetForeground( disp , gc , coul );
        XDrawRectangle( disp , win , gc , bord ,10,larg * size - 1,220);

        /* numerotation */

        for (i=0;i<larg;i++)
        {
                sprintf(str,"%d",i+1);

                XDrawString( disp , win , gc, bord + i*size + size / 2, 115 , str , strlen(str) );
                XDrawRectangle( disp , win , gc, bord + i*size , 100 , size-1 , 20 );
        }



}

void usage()
{
        printf("usage : \n");
        printf(" -h cette page\n");
        printf(" -B bord taille du bord en pixel\n");
        printf(" -F fonte nom cryptique de la fonte pour le texte\n");
        printf(" -N nombre nombre de cartouche dans le dessin\n");
        printf(" -S pixel nombre de pixel d'un cartouche\n");
        printf(" -C couleur couleur des textes et dessins\n");
        exit(0);
}

void main(int argc,char **argv)
{
        Arg args[20];
        int n;
        Font f;

        top = XtInitialize( argv[0], "Bug01", NULL, 0, &argc, argv);

        disp = XtDisplay(top);

        fnt = NULL;




        larg = 0;
        size = 0;
        bord = 10 ;
        coul = 1;

        argc--;
        while ( argc )
        {
                argv++;
                if ( argv[0][0] != '-' )
                {
                        usage();
                        exit(0);
                }

                switch ( argv[0][1] )
                {
                        case 'h' :
                                usage();
                                break;
                        case 'F' :
                                if ( argv[0][2] == 0 )
                                {
                                        argc--;
                                        argv++;
                                }
                                else
                                {
                                        argv[0]++;
                                        argv[0]++;
                                }

                                if (argc == 0)
                                {
                                        usage();
                                }

                                /* chargement de la fonte */
                                XSynchronize(disp,True);
                                XFlush(disp);
                                XSync(disp,False);
                                err_hnd = XSetErrorHandler( my_err_hnd );
                                f = XLoadFont(disp,argv[0]);
                                if ( f != 0)
                                {
                                        fnt = XQueryFont( disp , f );
                                        if ( Erreur )
                                        {
                                                Erreur = 0;
                                                fnt = NULL;
                                                printf("Fonte %s non trouvee\n",argv[0]);
                                        }
                                        else
                                                flst = XmFontListCreate(fnt,
                                                                XmSTRING_DEFAULT_CHARSET);
                                }
                                XSetErrorHandler( err_hnd );
                                break;

                        case 'B' :
                                if ( argv[0][2] == 0 )
                                {
                                        argc--;
                                        argv++;
                                }
                                else
                                {
                                        argv[0]++;
                                        argv[0]++;
                                }

                                if (argc == 0)
                                {
                                        usage();
                                }
                                bord = atoi(argv[0]);
                                break;
                        case 'N' :
                                if ( argv[0][2] == 0 )
                                {
                                        argc--;
                                        argv++;
                                }
                                else
                                {
                                        argv[0]++;
                                        argv[0]++;
                                }

                                if (argc == 0)
                                {
                                        usage();
                                }
                                larg = atoi(argv[0]);
                                break;
                        case 'S' :
                                if ( argv[0][2] == 0 )
                                {
                                        argc--;
                                        argv++;
                                }
                                else
                                {
                                        argv[0]++;
                                        argv[0]++;
                                }

                                if (argc == 0)
                                {
                                        usage();
                                }
                                size = atoi(argv[0]);
                                break;
                        case 'C' :
                                if ( argv[0][2] == 0 )
                                {
                                        argc--;
                                        argv++;
                                }
                                else
                                {
                                        argv[0]++;
                                        argv[0]++;
                                }

                                if (argc == 0)
                                {
                                        usage();
                                }
                                coul = atoi(argv[0]);
                                break;

                }

                argc--;

        }


        if (larg < 1 ) larg = 10;
        if (size < 64 ) size = 64;

        if (fnt == NULL )
        {
                fnt = XLoadQueryFont( disp ,
                "-adobe-courier-bold-r-normal--20-140-100-100-m-110-iso8859-1" );

                flst = XmFontListCreate(fnt,XmSTRING_DEFAULT_CHARSET);
        }

        TxtExposeHnd();

        /* creation d'une fenetre avec barres deroulante */

        n = 0;
        XtSetArg(args[n],XmNheight,340+haut);n++;
        XtSetArg(args[n],XmNwidth,500);n++;
        XtSetArg(args[n],XmNscrollingPolicy,XmSTATIC);n++;

        scw = XmCreateScrolledWindow(top,"scw",args,n);
        XtManageChild(scw);

        /* creation d'un bulletin board dans la fenetre */
        con = XtCreateManagedWidget("cont", xmBulletinBoardWidgetClass, scw , NULL, 0);


        /* creation d'une zone de dessin */
        n = 0;
        XtSetArg(args[n],XmNheight,240);n++;
        XtSetArg(args[n],XmNwidth,size * larg + 2*bord );n++;
        XtSetArg(args[n],XmNx,10);n++;
        XtSetArg(args[n],XmNy,10);n++;
        XtSetArg(args[n],XmNbackground,0);n++;
        XtSetArg(args[n],XmNforeground,coul);n++;
        drw = XmCreateDrawingArea(con,"drw",args,n);
        XtManageChild(drw);

        /* creation d'un Libelle */

        n=0;
        XtSetArg(args[n],XmNheight,30);n++;
        XtSetArg(args[n],XmNx,10);n++;
        XtSetArg(args[n],XmNy,260);n++;
        XtSetArg(args[n],XmNlabelString,xlbl);n++;
        lbl = XmCreateLabel(con,"lbl",args,n);
        XtManageChild(lbl);

        /* creation d'une zone de texte */

        n = 0;
        XtSetArg(args[n],XmNheight,haut);n++;
        XtSetArg(args[n],XmNwidth,size * larg + 2 * bord);n++;
        XtSetArg(args[n],XmNx,10);n++;
        XtSetArg(args[n],XmNy,300);n++;
        XtSetArg(args[n],XmNbackground,0);n++;
        XtSetArg(args[n],XmNforeground,coul);n++;
        XtSetArg(args[n],XmNeditMode,XmMULTI_LINE_EDIT);n++;
        XtSetArg(args[n],XmNfontList,flst);n++;
        XtSetArg(args[n],XmNeditable,False);n++;
        XtSetArg(args[n],XmNmarginWidth,5);n++;
        XtSetArg(args[n],XmNmarginHeight,5);n++;
        txt = (Widget) XmCreateText(con,"txt",args,n);
        XtManageChild(txt);

        XmTextSetString(txt,str);

        gcm = GCForeground ;
        gc = XtGetGC( drw , gcm , &gcv );




        XtRealizeWidget(top);
        XtRealizeWidget(scw);
        XtRealizeWidget(con);

        XtRealizeWidget(drw);
        XtRealizeWidget(txt);
        XtRealizeWidget(lbl);



        XtAddEventHandler(drw, ExposureMask, True,(XtEventHandler)DrwExposeHnd , NULL);

        XtMainLoop();
}

CUT HERE

--
                                \\\|///
                               \\  ~ ~  //
                                (  _at_ _at_  )
*-----------------------------oOOo-(_)-oOOo----------------------------*
| Yves BLUSSEAU  | E-Mail:    blusseau_at_pharmacie.unicaen.fr            |
|                | Home Page: http://www.pharmacie.unicaen.fr/blusseau |
|                | ICQ:       7761321                                  |
|                | PGP Key:   send me an E-Mail with SEND PGP KEYS     |
|                |            as Subject                               |
|----------------------------------------------------------------------|
| For automated information on various subjects, send an e-mail to my  |
|        E-Mail address with SEND HELP on the Subject line.            |
*-------------------------------------Oooo.----------------------------*
                           .oooO      (   )
                           (   )       ) /
                            \ (       (_/
                             \_)
Received on Wed Nov 03 1999 - 09:19:42 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT