[comp.windows.x] tiling problems

ezer@mips.COM (Gulbin Ezer) (02/12/89)

  I am having problems with tiling a rectangular area with an 8 bit pixmap.
It seems there is a bug in the server that causes an incorrect rectangle
fill operation. The following program is supposed to fill an area on the
right hand side of the window with a constant pixmap tile (I hope). However,
the operation puts the tile on top of the window border and on the parent
window (the operation is not clipped right). This bug is window position
dependent. If the window is located at x=100, I get the incorrect behavior.
For x=101, everything is OK. Is there a fix to this bug? I would rather
get a fix for this bug rather than program code to do this operation in
a different way since I am using similar constructs extensively.

  I am using X11R3 on a SUN4/110 with a cgfour0 (sunos SYS4/3.2).
Here is the code:

----------------------------------------------------------------------------
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/X10.h>

Pixmap tilepm;
Window win;
Display *dpy;

unsigned long  xTvm;
XSetWindowAttributes xTat;
GC _GC;

#define VRoot DefaultRootWindow(dpy)

main(argc, argv)
int argc; char *argv[];
{
    int x, y, w, h;
    int pw = 1;

    x = 100; y = 100;
    w = 200; h = 100;

    /* OpenDisplay */
    dpy = XOpenDisplay("");
    if(dpy == NULL) exit(1);

    /* Create default GC */
    _GC = XCreateGC(dpy, VRoot, 0, 0);

    /* Create tile pixmap, and fill it with color 2 */
    /* Note that this is a 1x1 pixmap of depth 8 */
    tilepm=XCreatePixmap(dpy,VRoot,1,1,8);
    XSetForeground(dpy,_GC,2);
    XFillRectangle(dpy,tilepm,_GC,0,0,1,1);

    /* Create window (border width = 3, border color = 0, back color = 1) */
    win = XCreateSimpleWindow(dpy, VRoot, x, y, w, h, 3, 0, 1);

    /* Change override redirect attribute */
    xTvm=CWOverrideRedirect;
    xTat.override_redirect=True;
    XChangeWindowAttributes(dpy,win,xTvm,&xTat);

    XMapWindow(dpy, win);

    /* Fill the right hand side of the window in tile mode */
    XSetTile(dpy,_GC,tilepm);
    XSetFillStyle(dpy,_GC,FillTiled);
    XSetTSOrigin(dpy,_GC,0,0);
    XFillRectangle(dpy,win,_GC,w-13,1,13,h-2);

    XFlush(dpy);
    sleep(10);
}
----------------------------------------------------------------------------

I would appreciate any comments. Thanks.
Sener Ilgen.


You can send me mail at this address.
-- 
Gulbin Ezer
{ames,prls,pyramid,decwrl}!mips!ezer  or  ezer@mips.com 
MIPS Computer Systems, 930 Arques, Sunnyvale, CA 94086, (408) 991-7727