@@ -250,9 +250,10 @@ compile_win_script(config_setting_t *setting, int *output_indices, char **err) {
250
250
return script ;
251
251
}
252
252
253
- static bool set_animation (struct win_script * animations ,
254
- const enum animation_trigger * triggers , int number_of_triggers ,
255
- struct script * script , const int * output_indices , unsigned line ) {
253
+ static bool
254
+ set_animation (struct win_script * animations , const enum animation_trigger * triggers ,
255
+ int number_of_triggers , struct script * script , const int * output_indices ,
256
+ uint64_t suppressions , unsigned line ) {
256
257
bool needed = false;
257
258
for (int i = 0 ; i < number_of_triggers ; i ++ ) {
258
259
if (triggers [i ] == ANIMATION_TRIGGER_INVALID ) {
@@ -268,6 +269,7 @@ static bool set_animation(struct win_script *animations,
268
269
memcpy (animations [triggers [i ]].output_indices , output_indices ,
269
270
sizeof (int [NUM_OF_WIN_SCRIPT_OUTPUTS ]));
270
271
animations [triggers [i ]].script = script ;
272
+ animations [triggers [i ]].suppressions = suppressions ;
271
273
needed = true;
272
274
}
273
275
return needed ;
@@ -317,6 +319,52 @@ parse_animation_one(struct win_script *animations, config_setting_t *setting) {
317
319
// script parser shouldn't see this.
318
320
config_setting_remove (setting , "triggers" );
319
321
322
+ uint64_t suppressions = 0 ;
323
+ auto suppressions_setting = config_setting_lookup (setting , "suppressions" );
324
+ if (suppressions_setting != NULL ) {
325
+ auto single_suppression = config_setting_get_string (suppressions_setting );
326
+ if (!config_setting_is_list (suppressions_setting ) &&
327
+ !config_setting_is_array (suppressions_setting ) &&
328
+ single_suppression == NULL ) {
329
+ log_error ("The \"suppressions\" option must either be a string, "
330
+ "a list, or an array, but is none of those at line %d" ,
331
+ config_setting_source_line (suppressions_setting ));
332
+ return NULL ;
333
+ }
334
+ if (single_suppression != NULL ) {
335
+ auto suppression = parse_animation_trigger (single_suppression );
336
+ if (suppression == ANIMATION_TRIGGER_INVALID ) {
337
+ log_error ("Invalid suppression defined at line %d" ,
338
+ config_setting_source_line (suppressions_setting ));
339
+ return NULL ;
340
+ }
341
+ suppressions = 1 << suppression ;
342
+ } else {
343
+ auto len = config_setting_length (suppressions_setting );
344
+ for (int i = 0 ; i < len ; i ++ ) {
345
+ auto suppression_str =
346
+ config_setting_get_string_elem (suppressions_setting , i );
347
+ if (suppression_str == NULL ) {
348
+ log_error (
349
+ "The \"suppressions\" option must only "
350
+ "contain strings, but one of them is not at "
351
+ "line %d" ,
352
+ config_setting_source_line (suppressions_setting ));
353
+ return NULL ;
354
+ }
355
+ auto suppression = parse_animation_trigger (suppression_str );
356
+ if (suppression == ANIMATION_TRIGGER_INVALID ) {
357
+ log_error (
358
+ "Invalid suppression defined at line %d" ,
359
+ config_setting_source_line (suppressions_setting ));
360
+ return NULL ;
361
+ }
362
+ suppressions |= 1 << suppression ;
363
+ }
364
+ }
365
+ config_setting_remove (setting , "suppressions" );
366
+ }
367
+
320
368
int output_indices [NUM_OF_WIN_SCRIPT_OUTPUTS ];
321
369
char * err ;
322
370
auto script = compile_win_script (setting , output_indices , & err );
@@ -328,7 +376,8 @@ parse_animation_one(struct win_script *animations, config_setting_t *setting) {
328
376
}
329
377
330
378
bool needed = set_animation (animations , trigger_types , number_of_triggers , script ,
331
- output_indices , config_setting_source_line (setting ));
379
+ output_indices , suppressions ,
380
+ config_setting_source_line (setting ));
332
381
if (!needed ) {
333
382
script_free (script );
334
383
script = NULL ;
@@ -409,7 +458,7 @@ void generate_fading_config(struct options *opt) {
409
458
trigger [number_of_triggers ++ ] = ANIMATION_TRIGGER_SHOW ;
410
459
}
411
460
if (set_animation (opt -> animations , trigger , number_of_triggers , fade_in1 ,
412
- output_indices , 0 )) {
461
+ output_indices , 0 , 0 )) {
413
462
scripts [number_of_scripts ++ ] = fade_in1 ;
414
463
} else {
415
464
script_free (fade_in1 );
@@ -423,7 +472,7 @@ void generate_fading_config(struct options *opt) {
423
472
trigger [number_of_triggers ++ ] = ANIMATION_TRIGGER_INCREASE_OPACITY ;
424
473
}
425
474
if (set_animation (opt -> animations , trigger , number_of_triggers , fade_in2 ,
426
- output_indices , 0 )) {
475
+ output_indices , 0 , 0 )) {
427
476
scripts [number_of_scripts ++ ] = fade_in2 ;
428
477
} else {
429
478
script_free (fade_in2 );
@@ -443,7 +492,7 @@ void generate_fading_config(struct options *opt) {
443
492
trigger [number_of_triggers ++ ] = ANIMATION_TRIGGER_HIDE ;
444
493
}
445
494
if (set_animation (opt -> animations , trigger , number_of_triggers , fade_out1 ,
446
- output_indices , 0 )) {
495
+ output_indices , 0 , 0 )) {
447
496
scripts [number_of_scripts ++ ] = fade_out1 ;
448
497
} else {
449
498
script_free (fade_out1 );
@@ -457,7 +506,7 @@ void generate_fading_config(struct options *opt) {
457
506
trigger [number_of_triggers ++ ] = ANIMATION_TRIGGER_DECREASE_OPACITY ;
458
507
}
459
508
if (set_animation (opt -> animations , trigger , number_of_triggers , fade_out2 ,
460
- output_indices , 0 )) {
509
+ output_indices , 0 , 0 )) {
461
510
scripts [number_of_scripts ++ ] = fade_out2 ;
462
511
} else {
463
512
script_free (fade_out2 );
0 commit comments