[comp.windows.x] clip mask problems

laurie@sol.UUCP (Laurie Clow) (07/14/88)

I have a problem with the clip_mask of the graphics context.

I am trying to use a clip mask to draw a symbol onto the screen using a 
fill rectangle then erase the symbol by using the same clip mask on an
XCopyArea command.

I have a loop which notices ButtonPressed events. If there is already a
symbol on the window it copys over the symbol, it then draws the symbol onto 
the window at the event location.  

This works correctly the first time I try to draw the symbol but nothing is
drawn onto the window after that.  If I remove the code to initialize and
draw the pixmap used to copy over the symbol the symbols are drawn correctly.

This is the initialization code for the drawables and graphics contexts
   w_id = XCreateWindow( display, w_parent, 0, 0, w_width, w_height, 0, 8,
                         InputOutput, visual, 0, NULL);
   XSelectInput( display, w_id, ExposureMask | ButtonPressMask );
   mask = XCreatePixmap( display, w_id, w_width, w_height, 1 );
   back = XCreatePixmap( display, w_id, w_width, w_height, 8 );
   graphics->clip_gc = XCreateGC( display, graphics->w_id, 0, NULL );
   values.foreground = 1;
   values.background = 0;
   values.function = GXor;
   solid_gc = XCreateGC( display, mask, GCForeground|GCBackground|GCFunction, 
                         &values );
   values.function = GXclear;
   clear_gc = XCreateGC( display, mask, GCFunction, &values );
   XSetForeground( display, clip_gc, blue_pixel );
   XFillRectangle( display, back, clip_gc, 0, 0, w_width, w_height );

This is the code which is called at every button_pressed event
   if (count > 0)
   {
      XFillRectangle( display, mask, clear_gc, 0, 0, w_width, w_height );
      XCopyPlane( display, s_id, mask, solid_gc, 0, 0, s_width, s_height, 
                  last_x, last_y, 1 );
      XSetClipMask( display, clip_gc, mask );
      XCopyArea( display, back, w_id, clip_gc, 0, 0, w_width, w_height, 0, 0 );
   }
   count++;
   last_x = event->x;
   last_y = event->y;
   XFillRectangle( display, mask, clear_gc, 0, 0, w_width, w_height );
   XCopyPlane( display, s_id, mask, solid_gc, 0, 0, s_width, s_height, 
               event->x, event->y, 1 );
   XSetForeground( graphics, clip_gc, red_pixel );
   XSetClipMask( display, clip_gc, mask );
   XFillRectangle( display, w_id, clip_gc, 0, 0, w_width, w_height );
 
I am running on a sun4 using 4.2bsd and screen 1.

Thank you in advance.
Laurie Clow

UUCP:  {ucbvax!ucsd,seismo}!esosun!sol!laurie
ARPA:  esosun!sol!laurie@seismo.css.gov

laurie@sol.UUCP (Laurie Clow) (10/04/88)

I am using x11 r2 on a sun.  When I try to call XFillRectangle with a clip 
mask that is clear ( all bits set to 0 ) the entire rectangle is drawn 
rather than none of it.  Is there a fix for this or a way to tell if the 
clip mask is clear? 

Thank you for your time.

Laurie Clow

UUCP:  {ucbvax!ucsd,seismo}!esosun!sol!laurie (Lauren Clow) (619) 546-6409
ARPA:  esosun!sol!laurie@seismo.css.gov