X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=a475c588edeb020459f1106e64c22d691228392c;hb=fbefb9f0b24c20920d7ac2ddf8d2503de9365821;hp=70ab43195f8a6ee72d4a5885d853bbc94424d3db;hpb=faa0fea4cf9cc9de2d73add4695af3ed06517787;p=xboard.git diff --git a/xoptions.c b/xoptions.c index 70ab431..a475c58 100644 --- a/xoptions.c +++ b/xoptions.c @@ -541,7 +541,6 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) int j, button=10, f=1, sizing=0; Option *opt, *graph = (Option *) client_data; PointerCallback *userHandler = graph->target; - cairo_t *cr; if (!XtIsRealized(widget)) return; @@ -552,25 +551,30 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) XtSetArg(args[j], XtNwidth, &w); j++; XtSetArg(args[j], XtNheight, &h); j++; XtGetValues(widget, args, j); - sizing = ((w != graph->max || h != graph->value) && ((XExposeEvent*)event)->count >= 0); - graph->max = w; graph->value = h; + + if(w < graph->max || w > graph->max + 1 || h != graph->value) { // use width fudge of 1 pixel + if(((XExposeEvent*)event)->count >= 0) { // suppress sizing on expose for ordered redraw in response to sizing. + sizing = 1; + graph->max = w; graph->value = h; // note: old values are kept if we we don't exceed width fudge + } + } else w = graph->max; + if(sizing && ((XExposeEvent*)event)->count > 0) { graph->max = 0; return; } // don't bother if further exposure is pending during resize if(!graph->textValue || sizing) { // create surfaces of new size for display widget if(graph->textValue) cairo_surface_destroy((cairo_surface_t *)graph->textValue); graph->textValue = (char*) cairo_xlib_surface_create(xDisplay, XtWindow(widget), DefaultVisual(xDisplay, 0), w, h); } if(sizing) { // the memory buffer was already created in GenericPopup(), - // to give drawing routines opportunity to use it befor first expose event + // to give drawing routines opportunity to use it before first expose event // (which are only processed when main gets to the event loop, so after all init!) // so only change when size is no longer good if(graph->choice) cairo_surface_destroy((cairo_surface_t *) graph->choice); graph->choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h); + break; } - cr = cairo_create((cairo_surface_t *) graph->textValue); - cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0); - cairo_rectangle(cr, ((XExposeEvent*)event)->x, ((XExposeEvent*)event)->y, ((XExposeEvent*)event)->width, ((XExposeEvent*)event)->height); - cairo_fill(cr); - cairo_destroy(cr); + w = ((XExposeEvent*)event)->width; + if(((XExposeEvent*)event)->x + w > graph->max) w--; // cut off fudge pixel + if(w) ExposeRedraw(graph, ((XExposeEvent*)event)->x, ((XExposeEvent*)event)->y, w, ((XExposeEvent*)event)->height); return; case MotionNotify: f = 0; @@ -599,10 +603,9 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) } void -DrawExpose (Option *opt, int x, int y, int w, int h) +GraphExpose (Option *opt, int x, int y, int w, int h) { XExposeEvent e; - opt = &mainOptions[W_BOARD]; if(!opt->handle) return; e.x = x; e.y = y; e.width = w; e.height = h; e.count = -1; e.type = Expose; // count = -1: kludge to suppress sizing GraphEventProc(opt->handle, (caddr_t) opt, (XEvent *) &e); // fake expose event