mirror of
https://github.com/yshui/picom.git
synced 2024-12-02 14:15:41 -05:00
c2: add list iterating functions
Also renames free_wincondlst to c2_list_free and move it to c2.h. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
7e833744b7
commit
23c56ab328
4 changed files with 41 additions and 19 deletions
15
src/c2.c
15
src/c2.c
|
@ -1675,3 +1675,18 @@ bool c2_match(session_t *ps, const struct managed_win *w, const c2_lptr_t *condl
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Iterate over all conditions in a condition linked list. Call the callback for each of
|
||||
/// the conditions. If the callback returns true, the iteration stops early.
|
||||
void c2_list_foreach(const c2_lptr_t *condlist, c2_list_foreach_cb_t cb, void *data) {
|
||||
for (auto i = condlist; i; condlist = condlist->next) {
|
||||
if (cb(i, data)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Return user data stored in a condition.
|
||||
void *c2_list_get_data(const c2_lptr_t *condlist) {
|
||||
return condlist->data;
|
||||
}
|
||||
|
|
17
src/c2.h
17
src/c2.h
|
@ -12,6 +12,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct _c2_lptr c2_lptr_t;
|
||||
typedef struct session session_t;
|
||||
|
@ -21,6 +22,20 @@ c2_lptr_t *c2_parse(c2_lptr_t **pcondlst, const char *pattern, void *data);
|
|||
|
||||
c2_lptr_t *c2_free_lptr(c2_lptr_t *lp);
|
||||
|
||||
bool c2_match(session_t *ps, const struct managed_win *w, const c2_lptr_t *condlst, void **pdata);
|
||||
bool c2_match(session_t *ps, const struct managed_win *w, const c2_lptr_t *condlst,
|
||||
void **pdata);
|
||||
|
||||
bool c2_list_postprocess(session_t *ps, c2_lptr_t *list);
|
||||
typedef bool (*c2_list_foreach_cb_t)(const c2_lptr_t *cond, void *data);
|
||||
void c2_list_foreach(const c2_lptr_t *list, c2_list_foreach_cb_t cb, void *data);
|
||||
/// Return user data stored in a condition.
|
||||
void *c2_list_get_data(const c2_lptr_t *condlist);
|
||||
|
||||
/**
|
||||
* Destroy a condition list.
|
||||
*/
|
||||
static inline void c2_list_free(c2_lptr_t **pcondlst) {
|
||||
while ((*pcondlst = c2_free_lptr(*pcondlst))) {
|
||||
}
|
||||
*pcondlst = NULL;
|
||||
}
|
||||
|
|
20
src/picom.c
20
src/picom.c
|
@ -2164,16 +2164,16 @@ static void session_destroy(session_t *ps) {
|
|||
list_init_head(&ps->window_stack);
|
||||
|
||||
// Free blacklists
|
||||
free_wincondlst(&ps->o.shadow_blacklist);
|
||||
free_wincondlst(&ps->o.shadow_clip_list);
|
||||
free_wincondlst(&ps->o.fade_blacklist);
|
||||
free_wincondlst(&ps->o.focus_blacklist);
|
||||
free_wincondlst(&ps->o.invert_color_list);
|
||||
free_wincondlst(&ps->o.blur_background_blacklist);
|
||||
free_wincondlst(&ps->o.opacity_rules);
|
||||
free_wincondlst(&ps->o.paint_blacklist);
|
||||
free_wincondlst(&ps->o.unredir_if_possible_blacklist);
|
||||
free_wincondlst(&ps->o.rounded_corners_blacklist);
|
||||
c2_list_free(&ps->o.shadow_blacklist);
|
||||
c2_list_free(&ps->o.shadow_clip_list);
|
||||
c2_list_free(&ps->o.fade_blacklist);
|
||||
c2_list_free(&ps->o.focus_blacklist);
|
||||
c2_list_free(&ps->o.invert_color_list);
|
||||
c2_list_free(&ps->o.blur_background_blacklist);
|
||||
c2_list_free(&ps->o.opacity_rules);
|
||||
c2_list_free(&ps->o.paint_blacklist);
|
||||
c2_list_free(&ps->o.unredir_if_possible_blacklist);
|
||||
c2_list_free(&ps->o.rounded_corners_blacklist);
|
||||
|
||||
// Free tracked atom list
|
||||
{
|
||||
|
|
|
@ -84,14 +84,6 @@ static inline bool array_wid_exists(const xcb_window_t *arr, int count, xcb_wind
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a condition list.
|
||||
*/
|
||||
static inline void free_wincondlst(c2_lptr_t **pcondlst) {
|
||||
while ((*pcondlst = c2_free_lptr(*pcondlst)))
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_OPENGL
|
||||
static inline void free_paint_glx(session_t *ps attr_unused, paint_t *p attr_unused) {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue