Skip to content

Commit a23d619

Browse files
committed
Deduplicate code
1 parent a4b08f3 commit a23d619

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

src/egfullscreenclient.cpp

+22-35
Original file line numberDiff line numberDiff line change
@@ -266,27 +266,32 @@ void egmde::FullscreenClient::on_output_changed(Output const* output)
266266
draw_screen(p->second, should_draw_crash());
267267
}
268268

269-
auto i = begin(hidden_outputs);
270-
while (i != end(hidden_outputs))
271-
{
272-
mir::geometry::Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};
273-
274-
if (!display_area.bounding_rectangle().overlaps(screen_rect))
275-
{
276-
display_area.add(screen_rect);
277-
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
278-
break;
279-
}
269+
check_for_exposed_output();
270+
}
271+
wl_display_flush(display);
272+
}
280273

281-
++i;
282-
}
274+
void egmde::FullscreenClient::check_for_exposed_output()
275+
{
276+
auto i = begin(hidden_outputs);
277+
while (i != end(hidden_outputs))
278+
{
279+
Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};
283280

284-
if (i != end(hidden_outputs))
281+
if (!display_area.bounding_rectangle().overlaps(screen_rect))
285282
{
286-
hidden_outputs.erase(i);
283+
display_area.add(screen_rect);
284+
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
285+
break;
287286
}
287+
288+
++i;
289+
}
290+
291+
if (i != end(hidden_outputs))
292+
{
293+
hidden_outputs.erase(i);
288294
}
289-
wl_display_flush(display);
290295
}
291296

292297
void egmde::FullscreenClient::on_output_gone(Output const* output)
@@ -316,25 +321,7 @@ void egmde::FullscreenClient::on_output_gone(Output const* output)
316321
display_area.remove({{output->x, output->y}, {output->width, output->height}});
317322
}
318323

319-
i = begin(hidden_outputs);
320-
while (i != end(hidden_outputs))
321-
{
322-
mir::geometry::Rectangle const screen_rect{{(*i)->x, (*i)->y}, {(*i)->width, (*i)->height}};
323-
324-
if (!display_area.bounding_rectangle().overlaps(screen_rect))
325-
{
326-
display_area.add(screen_rect);
327-
draw_screen(outputs.insert({*i, SurfaceInfo{*i}}).first->second, should_draw_crash());
328-
break;
329-
}
330-
331-
++i;
332-
}
333-
334-
if (i != end(hidden_outputs))
335-
{
336-
hidden_outputs.erase(i);
337-
}
324+
check_for_exposed_output();
338325
}
339326
wl_display_flush(display);
340327
}

src/egfullscreenclient.h

+2
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class FullscreenClient
256256

257257
bool diagnostic_wants_to_draw = false;
258258
bool diagnostic_exists = false;
259+
260+
void check_for_exposed_output();
259261
};
260262
}
261263

0 commit comments

Comments
 (0)