aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Carl Smedstad <carl.smedstad@protonmail.com>2022-12-30 08:50:14 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2023-01-03 21:50:56 +0100
commit9425ce2fba6dd643c240386901de370ac90cc337 (patch)
treeeece0cfb4e472de8809ea7a074336905c2767932
parentRemove redundant return statements (diff)
downloadsway-9425ce2fba6dd643c240386901de370ac90cc337.tar.gz
sway-9425ce2fba6dd643c240386901de370ac90cc337.tar.zst
sway-9425ce2fba6dd643c240386901de370ac90cc337.zip
Replace math functions that promote float to double
-rw-r--r--sway/config/output.c2
-rw-r--r--sway/desktop/output.c10
-rw-r--r--sway/desktop/render.c12
-rw-r--r--sway/input/seatop_default.c4
-rw-r--r--sway/input/seatop_down.c2
5 files changed, 15 insertions, 15 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 914cf6c4..e2e48e4c 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -257,7 +257,7 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending
257 // Not all floating point integers can be represented exactly 257 // Not all floating point integers can be represented exactly
258 // as (int)(1000 * mHz / 1000.f) 258 // as (int)(1000 * mHz / 1000.f)
259 // round() the result to avoid any error 259 // round() the result to avoid any error
260 int mhz = (int)round(refresh_rate * 1000); 260 int mhz = (int)roundf(refresh_rate * 1000);
261 261
262 if (wl_list_empty(&output->modes) || custom) { 262 if (wl_list_empty(&output->modes) || custom) {
263 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); 263 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name);
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index f39b8ea7..409478a7 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -364,14 +364,14 @@ overlay:
364} 364}
365 365
366static int scale_length(int length, int offset, float scale) { 366static int scale_length(int length, int offset, float scale) {
367 return round((offset + length) * scale) - round(offset * scale); 367 return roundf((offset + length) * scale) - roundf(offset * scale);
368} 368}
369 369
370void scale_box(struct wlr_box *box, float scale) { 370void scale_box(struct wlr_box *box, float scale) {
371 box->width = scale_length(box->width, box->x, scale); 371 box->width = scale_length(box->width, box->x, scale);
372 box->height = scale_length(box->height, box->y, scale); 372 box->height = scale_length(box->height, box->y, scale);
373 box->x = round(box->x * scale); 373 box->x = roundf(box->x * scale);
374 box->y = round(box->y * scale); 374 box->y = roundf(box->y * scale);
375} 375}
376 376
377struct sway_workspace *output_get_active_workspace(struct sway_output *output) { 377struct sway_workspace *output_get_active_workspace(struct sway_output *output) {
@@ -683,11 +683,11 @@ static void damage_surface_iterator(struct sway_output *output,
683 pixman_region32_init(&damage); 683 pixman_region32_init(&damage);
684 wlr_surface_get_effective_damage(surface, &damage); 684 wlr_surface_get_effective_damage(surface, &damage);
685 wlr_region_scale(&damage, &damage, output->wlr_output->scale); 685 wlr_region_scale(&damage, &damage, output->wlr_output->scale);
686 if (ceil(output->wlr_output->scale) > surface->current.scale) { 686 if (ceilf(output->wlr_output->scale) > surface->current.scale) {
687 // When scaling up a surface, it'll become blurry so we need to 687 // When scaling up a surface, it'll become blurry so we need to
688 // expand the damage region 688 // expand the damage region
689 wlr_region_expand(&damage, &damage, 689 wlr_region_expand(&damage, &damage,
690 ceil(output->wlr_output->scale) - surface->current.scale); 690 ceilf(output->wlr_output->scale) - surface->current.scale);
691 } 691 }
692 pixman_region32_translate(&damage, box.x, box.y); 692 pixman_region32_translate(&damage, box.x, box.y);
693 if (wlr_damage_ring_add(&output->damage_ring, &damage)) { 693 if (wlr_damage_ring_add(&output->damage_ring, &damage)) {
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index ea9c37d9..4d242bd7 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -50,7 +50,7 @@ struct render_data {
50 * scaled to 2px. 50 * scaled to 2px.
51 */ 51 */
52static int scale_length(int length, int offset, float scale) { 52static int scale_length(int length, int offset, float scale) {
53 return round((offset + length) * scale) - round(offset * scale); 53 return roundf((offset + length) * scale) - roundf(offset * scale);
54} 54}
55 55
56static void scissor_output(struct wlr_output *wlr_output, 56static void scissor_output(struct wlr_output *wlr_output,
@@ -482,7 +482,7 @@ static void render_titlebar(struct sway_output *output,
482 size_t inner_width = width - titlebar_h_padding * 2; 482 size_t inner_width = width - titlebar_h_padding * 2;
483 483
484 // output-buffer local 484 // output-buffer local
485 int ob_inner_x = round(inner_x * output_scale); 485 int ob_inner_x = roundf(inner_x * output_scale);
486 int ob_inner_width = scale_length(inner_width, inner_x, output_scale); 486 int ob_inner_width = scale_length(inner_width, inner_x, output_scale);
487 int ob_bg_height = scale_length( 487 int ob_bg_height = scale_length(
488 (titlebar_v_padding - titlebar_border_thickness) * 2 + 488 (titlebar_v_padding - titlebar_border_thickness) * 2 +
@@ -531,7 +531,7 @@ static void render_titlebar(struct sway_output *output,
531 memcpy(&color, colors->background, sizeof(float) * 4); 531 memcpy(&color, colors->background, sizeof(float) * 4);
532 premultiply_alpha(color, con->alpha); 532 premultiply_alpha(color, con->alpha);
533 box.x = texture_box.x + round(output_x * output_scale); 533 box.x = texture_box.x + round(output_x * output_scale);
534 box.y = round((y + titlebar_border_thickness) * output_scale); 534 box.y = roundf((y + titlebar_border_thickness) * output_scale);
535 box.width = texture_box.width; 535 box.width = texture_box.width;
536 box.height = ob_padding_above; 536 box.height = ob_padding_above;
537 render_rect(output, output_damage, &box, color); 537 render_rect(output, output_damage, &box, color);
@@ -562,7 +562,7 @@ static void render_titlebar(struct sway_output *output,
562 562
563 // The title texture might be shorter than the config->font_height, 563 // The title texture might be shorter than the config->font_height,
564 // in which case we need to pad it above and below. 564 // in which case we need to pad it above and below.
565 int ob_padding_above = round((titlebar_v_padding - 565 int ob_padding_above = roundf((titlebar_v_padding -
566 titlebar_border_thickness) * output_scale); 566 titlebar_border_thickness) * output_scale);
567 int ob_padding_below = ob_bg_height - ob_padding_above - 567 int ob_padding_below = ob_bg_height - ob_padding_above -
568 texture_box.height; 568 texture_box.height;
@@ -607,7 +607,7 @@ static void render_titlebar(struct sway_output *output,
607 memcpy(&color, colors->background, sizeof(float) * 4); 607 memcpy(&color, colors->background, sizeof(float) * 4);
608 premultiply_alpha(color, con->alpha); 608 premultiply_alpha(color, con->alpha);
609 box.x = texture_box.x + round(output_x * output_scale); 609 box.x = texture_box.x + round(output_x * output_scale);
610 box.y = round((y + titlebar_border_thickness) * output_scale); 610 box.y = roundf((y + titlebar_border_thickness) * output_scale);
611 box.width = texture_box.width; 611 box.width = texture_box.width;
612 box.height = ob_padding_above; 612 box.height = ob_padding_above;
613 render_rect(output, output_damage, &box, color); 613 render_rect(output, output_damage, &box, color);
@@ -647,7 +647,7 @@ static void render_titlebar(struct sway_output *output,
647 box.width = ob_right_x - ob_left_x - ob_left_width; 647 box.width = ob_right_x - ob_left_x - ob_left_width;
648 if (box.width > 0) { 648 if (box.width > 0) {
649 box.x = ob_left_x + ob_left_width + round(output_x * output_scale); 649 box.x = ob_left_x + ob_left_width + round(output_x * output_scale);
650 box.y = round(bg_y * output_scale); 650 box.y = roundf(bg_y * output_scale);
651 box.height = ob_bg_height; 651 box.height = ob_bg_height;
652 render_rect(output, output_damage, &box, color); 652 render_rect(output, output_damage, &box, color);
653 } 653 }
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 84acefdf..6c69a0ea 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -726,7 +726,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
726 seat_get_active_tiling_child(seat, tabcontainer); 726 seat_get_active_tiling_child(seat, tabcontainer);
727 list_t *siblings = container_get_siblings(cont); 727 list_t *siblings = container_get_siblings(cont);
728 int desired = list_find(siblings, active->sway_container) + 728 int desired = list_find(siblings, active->sway_container) +
729 round(scroll_factor * event->delta_discrete / WLR_POINTER_AXIS_DISCRETE_STEP); 729 roundf(scroll_factor * event->delta_discrete / WLR_POINTER_AXIS_DISCRETE_STEP);
730 if (desired < 0) { 730 if (desired < 0) {
731 desired = 0; 731 desired = 0;
732 } else if (desired >= siblings->length) { 732 } else if (desired >= siblings->length) {
@@ -761,7 +761,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
761 if (!handled) { 761 if (!handled) {
762 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, 762 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec,
763 event->orientation, scroll_factor * event->delta, 763 event->orientation, scroll_factor * event->delta,
764 round(scroll_factor * event->delta_discrete), event->source); 764 roundf(scroll_factor * event->delta_discrete), event->source);
765 } 765 }
766} 766}
767 767
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index b40773d0..3f880ccf 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -28,7 +28,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
28 28
29 wlr_seat_pointer_notify_axis(seat->wlr_seat, event->time_msec, 29 wlr_seat_pointer_notify_axis(seat->wlr_seat, event->time_msec,
30 event->orientation, scroll_factor * event->delta, 30 event->orientation, scroll_factor * event->delta,
31 round(scroll_factor * event->delta_discrete), event->source); 31 roundf(scroll_factor * event->delta_discrete), event->source);
32} 32}
33 33
34static void handle_button(struct sway_seat *seat, uint32_t time_msec, 34static void handle_button(struct sway_seat *seat, uint32_t time_msec,