| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <stdbool.h> |
| 8 |
#include <stddef.h> |
| 9 |
#include <xcb/xproto.h> |
| 10 |
|
| 11 |
#include "utils/list.h" |
| 12 |
|
| 13 |
typedef struct c2_condition c2_condition; |
| 14 |
typedef struct session session_t; |
| 15 |
struct c2_state; |
| 16 |
|
| 17 |
struct c2_window_state { |
| 18 |
|
| 19 |
|
| 20 |
struct c2_property_value *values; |
| 21 |
}; |
| 22 |
struct atom; |
| 23 |
struct win; |
| 24 |
struct list_node; |
| 25 |
|
| 26 |
typedef void (*c2_userdata_free)(void *); |
| 27 |
struct c2_condition * |
| 28 |
c2_parse(struct list_node *list, const char *pattern, void *data, bool *deprecated); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
c2_condition * |
| 34 |
c2_parse_with_prefix(struct list_node *list, const char *pattern, |
| 35 |
void *(*parse_prefix)(const char *input, const char **end, void *), |
| 36 |
void (*free_value)(void *), void *user_data, bool *deprecated); |
| 37 |
|
| 38 |
void c2_free_condition(c2_condition *lp, c2_userdata_free f); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
struct c2_state *c2_state_new(struct atom *atoms); |
| 45 |
void c2_state_free(struct c2_state *state); |
| 46 |
|
| 47 |
bool c2_state_is_property_tracked(struct c2_state *state, xcb_atom_t property); |
| 48 |
void c2_window_state_init(const struct c2_state *state, struct c2_window_state *window_state); |
| 49 |
void c2_window_state_destroy(const struct c2_state *state, struct c2_window_state *window_state); |
| 50 |
void c2_window_state_mark_dirty(const struct c2_state *state, |
| 51 |
struct c2_window_state *window_state, xcb_atom_t property, |
| 52 |
bool is_on_client); |
| 53 |
|
| 54 |
|
| 55 |
void c2_window_state_mark_dirty_for_client_change(const struct c2_state *state, |
| 56 |
struct c2_window_state *window_state); |
| 57 |
void c2_window_state_update(struct c2_state *state, struct c2_window_state *window_state, |
| 58 |
xcb_connection_t *c, xcb_window_t client_win, |
| 59 |
xcb_window_t frame_win); |
| 60 |
|
| 61 |
bool c2_match(struct c2_state *state, const struct win *w, |
| 62 |
const struct list_node *conditions, void **pdata); |
| 63 |
bool c2_match_one(const struct c2_state *state, const struct win *w, |
| 64 |
const c2_condition *condlst, void **pdata); |
| 65 |
|
| 66 |
bool c2_list_postprocess(struct c2_state *state, xcb_connection_t *c, struct list_node *list); |
| 67 |
|
| 68 |
void *c2_condition_get_data(const c2_condition *condition); |
| 69 |
|
| 70 |
void *c2_condition_set_data(c2_condition *condlist, void *data); |
| 71 |
|
| 72 |
|
| 73 |
const char *c2_condition_to_str(const c2_condition *); |
| 74 |
c2_condition *c2_condition_list_next(struct list_node *list, c2_condition *condition); |
| 75 |
c2_condition *c2_condition_list_prev(struct list_node *list, c2_condition *condition); |
| 76 |
c2_condition *c2_condition_list_entry(struct list_node *list); |
| 77 |
|
| 78 |
c2_condition *c2_new_true(struct list_node *list); |
| 79 |
|
| 80 |
|
| 81 |
#define c2_condition_list_foreach(list, i) \ |
| 82 |
for (c2_condition *i = \ |
| 83 |
list_is_empty((list)) ? NULL : c2_condition_list_entry((list)->next); \ |
| 84 |
i; i = c2_condition_list_next(list, i)) |
| 85 |
#define c2_condition_list_foreach_rev(list, i) \ |
| 86 |
for (c2_condition *i = \ |
| 87 |
list_is_empty((list)) ? NULL : c2_condition_list_entry((list)->prev); \ |
| 88 |
i; i = c2_condition_list_prev(list, i)) |
| 89 |
|
| 90 |
#define c2_condition_list_foreach_safe(list, i, n) \ |
| 91 |
for (c2_condition *i = \ |
| 92 |
list_is_empty((list)) ? NULL : c2_condition_list_entry((list)->next), \ |
| 93 |
*n = c2_condition_list_next(list, i); \ |
| 94 |
i; i = n, n = c2_condition_list_next(list, i)) |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
static inline void c2_list_free(struct list_node *list, c2_userdata_free f) { |
| 101 |
c2_condition_list_foreach_safe(list, i, ni) { |
| 102 |
c2_free_condition(i, f); |
| 103 |
} |
| 104 |
list_init_head(list); |
| 105 |
} |