-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcoma.h
executable file
·231 lines (190 loc) · 6.1 KB
/
coma.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
* Copyright (c) 2019 Joris Vink <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __H_COMA_H
#define __H_COMA_H
#include <sys/queue.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#define errno_s strerror(errno)
#define COMA_VERSION "1.2"
#define COMA_WM_FONT "fixed:pixelsize=13:style=bold"
#define COMA_TERMINAL "xterm"
#define COMA_ACTION_PREFIX "cmd:"
#define COMA_ACTION_SHELL_PREFIX "cmd_shell:"
#define COMA_ACTION_NOHOLD_PREFIX "cmd_nohold:"
#define COMA_ACTION_PREFIX_LEN (sizeof(COMA_ACTION_PREFIX) - 1)
#define COMA_ACTION_SHELL_PREFIX_LEN (sizeof(COMA_ACTION_SHELL_PREFIX) - 1)
#define COMA_ACTION_NOHOLD_PREFIX_LEN (sizeof(COMA_ACTION_NOHOLD_PREFIX) - 1)
#define COMA_LOG_FILE ".coma.log"
#define COMA_MOD_KEY ControlMask
#define COMA_PREFIX_KEY XK_t
#define COMA_FRAME_LAYOUT_DEFAULT 1
#define COMA_FRAME_LAYOUT_SMALL_LARGE 2
#define COMA_FRAME_LAYOUT_SMALL_DUAL 3
#define COMA_FRAME_BORDER 5
#define COMA_FRAME_GAP 20
#define COMA_FRAME_BAR 35
#define COMA_FRAME_WIDTH 484
#define COMA_SHELL_ARGV 64
struct frame;
#define COMA_CLIENT_HIDDEN 0x0001
struct client {
u_int32_t id;
u_int32_t pos;
u_int32_t prev;
u_int32_t flags;
Window window;
struct frame *frame;
char *tag;
char *cmd;
char *pwd;
char *host;
char *status;
u_int16_t w;
u_int16_t h;
u_int16_t x;
u_int16_t y;
u_int16_t bw;
u_int16_t fbo;
u_int16_t fbw;
TAILQ_ENTRY(client) list;
TAILQ_ENTRY(client) glist;
};
TAILQ_HEAD(client_list, client);
#define COMA_FRAME_INLIST 0x0001
#define COMA_FRAME_ZOOMED 0x0002
struct frame {
u_int32_t id;
int flags;
int screen;
Window bar;
Visual *visual;
Colormap colormap;
XftDraw *xft_draw;
u_int16_t w;
u_int16_t h;
u_int16_t x;
u_int16_t y;
u_int16_t orig_w;
u_int16_t orig_h;
u_int16_t orig_x;
u_int16_t orig_y;
struct client *focus;
struct client_list clients;
struct frame *split;
TAILQ_ENTRY(frame) list;
};
TAILQ_HEAD(frame_list, frame);
extern Display *dpy;
extern XftFont *font;
extern struct client_list clients;
extern int restart;
extern char *homedir;
extern char myhost[256];
extern unsigned int prefix_mod;
extern KeySym prefix_key;
extern char *terminal;
extern char *font_name;
extern int frame_count;
extern int frame_layout;
extern u_int16_t frame_gap;
extern u_int16_t frame_bar;
extern u_int16_t frame_width;
extern u_int16_t frame_height;
extern int frame_offset;
extern u_int16_t frame_border;
extern u_int16_t screen_width;
extern u_int16_t screen_height;
extern struct frame *frame_popup;
extern struct frame *frame_active;
extern struct client *client_active;
extern int client_discovery;
extern volatile sig_atomic_t sig_recv;
extern Atom atom_frame_id;
extern Atom atom_client_pos;
extern Atom atom_client_act;
extern Atom atom_net_wm_pid;
extern Atom atom_client_visible;
void fatal(const char *, ...);
void coma_log(const char *, ...);
void coma_reap(void);
void coma_command(char *);
void coma_execute(char **);
char *coma_program_path(void);
void coma_spawn_terminal(void);
void coma_config_parse(const char *);
int coma_split_arguments(char *, char **, size_t);
int coma_split_string(char *, const char *, char **, size_t);
void *coma_malloc(size_t);
void *coma_calloc(size_t, size_t);
void coma_wm_run(void);
void coma_wm_init(void);
void coma_wm_setup(void);
XftColor *coma_wm_color(const char *);
void coma_wm_register_prefix(Window);
int coma_wm_register_action(const char *, KeySym);
void coma_wm_property_write(Window, Atom, u_int32_t);
int coma_wm_property_read(Window, Atom, u_int32_t *);
int coma_wm_register_color(const char *, const char *);
struct frame *coma_frame_lookup(u_int32_t);
void coma_frame_init(void);
void coma_frame_prev(void);
void coma_frame_next(void);
void coma_frame_zoom(void);
void coma_frame_setup(void);
void coma_frame_split(void);
void coma_frame_merge(void);
void coma_frame_cleanup(void);
void coma_frame_bar_sort(void);
void coma_frame_popup_show(void);
void coma_frame_popup_hide(void);
void coma_frame_split_next(void);
void coma_frame_select_any(void);
void coma_frame_client_prev(void);
void coma_frame_client_next(void);
void coma_frame_bars_create(void);
void coma_frame_bars_update(void);
void coma_frame_popup_toggle(void);
void coma_frame_update_titles(void);
void coma_frame_layout(const char *);
void coma_frame_select_id(u_int32_t);
void coma_frame_client_move_left(void);
void coma_frame_client_move_right(void);
void coma_frame_register(struct frame *);
void coma_frame_focus(struct frame *, int);
void coma_frame_bar_update(struct frame *);
void coma_frame_bar_click(Window, u_int16_t);
void coma_frame_mouseover(u_int16_t, u_int16_t);
struct frame *coma_frame_create(u_int16_t, u_int16_t, u_int16_t, u_int16_t);
void coma_client_init(void);
void coma_client_create(Window);
void coma_client_kill_active(void);
void coma_client_map(struct client *);
void coma_client_hide(struct client *);
void coma_client_focus(struct client *);
void coma_client_unhide(struct client *);
void coma_client_adjust(struct client *);
void coma_client_destroy(struct client *);
void coma_client_update_title(struct client *);
void coma_client_warp_pointer(struct client *);
void coma_client_send_configure(struct client *);
struct client *coma_client_find(Window);
struct client *coma_frame_find_client(Window);
#endif