@@ -94,6 +94,7 @@ struct BackgroundClient::Self : egmde::FullscreenClient
94
94
wl_display* display,
95
95
miral::MirRunner* runner,
96
96
WindowManagerObserver* window_manager_observer,
97
+ bool wallpaper_enabled,
97
98
Colour const & wallpaper_top_colour,
98
99
Colour const & wallpaper_bottom_colour,
99
100
Colour const & crash_background_colour,
@@ -105,6 +106,7 @@ struct BackgroundClient::Self : egmde::FullscreenClient
105
106
106
107
void render_text (uint32_t width, uint32_t height, unsigned char * buffer) const ;
107
108
109
+ bool const wallpaper_enabled;
108
110
Colour const & wallpaper_top_colour;
109
111
Colour const & wallpaper_bottom_colour;
110
112
Colour const & crash_background_colour;
@@ -182,6 +184,11 @@ void BackgroundClient::set_colour(std::string const& option, Colour& colour)
182
184
}
183
185
}
184
186
187
+ void BackgroundClient::set_wallpaper_enabled (bool option)
188
+ {
189
+ wallpaper_enabled = option;
190
+ }
191
+
185
192
void BackgroundClient::set_wallpaper_top_colour (std::string const & option)
186
193
{
187
194
set_colour (option, wallpaper_top_colour);
@@ -293,6 +300,7 @@ void BackgroundClient::operator()(wl_display* display)
293
300
display,
294
301
runner,
295
302
window_manager_observer,
303
+ wallpaper_enabled,
296
304
wallpaper_top_colour,
297
305
wallpaper_bottom_colour,
298
306
crash_background_colour,
@@ -319,6 +327,7 @@ BackgroundClient::Self::Self(
319
327
wl_display* display,
320
328
miral::MirRunner* runner,
321
329
WindowManagerObserver* window_manager_observer,
330
+ bool wallpaper_enabled,
322
331
Colour const & wallpaper_top_colour,
323
332
Colour const & wallpaper_bottom_colour,
324
333
Colour const & crash_background_colour,
@@ -327,6 +336,7 @@ BackgroundClient::Self::Self(
327
336
uint diagnostic_delay)
328
337
: FullscreenClient(display, diagnostic_path, diagnostic_delay, runner, window_manager_observer),
329
338
runner{runner},
339
+ wallpaper_enabled{wallpaper_enabled},
330
340
wallpaper_top_colour{wallpaper_top_colour},
331
341
wallpaper_bottom_colour{wallpaper_bottom_colour},
332
342
crash_background_colour{crash_background_colour},
@@ -377,6 +387,14 @@ void BackgroundClient::Self::draw_screen(SurfaceInfo& info, bool draws_crash) co
377
387
{
378
388
std::lock_guard lock{buffer_mutex};
379
389
390
+ // Don't draw diagnostic background if file is empty or font not found
391
+ bool const have_diagnostic = diagnostic_path && fs::exists (diagnostic_path.value ()) && fs::file_size (diagnostic_path.value ());
392
+ bool const should_show_diagnostic = draws_crash && have_diagnostic;
393
+ if (!wallpaper_enabled && !should_show_diagnostic)
394
+ {
395
+ return ;
396
+ }
397
+
380
398
bool const rotated = info.output ->transform & WL_OUTPUT_TRANSFORM_90;
381
399
auto const width = rotated ? info.output ->height : info.output ->width ;
382
400
auto const height = rotated ? info.output ->width : info.output ->height ;
@@ -418,18 +436,7 @@ void BackgroundClient::Self::draw_screen(SurfaceInfo& info, bool draws_crash) co
418
436
419
437
auto buffer = static_cast <unsigned char *>(info.content_area );
420
438
421
- // Don't draw diagnostic background if file is empty or font not found
422
- bool file_exists;
423
- if (fs::exists (diagnostic_path.value_or (" " )))
424
- {
425
- file_exists = fs::file_size (diagnostic_path.value ());
426
- }
427
- else
428
- {
429
- file_exists = false ;
430
- }
431
-
432
- if (draws_crash && file_exists)
439
+ if (should_show_diagnostic)
433
440
{
434
441
render_background (width, height, buffer, crash_background_colour);
435
442
render_text (width, height, buffer);
0 commit comments