Skip to content

Commit

Permalink
Tidy up after static analysis (#185)
Browse files Browse the repository at this point in the history
Fix true positives
  • Loading branch information
mattkae authored May 29, 2024
2 parents a978d46 + 26cb832 commit 8e509db
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 41 deletions.
10 changes: 5 additions & 5 deletions src/background_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void BackgroundClient::render_background(
{
Colour new_pixel;

for (auto current_y = 0; current_y < height; current_y++)
for (uint32_t current_y = 0; current_y < height; current_y++)
{
// Render gradient
for (auto i = 0; i < 3; i++)
Expand Down Expand Up @@ -358,8 +358,8 @@ void BackgroundClient::Self::render_text(

auto const diagnostic = TextRenderer::DiagnosticText::from(diagnostic_path.value());

auto const x_margin = width * (x_margin_percent / 100.0);
auto const y_margin = height * (y_margin_percent / 100.0);
auto const x_margin = uint32_t(width * (x_margin_percent / 100.0));
auto const y_margin = uint32_t(height * (y_margin_percent / 100.0));

auto const x_diff = width - x_margin;
auto const y_diff = height - y_margin;
Expand Down Expand Up @@ -652,7 +652,7 @@ auto TextRenderer::get_max_font_height_by_width(DiagnosticText const& diagnostic
auto estimate_font_height = 50;
auto const width_from_estimate = get_max_line_width(diagnostic, estimate_font_height);

auto const final_font_height = estimate_font_height * (static_cast<double>(max_width) / width_from_estimate);
auto const final_font_height = uint32_t(estimate_font_height * (static_cast<double>(max_width) / width_from_estimate));
return final_font_height;
}

Expand All @@ -662,7 +662,7 @@ auto TextRenderer::get_max_font_height_by_height(DiagnosticText const& diagnosti
auto estimate_font_height = 50;
auto const height_from_estimate = get_total_height(num_lines, estimate_font_height);

auto const final_font_height = estimate_font_height * (static_cast<double>(max_height) / height_from_estimate);
auto const final_font_height = uint32_t(estimate_font_height * (static_cast<double>(max_height) / height_from_estimate));
return final_font_height;
}

Expand Down
57 changes: 21 additions & 36 deletions src/egfullscreenclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ egmde::FullscreenClient::FullscreenClient(wl_display* display, std::optional<Pat
draw_signal{::eventfd(0, EFD_SEMAPHORE)},
shutdown_signal{::eventfd(0, EFD_CLOEXEC)},
diagnostic_signal{inotify_init()},
registry{nullptr, [](auto){}},
diagnostic_path{diagnostic_path},
diagnostic_delay{diagnostic_delay},
runner{runner},
window_manager_observer{window_manager_observer},
registry{nullptr, [](auto){}}
window_manager_observer{window_manager_observer}
{
// Check inotify initializaiton
if (diagnostic_signal < 0)
Expand Down Expand Up @@ -266,27 +266,30 @@ void egmde::FullscreenClient::on_output_changed(Output const* output)
draw_screen(p->second, should_draw_crash());
}

auto i = begin(hidden_outputs);
while (i != end(hidden_outputs))
{
mir::geometry::Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};

if (!display_area.bounding_rectangle().overlaps(screen_rect))
{
display_area.add(screen_rect);
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
break;
}
check_for_exposed_outputs();
}
wl_display_flush(display);
}

++i;
}
void egmde::FullscreenClient::check_for_exposed_outputs()
{
auto i = begin(hidden_outputs);
while (i != end(hidden_outputs))
{
Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};

if (i != end(hidden_outputs))
if (!display_area.bounding_rectangle().overlaps(screen_rect))
{
display_area.add(screen_rect);
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
hidden_outputs.erase(i);
break;
}
else
{
++i;
}
}
wl_display_flush(display);
}

void egmde::FullscreenClient::on_output_gone(Output const* output)
Expand Down Expand Up @@ -316,25 +319,7 @@ void egmde::FullscreenClient::on_output_gone(Output const* output)
display_area.remove({{output->x, output->y}, {output->width, output->height}});
}

i = begin(hidden_outputs);
while (i != end(hidden_outputs))
{
mir::geometry::Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};

if (!display_area.bounding_rectangle().overlaps(screen_rect))
{
display_area.add(screen_rect);
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
break;
}

++i;
}

if (i != end(hidden_outputs))
{
hidden_outputs.erase(i);
}
check_for_exposed_outputs();
}
wl_display_flush(display);
}
Expand Down
2 changes: 2 additions & 0 deletions src/egfullscreenclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ class FullscreenClient

void draw();

void check_for_exposed_outputs();

mir::Fd const draw_signal;
mir::Fd const shutdown_signal;
mir::Fd const diagnostic_signal;
Expand Down

0 comments on commit 8e509db

Please sign in to comment.