aboutsummaryrefslogtreecommitdiff
path: root/src/c2.h
blob: a7ddd392db73fa11386eebe050f1d2582b4cc391 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: MIT
/*
 * Compton - a compositor for X11
 *
 * Based on `xcompmgr` - Copyright (c) 2003, Keith Packard
 *
 * Copyright (c) 2011-2013, Christopher Jeffrey
 * See LICENSE-mit for more information.
 *
 */

#pragma once

#include <stdbool.h>
#include <stddef.h>

typedef struct _c2_lptr c2_lptr_t;
typedef struct session session_t;
struct managed_win;

typedef void (*c2_userdata_free)(void *);
c2_lptr_t *c2_parse(c2_lptr_t **pcondlst, const char *pattern, void *data);

c2_lptr_t *c2_free_lptr(c2_lptr_t *lp, c2_userdata_free f);

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);
bool 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, c2_userdata_free f) {
	while ((*pcondlst = c2_free_lptr(*pcondlst, f))) {
	}
	*pcondlst = NULL;
}