-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.h
287 lines (232 loc) · 5.33 KB
/
types.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#ifndef COMMONDEFS_H
#define COMMONDEFS_H
#include <unistd.h>
#include <stdint.h>
#include "events.h"
typedef enum {
MB_LEFT,
MB_RIGHT,
MB_CENTER,
MB_SCROLLUP,
MB_SCROLLDOWN,
MB__dummy_,
MB__MAX_ = MB__dummy_ - 1,
} mousebutton_t;
/* Platform-independent internal representation of a keyboard key */
typedef uint32_t keycode_t;
/* Whether a given keystroke/mouse-click is a press or release */
typedef enum {
PR_PRESS = 1,
PR_RELEASE,
} pressrel_t;
/* Different states a remote connection can be in at any given time */
typedef enum {
CS_NEW = 0,
CS_SETTINGUP,
CS_FAILED,
CS_PERMFAILED,
CS_CONNECTED,
} connstate_t;
typedef enum {
NO_DIR = -1,
LEFT = 0,
RIGHT,
UP,
DOWN,
NUM_DIRECTIONS,
} direction_t;
#define for_each_direction(d) for (d = LEFT; d < NUM_DIRECTIONS; d++)
typedef uint32_t dirmask_t;
#define LEFTMASK (1U << LEFT)
#define RIGHTMASK (1U << RIGHT)
#define UPMASK (1U << UP)
#define DOWNMASK (1U << DOWN)
#define ALLDIRS_MASK (LEFTMASK|RIGHTMASK|UPMASK|DOWNMASK)
/* Configuration options used to set command-line arguments when invoking ssh */
struct ssh_config {
char* remoteshell;
int port;
char* bindaddr;
char* identityfile;
char* username;
char* remotecmd;
};
/* Types of "edge events" (mouse pointer arriving at or leaving a screen edge) */
typedef enum {
EE_DEPART,
EE_ARRIVE,
} edgeevent_t;
/* How long a history of edge events we track */
#define EDGESTATE_HISTLEN 8
/*
* Circular buffer containing recent history of mouse-pointer
* arrival/departure events at a given screen edge, in strict alternation
*/
struct edge_state {
uint64_t event_times[EDGESTATE_HISTLEN];
edgeevent_t last_evtype;
/* Where in the circular buffer the last event is */
unsigned int evidx;
};
#include "msgchan.h"
#include "message.h"
#include "kvmap.h"
struct node {
char* name;
/* Bounds of the node's effective logical screen */
struct rectangle dimensions;
/* Neighboring node in each direction */
struct node* neighbors[NUM_DIRECTIONS];
/* History of mouse arrivals/departures at each screen edge */
struct edge_state edgehist[NUM_DIRECTIONS];
/* Bitmask of which screen edges the mouse pointer is currently at */
dirmask_t edgemask;
/* Pointer to the remote info for this node (NULL for master) */
struct remote* remote;
};
struct remote {
struct node node;
/* Used for graph topology check */
int reachable;
char* hostname;
/* how to invoke ssh to this remote */
struct ssh_config sshcfg;
/* miscellaneous extra parameters from config file */
struct kvmap* params;
/* connection state */
connstate_t state;
/* pid of the ssh process we're connected via */
pid_t sshpid;
/*
* How many times (since the last successful one) this remote's
* connection has failed.
*/
int failcount;
/* timer for determing when to next attempt a reconnect */
timer_ctx_t reconnect_timer;
/* multiplier for scroll-wheel events (some systems scroll "slower" than others) */
int scrollmult;
/* msgchan by which the master exchanges messages with this remote */
struct msgchan msgchan;
/* for linking into a list of remotes */
struct remote* next;
/* whether enabled or disabled by -e/-d flags */
int enabled;
};
/*
* A reference to a node; starts as a string (the node's name) after
* config-file parsing and then gets resolved to an actual node during
* setup/initialization.
*/
struct noderef {
enum {
/* initial state before a name gets resolved to a node */
NT_TMPNAME,
NT_NODE,
} type;
union {
char* name;
struct node* node;
};
};
/* Things that can go in a 'focus' hotkey action. */
struct focus_target {
enum {
FT_DIRECTION,
FT_NODE,
FT_PREVIOUS,
} type;
union {
direction_t dir;
struct noderef nr;
};
};
/* Actions that can be assigned to a hotkey */
struct action {
enum {
AT_FOCUS,
AT_CLEARCLIPBOARD,
AT_RECONNECT,
AT_HALT_RECONNECTS,
AT_QUIT,
AT_STEP_LOGLEVEL,
} type;
union {
struct focus_target target;
int loglevel_delta;
};
};
/* A user-configured hotkey */
struct hotkey {
/* Platform-dependent string encoding the key(s) */
char* key_string;
/* Action to perform when pressed */
struct action action;
/* for linking into a list of hotkeys */
struct hotkey* next;
};
/* Different ways focus can be visually indicated */
struct focus_hint {
enum {
FH_NONE = 0,
FH_DIM_INACTIVE,
FH_FLASH_ACTIVE,
} type;
float brightness;
uint64_t duration;
int fade_steps;
};
/* Configurable ways of switching focus with the mouse */
struct mouse_switch {
enum {
MS_NONE = 0,
MS_MULTITAP,
} type;
int num;
uint64_t window;
};
/* A link in the node topology graph */
struct link {
struct {
struct noderef nr;
direction_t dir;
} a, b;
struct link* next;
};
/* Options for log message destination */
struct logfile {
enum {
LF_STDERR = 0,
LF_FILE,
LF_SYSLOG,
LF_NONE,
} type;
char* path;
};
struct config {
char* remote_shell;
char* bind_address;
struct remote* remotes;
struct link* topology;
struct hotkey* hotkeys;
struct {
struct logfile file;
unsigned int level;
} log;
struct {
int max_tries;
uint64_t max_interval;
} reconnect;
struct focus_hint focus_hint;
struct mouse_switch mouseswitch;
enum {
NS_NO,
NS_YES,
NS_HOTKEYONLY,
} show_nullswitch;
/* default SSH settings, optionally overridden per-remote */
struct ssh_config ssh_defaults;
int use_private_ssh_agent;
struct node master;
};
#endif /* COMMONDEFS_H */