Hello, I finally went to C with Xlib. My testbench looks like this: module tb (); import "DPI" function void init_screen(); import "DPI" function void deinit_screen(); import "DPI" function void show_boxes(); initial begin #100 init_screen(); #100 show_boxes(); #100 show_boxes(); #100 show_boxes(); #1 $display( "we should see boxes"); #10000 deinit_screen(); end endmodule // tb and DPI function for show_boxes() : extern void show_boxes( void) { XFlushGC( disp, gc); while (1) { XNextEvent(disp, &e); /* draw or redraw the window */ if(e.type==Expose) { XSetForeground(disp, gc, yellow.pixel); XFillRectangle(disp, w, gc, 20, 20, 30, 30); XSetForeground(disp, gc, red.pixel); XFillRectangle(disp, w, gc, 50, 20, 30, 30); printf("boxes on screen\n"); break; } // Handle Windows Close Event if(e.type==ClientMessage) break; } } But when I call this func once no boxes are shown. If I run it twice or three times the boxes are shown but func stays in while() loop. It looks that XEvents are processed strangely. Any idea how to fix the code ?
↧