From 39e9a67b05d4558c065aedd2ebbe6eb11d0b88de Mon Sep 17 00:00:00 2001 From: Markus Steinborn Date: Thu, 1 Mar 2012 18:07:40 +0100 Subject: Correct XtNthumbProc usage This ugly piece of magic was copied from libXaw, and now scrollbars will work slightly less incorrectly than they did before. Found at http://gitorious.org/xaw3d/xaw3d/commit/4ec68aebffbdc406139f880f92b6c18b835af6d4 Signed-off-by: Jeremy Huddleston --- src/Scrollbar.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Scrollbar.c b/src/Scrollbar.c index 5667327..69c2d54 100644 --- a/src/Scrollbar.c +++ b/src/Scrollbar.c @@ -1054,7 +1054,10 @@ static void NotifyThumb (Widget w, XEvent *event, String *params, Cardinal *num_params) { register ScrollbarWidget sbw = (ScrollbarWidget) w; - float top = sbw->scrollbar.top; + union { + XtPointer xtp; + float xtf; + } xtpf; #ifndef XAW_ARROW_SCROLLBARS if (sbw->scrollbar.direction == 0) return; /* if no StartScroll */ @@ -1065,6 +1068,8 @@ NotifyThumb (Widget w, XEvent *event, String *params, Cardinal *num_params) /* thumbProc is not pretty, but is necessary for backwards compatibility on those architectures for which it work{s,ed}; the intent is to pass a (truncated) float by value. */ + xtpf.xtf = sbw->scrollbar.top; + /* #ifdef XAW_ARROW_SCROLLBARS */ /* This corrects for rounding errors: If the thumb is moved to the end of the scrollable area sometimes the last line/column is not displayed. @@ -1083,10 +1088,11 @@ NotifyThumb (Widget w, XEvent *event, String *params, Cardinal *num_params) /* Removed the dependancy on scrollbar arrows. Xterm as distributed in X11R6.6 by The XFree86 Project wants this correction, with or without the arrows. */ - top += 0.0001; + xtpf.xtf += 0.0001; /* #endif */ - XtCallCallbacks (w, XtNthumbProc, *(XtPointer*)&top); - XtCallCallbacks (w, XtNjumpProc, (XtPointer)&top); + + XtCallCallbacks (w, XtNthumbProc, xtpf.xtp); + XtCallCallbacks (w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top); } -- cgit v1.2.3