@@ -206,28 +206,45 @@ static bool match_string(const char *pattern, const char *value) {
206206}
207207
208208rule_consequence_t * find_matching_rule (const char * app_id , const char * title , const char * tag ) {
209- rule_t * r = rule_head ;
210- rule_t * matched = NULL ;
209+ static rule_consequence_t merged ;
210+ memset ( & merged , 0 , sizeof ( merged )) ;
211211
212+ rule_t * r = rule_head ;
212213 while (r != NULL ) {
214+ rule_t * next = r -> next ;
215+
213216 bool app_id_matches = match_string (r -> match .app_id , app_id );
214217 bool title_matches = match_string (r -> match .title , title );
215218 bool tag_matches = match_string (r -> match .tag , tag );
216219
217220 if (app_id_matches && title_matches && tag_matches ) {
218- matched = r ;
219- break ;
221+ rule_type_t bits = r -> consequence .has ;
222+ merged .has |= bits ;
223+ merged .flags = (merged .flags & ~bits ) | (r -> consequence .flags & bits );
224+
225+ if (bits & RULE_TYPE_DESKTOP )
226+ strncpy (merged .desktop , r -> consequence .desktop , SMALEN );
227+ if (bits & RULE_TYPE_MONITOR )
228+ strncpy (merged .monitor , r -> consequence .monitor , SMALEN );
229+ if (bits & RULE_TYPE_STATE )
230+ merged .state = r -> consequence .state ;
231+ if (bits & RULE_TYPE_SCROLLER_PROPORTION )
232+ merged .scroller_proportion = r -> consequence .scroller_proportion ;
233+ if (bits & RULE_TYPE_SCROLLER_PROPORTION_SINGLE )
234+ merged .scroller_proportion_single = r -> consequence .scroller_proportion_single ;
235+ if (bits & RULE_TYPE_BORDER_RADIUS )
236+ merged .border_radius = r -> consequence .border_radius ;
237+ if (bits & RULE_TYPE_OPACITY )
238+ merged .opacity = r -> consequence .opacity ;
239+
240+ if (r -> match .one_shot )
241+ remove_rule (r );
220242 }
221- r = r -> next ;
222- }
223-
224- if (matched == NULL )
225- return NULL ;
226243
227- if ( matched -> match . one_shot )
228- remove_rule ( matched );
244+ r = next ;
245+ }
229246
230- return & matched -> consequence ;
247+ return merged . has ? & merged : NULL ;
231248}
232249
233250void rule_apply_consequence (node_t * node , client_t * client , const rule_consequence_t * rule ) {
0 commit comments