diff options
| author | Paul Eggert | 2017-08-24 16:15:59 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-24 16:17:39 -0700 |
| commit | daf434b40d61e8cc99485988017a4a95ff475922 (patch) | |
| tree | 201c593baa44d6d59478b8a35458dd3154742cf0 /src | |
| parent | bd9ad2ea1051a73e30e720b90cf413ee93a977f7 (diff) | |
| download | emacs-daf434b40d61e8cc99485988017a4a95ff475922.tar.gz emacs-daf434b40d61e8cc99485988017a4a95ff475922.zip | |
Prefer ‘double’ for FP temps in xterm.c
* src/xterm.c (xm_scroll_callback, xaw_jump_callback)
(x_set_toolkit_scroll_bar_thumb)
(x_set_toolkit_horizontal_scroll_bar_thumb): Prefer ‘double’ to
‘float’ for individual local floating-point temporaries.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/xterm.c b/src/xterm.c index 77daa22ae0d..fb220b335a4 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5575,8 +5575,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data) | |||
| 5575 | 5575 | ||
| 5576 | if (horizontal) | 5576 | if (horizontal) |
| 5577 | { | 5577 | { |
| 5578 | portion = bar->whole * ((float)cs->value / XM_SB_MAX); | 5578 | double dXM_SB_MAX = XM_SB_MAX; |
| 5579 | whole = bar->whole * ((float)(XM_SB_MAX - slider_size) / XM_SB_MAX); | 5579 | portion = bar->whole * (cs->value / dXM_SB_MAX); |
| 5580 | whole = bar->whole * ((XM_SB_MAX - slider_size) / dXM_SB_MAX); | ||
| 5580 | portion = min (portion, whole); | 5581 | portion = min (portion, whole); |
| 5581 | part = scroll_bar_horizontal_handle; | 5582 | part = scroll_bar_horizontal_handle; |
| 5582 | } | 5583 | } |
| @@ -5713,7 +5714,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) | |||
| 5713 | { | 5714 | { |
| 5714 | struct scroll_bar *bar = client_data; | 5715 | struct scroll_bar *bar = client_data; |
| 5715 | float *top_addr = call_data; | 5716 | float *top_addr = call_data; |
| 5716 | float top = *top_addr; | 5717 | double top = *top_addr; |
| 5717 | float shown; | 5718 | float shown; |
| 5718 | int whole, portion, height, width; | 5719 | int whole, portion, height, width; |
| 5719 | enum scroll_bar_part part; | 5720 | enum scroll_bar_part part; |
| @@ -5729,7 +5730,8 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) | |||
| 5729 | 5730 | ||
| 5730 | if (shown < 1) | 5731 | if (shown < 1) |
| 5731 | { | 5732 | { |
| 5732 | whole = bar->whole - (shown * bar->whole); | 5733 | double dshown = shown; |
| 5734 | whole = bar->whole - (dshown * bar->whole); | ||
| 5733 | portion = min (top * bar->whole, whole); | 5735 | portion = min (top * bar->whole, whole); |
| 5734 | } | 5736 | } |
| 5735 | else | 5737 | else |
| @@ -5750,7 +5752,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) | |||
| 5750 | whole = 10000000; | 5752 | whole = 10000000; |
| 5751 | portion = shown < 1 ? top * whole : 0; | 5753 | portion = shown < 1 ? top * whole : 0; |
| 5752 | 5754 | ||
| 5753 | if (shown < 1 && (eabs (top + shown - 1) < 1.0f / height)) | 5755 | if (shown < 1 && (eabs (top + shown - 1) < 1.0 / height)) |
| 5754 | /* Some derivatives of Xaw refuse to shrink the thumb when you reach | 5756 | /* Some derivatives of Xaw refuse to shrink the thumb when you reach |
| 5755 | the bottom, so we force the scrolling whenever we see that we're | 5757 | the bottom, so we force the scrolling whenever we see that we're |
| 5756 | too close to the bottom (in x_set_toolkit_scroll_bar_thumb | 5758 | too close to the bottom (in x_set_toolkit_scroll_bar_thumb |
| @@ -6293,7 +6295,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio | |||
| 6293 | { | 6295 | { |
| 6294 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 6296 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
| 6295 | Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); | 6297 | Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); |
| 6296 | float top, shown; | 6298 | double dwhole = whole; |
| 6299 | double top, shown; | ||
| 6297 | 6300 | ||
| 6298 | block_input (); | 6301 | block_input (); |
| 6299 | 6302 | ||
| @@ -6322,8 +6325,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio | |||
| 6322 | top = 0, shown = 1; | 6325 | top = 0, shown = 1; |
| 6323 | else | 6326 | else |
| 6324 | { | 6327 | { |
| 6325 | top = (float) position / whole; | 6328 | top = position / dwhole; |
| 6326 | shown = (float) portion / whole; | 6329 | shown = portion / dwhole; |
| 6327 | } | 6330 | } |
| 6328 | 6331 | ||
| 6329 | if (bar->dragging == -1) | 6332 | if (bar->dragging == -1) |
| @@ -6347,8 +6350,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio | |||
| 6347 | top = 0, shown = 1; | 6350 | top = 0, shown = 1; |
| 6348 | else | 6351 | else |
| 6349 | { | 6352 | { |
| 6350 | top = (float) position / whole; | 6353 | top = position / dwhole; |
| 6351 | shown = (float) portion / whole; | 6354 | shown = portion / dwhole; |
| 6352 | } | 6355 | } |
| 6353 | 6356 | ||
| 6354 | { | 6357 | { |
| @@ -6368,19 +6371,20 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio | |||
| 6368 | #if ! defined (HAVE_XAW3D) | 6371 | #if ! defined (HAVE_XAW3D) |
| 6369 | /* With Xaw, 'top' values too closer to 1.0 may | 6372 | /* With Xaw, 'top' values too closer to 1.0 may |
| 6370 | cause the thumb to disappear. Fix that. */ | 6373 | cause the thumb to disappear. Fix that. */ |
| 6371 | top = min (top, 0.99f); | 6374 | top = min (top, 0.99); |
| 6372 | #endif | 6375 | #endif |
| 6373 | /* Keep two pixels available for moving the thumb down. */ | 6376 | /* Keep two pixels available for moving the thumb down. */ |
| 6374 | shown = max (0, min (1 - top - (2.0f / height), shown)); | 6377 | shown = max (0, min (1 - top - (2.0 / height), shown)); |
| 6375 | #if ! defined (HAVE_XAW3D) | 6378 | #if ! defined (HAVE_XAW3D) |
| 6376 | /* Likewise with too small 'shown'. */ | 6379 | /* Likewise with too small 'shown'. */ |
| 6377 | shown = max (shown, 0.01f); | 6380 | shown = max (shown, 0.01); |
| 6378 | #endif | 6381 | #endif |
| 6379 | 6382 | ||
| 6380 | /* If the call to XawScrollbarSetThumb below doesn't seem to | 6383 | /* If the call to XawScrollbarSetThumb below doesn't seem to |
| 6381 | work, check that 'NARROWPROTO' is defined in src/config.h. | 6384 | work, check that 'NARROWPROTO' is defined in src/config.h. |
| 6382 | If this is not so, most likely you need to fix configure. */ | 6385 | If this is not so, most likely you need to fix configure. */ |
| 6383 | if (top != old_top || shown != old_shown) | 6386 | float ftop = top, fshown = shown; |
| 6387 | if (ftop != old_top || fshown != old_shown) | ||
| 6384 | { | 6388 | { |
| 6385 | if (bar->dragging == -1) | 6389 | if (bar->dragging == -1) |
| 6386 | XawScrollbarSetThumb (widget, top, shown); | 6390 | XawScrollbarSetThumb (widget, top, shown); |
| @@ -6405,14 +6409,15 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 6405 | { | 6409 | { |
| 6406 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 6410 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
| 6407 | Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); | 6411 | Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); |
| 6408 | float top, shown; | 6412 | double dwhole = whole; |
| 6413 | double top, shown; | ||
| 6409 | 6414 | ||
| 6410 | block_input (); | 6415 | block_input (); |
| 6411 | 6416 | ||
| 6412 | #ifdef USE_MOTIF | 6417 | #ifdef USE_MOTIF |
| 6413 | bar->whole = whole; | 6418 | bar->whole = whole; |
| 6414 | shown = (float) portion / whole; | 6419 | shown = portion / dwhole; |
| 6415 | top = (float) position / (whole - portion); | 6420 | top = position / (dwhole - portion); |
| 6416 | { | 6421 | { |
| 6417 | int size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX); | 6422 | int size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX); |
| 6418 | int value = clip_to_bounds (0, top * (XM_SB_MAX - size), XM_SB_MAX - size); | 6423 | int value = clip_to_bounds (0, top * (XM_SB_MAX - size), XM_SB_MAX - size); |
| @@ -6425,8 +6430,8 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 6425 | top = 0, shown = 1; | 6430 | top = 0, shown = 1; |
| 6426 | else | 6431 | else |
| 6427 | { | 6432 | { |
| 6428 | top = (float) position / whole; | 6433 | top = position / dwhole; |
| 6429 | shown = (float) portion / whole; | 6434 | shown = portion / dwhole; |
| 6430 | } | 6435 | } |
| 6431 | 6436 | ||
| 6432 | { | 6437 | { |
| @@ -6447,13 +6452,13 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 6447 | #if ! defined (HAVE_XAW3D) | 6452 | #if ! defined (HAVE_XAW3D) |
| 6448 | /* With Xaw, 'top' values too closer to 1.0 may | 6453 | /* With Xaw, 'top' values too closer to 1.0 may |
| 6449 | cause the thumb to disappear. Fix that. */ | 6454 | cause the thumb to disappear. Fix that. */ |
| 6450 | top = min (top, 0.99f); | 6455 | top = min (top, 0.99); |
| 6451 | #endif | 6456 | #endif |
| 6452 | /* Keep two pixels available for moving the thumb down. */ | 6457 | /* Keep two pixels available for moving the thumb down. */ |
| 6453 | shown = max (0, min (1 - top - (2.0f / height), shown)); | 6458 | shown = max (0, min (1 - top - (2.0 / height), shown)); |
| 6454 | #if ! defined (HAVE_XAW3D) | 6459 | #if ! defined (HAVE_XAW3D) |
| 6455 | /* Likewise with too small 'shown'. */ | 6460 | /* Likewise with too small 'shown'. */ |
| 6456 | shown = max (shown, 0.01f); | 6461 | shown = max (shown, 0.01); |
| 6457 | #endif | 6462 | #endif |
| 6458 | #endif | 6463 | #endif |
| 6459 | 6464 | ||
| @@ -6462,7 +6467,8 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 6462 | If this is not so, most likely you need to fix configure. */ | 6467 | If this is not so, most likely you need to fix configure. */ |
| 6463 | XawScrollbarSetThumb (widget, top, shown); | 6468 | XawScrollbarSetThumb (widget, top, shown); |
| 6464 | #if false | 6469 | #if false |
| 6465 | if (top != old_top || shown != old_shown) | 6470 | float ftop = top, fshown = shown; |
| 6471 | if (ftop != old_top || fshown != old_shown) | ||
| 6466 | { | 6472 | { |
| 6467 | if (bar->dragging == -1) | 6473 | if (bar->dragging == -1) |
| 6468 | XawScrollbarSetThumb (widget, top, shown); | 6474 | XawScrollbarSetThumb (widget, top, shown); |