aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-09-04 12:08:55 -0700
committerPaul Eggert2017-09-04 12:09:33 -0700
commitd4c3669f9dd7a1da013c8d9d3d285fc3b67de533 (patch)
tree4870126d6a4d6d65f73ccc703c408f2f5a56816d /src
parent514e147dd3233615e7a3e17d594d05ac1420bae5 (diff)
downloademacs-d4c3669f9dd7a1da013c8d9d3d285fc3b67de533.tar.gz
emacs-d4c3669f9dd7a1da013c8d9d3d285fc3b67de533.zip
Revert recent float→double Motif change
Problem reported by Martin Rudalics in: http://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00014.html * src/xterm.c (xm_scroll_callback, xaw_jump_callback) (x_set_toolkit_scroll_bar_thumb) (x_set_toolkit_horizontal_scroll_bar_thumb): Go back to using ‘float’ temporaries rather than ‘double’. Although quite possibly this masks an underlying bug, we lack time to look into that now.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/xterm.c b/src/xterm.c
index a7a52064a10..0b949330ebc 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5587,9 +5587,8 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
5587 5587
5588 if (horizontal) 5588 if (horizontal)
5589 { 5589 {
5590 double dXM_SB_MAX = XM_SB_MAX; 5590 portion = bar->whole * ((float)cs->value / XM_SB_MAX);
5591 portion = bar->whole * (cs->value / dXM_SB_MAX); 5591 whole = bar->whole * ((float)(XM_SB_MAX - slider_size) / XM_SB_MAX);
5592 whole = bar->whole * ((XM_SB_MAX - slider_size) / dXM_SB_MAX);
5593 portion = min (portion, whole); 5592 portion = min (portion, whole);
5594 part = scroll_bar_horizontal_handle; 5593 part = scroll_bar_horizontal_handle;
5595 } 5594 }
@@ -5726,8 +5725,8 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
5726{ 5725{
5727 struct scroll_bar *bar = client_data; 5726 struct scroll_bar *bar = client_data;
5728 float *top_addr = call_data; 5727 float *top_addr = call_data;
5729 double top = *top_addr; 5728 float top = *top_addr;
5730 double shown; 5729 float shown;
5731 int whole, portion, height, width; 5730 int whole, portion, height, width;
5732 enum scroll_bar_part part; 5731 enum scroll_bar_part part;
5733 bool horizontal = bar->horizontal; 5732 bool horizontal = bar->horizontal;
@@ -5741,8 +5740,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
5741 5740
5742 if (shown < 1) 5741 if (shown < 1)
5743 { 5742 {
5744 double dshown = shown; 5743 whole = bar->whole - (shown * bar->whole);
5745 whole = bar->whole - (dshown * bar->whole);
5746 portion = min (top * bar->whole, whole); 5744 portion = min (top * bar->whole, whole);
5747 } 5745 }
5748 else 5746 else
@@ -5763,7 +5761,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
5763 whole = 10000000; 5761 whole = 10000000;
5764 portion = shown < 1 ? top * whole : 0; 5762 portion = shown < 1 ? top * whole : 0;
5765 5763
5766 if (shown < 1 && (eabs (top + shown - 1) < 1.0 / height)) 5764 if (shown < 1 && (eabs (top + shown - 1) < 1.0f / height))
5767 /* Some derivatives of Xaw refuse to shrink the thumb when you reach 5765 /* Some derivatives of Xaw refuse to shrink the thumb when you reach
5768 the bottom, so we force the scrolling whenever we see that we're 5766 the bottom, so we force the scrolling whenever we see that we're
5769 too close to the bottom (in x_set_toolkit_scroll_bar_thumb 5767 too close to the bottom (in x_set_toolkit_scroll_bar_thumb
@@ -6306,8 +6304,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
6306{ 6304{
6307 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 6305 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
6308 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 6306 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
6309 double dwhole = whole; 6307 float top, shown;
6310 double top, shown;
6311 6308
6312 block_input (); 6309 block_input ();
6313 6310
@@ -6336,8 +6333,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
6336 top = 0, shown = 1; 6333 top = 0, shown = 1;
6337 else 6334 else
6338 { 6335 {
6339 top = position / dwhole; 6336 top = (float) position / whole;
6340 shown = portion / dwhole; 6337 shown = (float) portion / whole;
6341 } 6338 }
6342 6339
6343 if (bar->dragging == -1) 6340 if (bar->dragging == -1)
@@ -6361,14 +6358,13 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
6361 top = 0, shown = 1; 6358 top = 0, shown = 1;
6362 else 6359 else
6363 { 6360 {
6364 top = position / dwhole; 6361 top = (float) position / whole;
6365 shown = portion / dwhole; 6362 shown = (float) portion / whole;
6366 } 6363 }
6367 6364
6368 { 6365 {
6369 double old_top, old_shown; 6366 float old_top, old_shown;
6370 Dimension height; 6367 Dimension height;
6371
6372 XtVaGetValues (widget, 6368 XtVaGetValues (widget,
6373 XtNtopOfThumb, &old_top, 6369 XtNtopOfThumb, &old_top,
6374 XtNshown, &old_shown, 6370 XtNshown, &old_shown,
@@ -6383,21 +6379,19 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
6383#if ! defined (HAVE_XAW3D) 6379#if ! defined (HAVE_XAW3D)
6384 /* With Xaw, 'top' values too closer to 1.0 may 6380 /* With Xaw, 'top' values too closer to 1.0 may
6385 cause the thumb to disappear. Fix that. */ 6381 cause the thumb to disappear. Fix that. */
6386 top = min (top, 0.99); 6382 top = min (top, 0.99f);
6387#endif 6383#endif
6388 /* Keep two pixels available for moving the thumb down. */ 6384 /* Keep two pixels available for moving the thumb down. */
6389 shown = max (0, min (1 - top - (2.0 / height), shown)); 6385 shown = max (0, min (1 - top - (2.0f / height), shown));
6390#if ! defined (HAVE_XAW3D) 6386#if ! defined (HAVE_XAW3D)
6391 /* Likewise with too small 'shown'. */ 6387 /* Likewise with too small 'shown'. */
6392 shown = max (shown, 0.01); 6388 shown = max (shown, 0.01f);
6393#endif 6389#endif
6394 6390
6395 /* If the call to XawScrollbarSetThumb below doesn't seem to 6391 /* If the call to XawScrollbarSetThumb below doesn't seem to
6396 work, check that 'NARROWPROTO' is defined in src/config.h. 6392 work, check that 'NARROWPROTO' is defined in src/config.h.
6397 If this is not so, most likely you need to fix configure. */ 6393 If this is not so, most likely you need to fix configure. */
6398 double ftop = top, fshown = shown; 6394 if (top != old_top || shown != old_shown)
6399
6400 if (ftop != old_top || fshown != old_shown)
6401 { 6395 {
6402 if (bar->dragging == -1) 6396 if (bar->dragging == -1)
6403 XawScrollbarSetThumb (widget, top, shown); 6397 XawScrollbarSetThumb (widget, top, shown);
@@ -6422,15 +6416,14 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion,
6422{ 6416{
6423 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 6417 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
6424 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 6418 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
6425 double dwhole = whole; 6419 float top, shown;
6426 double top, shown;
6427 6420
6428 block_input (); 6421 block_input ();
6429 6422
6430#ifdef USE_MOTIF 6423#ifdef USE_MOTIF
6431 bar->whole = whole; 6424 bar->whole = whole;
6432 shown = portion / dwhole; 6425 shown = (float) portion / whole;
6433 top = position / (dwhole - portion); 6426 top = (float) position / (whole - portion);
6434 { 6427 {
6435 int size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX); 6428 int size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX);
6436 int value = clip_to_bounds (0, top * (XM_SB_MAX - size), XM_SB_MAX - size); 6429 int value = clip_to_bounds (0, top * (XM_SB_MAX - size), XM_SB_MAX - size);
@@ -6443,8 +6436,8 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion,
6443 top = 0, shown = 1; 6436 top = 0, shown = 1;
6444 else 6437 else
6445 { 6438 {
6446 top = position / dwhole; 6439 top = (float) position / whole;
6447 shown = portion / dwhole; 6440 shown = (float) portion / whole;
6448 } 6441 }
6449 6442
6450 { 6443 {
@@ -6465,13 +6458,13 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion,
6465#if ! defined (HAVE_XAW3D) 6458#if ! defined (HAVE_XAW3D)
6466 /* With Xaw, 'top' values too closer to 1.0 may 6459 /* With Xaw, 'top' values too closer to 1.0 may
6467 cause the thumb to disappear. Fix that. */ 6460 cause the thumb to disappear. Fix that. */
6468 top = min (top, 0.99); 6461 top = min (top, 0.99f);
6469#endif 6462#endif
6470 /* Keep two pixels available for moving the thumb down. */ 6463 /* Keep two pixels available for moving the thumb down. */
6471 shown = max (0, min (1 - top - (2.0 / height), shown)); 6464 shown = max (0, min (1 - top - (2.0f / height), shown));
6472#if ! defined (HAVE_XAW3D) 6465#if ! defined (HAVE_XAW3D)
6473 /* Likewise with too small 'shown'. */ 6466 /* Likewise with too small 'shown'. */
6474 shown = max (shown, 0.01); 6467 shown = max (shown, 0.01f);
6475#endif 6468#endif
6476#endif 6469#endif
6477 6470
@@ -6480,8 +6473,7 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion,
6480 If this is not so, most likely you need to fix configure. */ 6473 If this is not so, most likely you need to fix configure. */
6481 XawScrollbarSetThumb (widget, top, shown); 6474 XawScrollbarSetThumb (widget, top, shown);
6482#if false 6475#if false
6483 float ftop = top, fshown = shown; 6476 if (top != old_top || shown != old_shown)
6484 if (ftop != old_top || fshown != old_shown)
6485 { 6477 {
6486 if (bar->dragging == -1) 6478 if (bar->dragging == -1)
6487 XawScrollbarSetThumb (widget, top, shown); 6479 XawScrollbarSetThumb (widget, top, shown);