I've observed a significant problem while using Xpdf 3.X. This patch tries to correct the problem. The patch is experimental, but it seems to work so far. The problem is that Xpdf 3.X doesn't see button presses at the right time. Because of this, copy-and-paste operations don't work correctly. Details: "copy" regions aren't highlighted until ButtonPress events are processed. However, those events sometimes aren't processed until the mouse has been moved all the way across the drawing area. There- fore, if you're trying to use copy-and-paste, you may need to cope with invisible regions. To solve the problem, I've added an event handler to the drawing area. The event handler simply repackages certain events and passes them on to Xpdf's original drawing-area callback routine. Note: I've observed the problem in conjunction with Lesstif 0.94.4, but I don't recall seeing it with OpenMotif. Therefore, I'm not sure if this is fundamentally a Lesstif or Xpdf problem. However, the patch seems to fix it, either way. Update: This version of the patch has been modified for use with Xpdf 3.04. --- xpdf-3.04.old/xpdf/XPDFCore.cc +++ xpdf-3.04/xpdf/XPDFCore.cc @@ -966,6 +966,17 @@ XtAddCallback(drawArea, XmNresizeCallback, &resizeCbk, (XtPointer)this); XtAddCallback(drawArea, XmNexposeCallback, &redrawCbk, (XtPointer)this); XtAddCallback(drawArea, XmNinputCallback, &inputCbk, (XtPointer)this); + + XtAddEventHandler + ( + drawArea , + KeyPressMask | ButtonPressMask | ButtonReleaseMask + | PointerMotionMask | PropertyChangeMask , + gFalse , + &drawAreaHandler , + (XtPointer) this + ); + resizeCbk(drawArea, this, NULL); // set up mouse motion translations @@ -987,6 +998,33 @@ core->scrollTo(data->value, core->scrollY); } +//-------------------------------------------------------------------- + +// BUG FIX: This event handler implements an experimental bug fix. The +// standard version of Xpdf 3.00pl3 doesn't see button presses at the +// right time, and so copy-and-paste operations don't work correctly. +// If this handler is added to the drawing area [using the appro- +// priate event masks], the problem goes away. + +// Note: I've observed the problem with Lesstif 0.94.4, but I don't +// recall seeing it with OpenMotif. Therefore, I'm not sure if this is +// fundamentally a Lesstif or Xpdf problem. However, the event handler +// seems to fix it, either way. + +void XPDFCore::drawAreaHandler +( + Widget widget, XtPointer ptr, XEvent *event, Boolean *propagate +) +{ + static XmDrawingAreaCallbackStruct x_data; + XPDFCore *core = (XPDFCore *) ptr; + + x_data.event = event; + inputCbk (widget, ptr, &x_data); +} + +//-------------------------------------------------------------------- + void XPDFCore::hScrollDragCbk(Widget widget, XtPointer ptr, XtPointer callData) { XPDFCore *core = (XPDFCore *)ptr; --- xpdf-3.04.old/xpdf/XPDFCore.h +++ xpdf-3.04/xpdf/XPDFCore.h @@ -161,6 +161,8 @@ void initWindow(); static void hScrollChangeCbk(Widget widget, XtPointer ptr, XtPointer callData); + static void drawAreaHandler (Widget widget, XtPointer ptr, + XEvent *event, Boolean *propagate); static void hScrollDragCbk(Widget widget, XtPointer ptr, XtPointer callData); static void vScrollChangeCbk(Widget widget, XtPointer ptr,