-
Notifications
You must be signed in to change notification settings - Fork 3
/
ruler.h
141 lines (109 loc) · 2.59 KB
/
ruler.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __RULER_H
#define __RULER_H
#include <xcb/xcb_ewmh.h>
#include <regex.h>
#define WINDOW_TYPE_STRING_LENGTH 110
#define REGEX_FLAGS REG_EXTENDED | REG_NOSUB
#define ENV_VARIABLE "RULER_WID"
#define DEBUG 0
#ifndef NAME
#define NAME "ruler"
#endif
#ifndef VERSION
#define VERSION "-1"
#endif
enum {
ATOM_WM_NAME,
ATOM_WM_CLASS,
ATOM_WM_ROLE,
ATOM_WM_TYPE,
NR_ATOMS
};
static const char *atom_names[] = {
"WM_NAME",
"WM_CLASS",
"WM_WINDOW_ROLE",
"_NET_WM_WINDOW_TYPE"
};
#define DMSG(fmt, ...) if (_debug) { fprintf(stderr, fmt, ##__VA_ARGS__); }
typedef char * command_t;
enum criterion {
CRIT_CLASS,
CRIT_INSTANCE,
CRIT_TYPE,
CRIT_NAME,
CRIT_ROLE
};
struct descriptor {
enum criterion criterion;
char *str;
regex_t *reg;
};
struct list {
void *n;
struct list *next;
struct list *prev;
};
struct block {
/* list of descriptors */
struct list *d;
command_t c;
};
struct win_props {
char *class;
char *instance;
char *type;
char *name;
char *role;
};
struct conf {
int case_insensitive;
char *shell;
int catch_override_redirect;
int exec_on_prop_change;
int exec_on_map;
};
void yyerror(const char *);
int yywrap(void);
int yylex(void);
int yyparse(void);
void yyrestart(FILE *);
void print_usage(const char *, int);
void print_version(void);
char * strip_quotes(char *);
struct descriptor * new_descriptor(char *, char *);
void desc(char *, char *);
void descriptor_free(struct descriptor *);
void list_add(struct list **, void *node);
void list_remove(struct list **, struct list *);
void list_free(struct list **);
command_t new_command(char *);
void comm(char *);
struct block * new_block(struct list *, command_t);
void block(void);
void block_free(struct block *);
struct win_props * new_win_props(void);
void free_win_props(struct win_props *);
void print_win_props(struct win_props *);
void init_ewmh(void);
xcb_atom_t get_atom(const char *);
void populate_allowed_atoms(void);
char * window_type_to_string(xcb_ewmh_get_atoms_reply_t *);
char * get_string_prop(xcb_window_t, xcb_atom_t, int);
struct win_props * get_props(xcb_window_t);
int match_props(struct win_props *, struct list *);
void find_matching_blocks(struct win_props *, struct list *, struct list **);
void execute(char **);
void spawn(char *, command_t);
void run_command(char *shell, command_t, int);
void execute_matching_block(struct win_props *, struct list *);
void register_events(void);
void set_environ(xcb_window_t);
void handle_events(void);
int is_new_window(xcb_window_t);
void cleanup(void);
void init_conf(void);
void handle_sig(int);
int parse_file(char *);
void reload_config(void);
#endif