Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!sol.UUCP!laurie From: laurie@sol.UUCP (Laurie Clow) Newsgroups: comp.windows.x Subject: clip mask problems Message-ID: <8807131730.AA09745@ws08.sag.uucp> Date: 13 Jul 88 17:30:32 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: Science Applications International Corporation Lines: 57 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