jcs ratpoison hax
1/* our datatypes and global variables
2 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca>
3 *
4 * This file is part of ratpoison.
5 *
6 * ratpoison is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * ratpoison is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this software; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307 USA
20 */
21
22#ifndef _RATPOISON_DATA_H
23#define _RATPOISON_DATA_H
24
25#include "linkedlist.h"
26#include "number.h"
27
28#include <X11/X.h>
29#include <X11/Xlib.h>
30#include <X11/Xutil.h>
31
32#ifdef USE_XFT_FONT
33#include <X11/Xft/Xft.h>
34#endif
35
36typedef struct rp_window rp_window;
37typedef struct rp_screen rp_screen;
38typedef struct rp_global_screen rp_global_screen;
39typedef struct rp_action rp_action;
40typedef struct rp_keymap rp_keymap;
41typedef struct rp_frame rp_frame;
42typedef struct rp_child_info rp_child_info;
43typedef struct rp_group rp_group;
44typedef struct rp_window_elem rp_window_elem;
45typedef struct rp_completions rp_completions;
46typedef struct rp_input_line rp_input_line;
47
48struct rp_frame
49{
50 int number;
51 int x, y, width, height;
52
53 /* The number of the window that is focused in this frame. */
54 int win_number;
55
56 /* For determining the last frame. */
57 int last_access;
58
59 /* Boolean that is set when a frame is
60 `dedicated' (a.k.a. glued) to one window. */
61 unsigned int dedicated;
62
63 struct list_head node;
64};
65
66struct rp_window
67{
68 rp_screen *scr;
69 Window w;
70 int state;
71 int last_access;
72 int named;
73
74 /* A number uniquely identifying this window. This is a different
75 number than the one given to it by the group it is in. This
76 number is used for internal purposes, whereas the group number is
77 what the user sees. */
78 int number;
79
80 /* Window name hints. */
81 char *user_name;
82 char *wm_name;
83 char *res_name;
84 char *res_class;
85
86 /* Dimensions */
87 int x, y, width, height, border;
88
89 /* WM Hints */
90 XSizeHints *hints;
91
92 /* Colormap */
93 Colormap colormap;
94
95 /* Is this a transient window? */
96 int transient;
97 Window transient_for;
98
99 /* Saved mouse position */
100 int mouse_x, mouse_y;
101
102 /* The alignment of the window. Decides to what side or corner the
103 window sticks to. */
104 int gravity;
105
106 /* A window can be visible inside a frame but not the frame's
107 current window. This keeps track of what frame the window was
108 mapped into. */
109 int frame_number;
110
111 /* Sometimes a window is intended for a certain frame. When a window
112 is mapped and this is >0 then use the frame (if it exists). */
113 int intended_frame_number;
114
115 struct list_head node;
116};
117
118struct rp_window_elem
119{
120 rp_window *win;
121 int number;
122 struct list_head node;
123};
124
125/* An rp_group is a group of windows. By default all windows are added
126 to the same group. But a new group can be created. All new windows
127 will be part of this new current group. The windows of any other
128 group may be visible in another frame, but will not show up in the
129 window list and will not be accessible with select, next, or
130 prev. These window navigation commands only navigate the current
131 group. */
132struct rp_group
133{
134 /* The name and number of this group. This is to allow the user to
135 quickly jump to the desired group. */
136 char *name;
137 int number;
138
139 /* For determining the last group. */
140 int last_access;
141
142 /* The list of windows participating in this group. */
143 struct list_head mapped_windows, unmapped_windows;
144
145 /* This numset is responsible for giving out numbers for each window
146 in the group. */
147 struct numset *numset;
148
149 /* This structure can exist in a list. */
150 struct list_head node;
151};
152
153struct rp_global_screen
154{
155 Window root;
156 unsigned long fg_color, bg_color, fw_color, bw_color; /* The pixel color. */
157
158 /* This numset is responsible for giving out numbers for each screen */
159 struct numset *numset;
160};
161
162struct xrandr_info {
163 int output;
164 int crtc;
165 int primary;
166 char *name;
167};
168
169struct rp_screen
170{
171 GC normal_gc, inverse_gc;
172 Window root, bar_window, key_window, input_window, frame_window, help_window;
173 int bar_is_raised;
174 int screen_num; /* Our screen number as dictated by X */
175 Colormap def_cmap;
176 Cursor rat;
177
178 /* Screen number, handled by rp_global_screen numset */
179 int number;
180
181 struct xrandr_info xrandr;
182
183 /* Here to abstract over the Xrandr vs X screens difference */
184 int left, top, width, height;
185
186 char *display_string;
187
188 /* A list of frames that may or may not contain windows. There should
189 always be one in the list. */
190 struct list_head frames;
191
192 /* Keep track of which numbers have been given to frames. */
193 struct numset *frames_numset;
194
195 /* The number of the currently focused frame. One for each screen so
196 when you switch screens the focus doesn't get frobbed. */
197 int current_frame;
198
199 /* This structure can exist in a list. */
200 struct list_head node;
201
202 /* Used by sfrestore */
203 struct sbuf *scratch_buffer;
204
205#ifdef USE_XFT_FONT
206 XftFont *xft_font;
207 XftColor xft_fg_color, xft_bg_color;
208#endif
209};
210
211struct rp_action
212{
213 KeySym key;
214 unsigned int state;
215 char *data; /* misc data to be passed to the function */
216/* void (*func)(void *); */
217};
218
219struct rp_keymap
220{
221 char *name;
222 rp_action *actions;
223 int actions_last;
224 int actions_size;
225
226 /* This structure can be part of a list. */
227 struct list_head node;
228};
229
230struct rp_key
231{
232 KeySym sym;
233 unsigned int state;
234};
235
236struct rp_defaults
237{
238 /* Default positions for new normal windows, transient windows, and
239 normal windows with maxsize hints. */
240 int win_gravity;
241 int trans_gravity;
242 int maxsize_gravity;
243
244 int input_window_size;
245 int window_border_width;
246 int only_border;
247
248 int bar_x_padding;
249 int bar_y_padding;
250 int bar_location;
251 int bar_timeout;
252 int bar_border_width;
253 int bar_in_padding;
254
255 int frame_indicator_timeout;
256 int frame_resize_unit;
257
258 int padding_left;
259 int padding_right;
260 int padding_top;
261 int padding_bottom;
262
263 XFontSet font;
264 char *font_string;
265
266 char *fgcolor_string;
267 char *bgcolor_string;
268 char *fwcolor_string;
269 char *bwcolor_string;
270
271 int wait_for_key_cursor;
272
273 char *window_fmt;
274 char *info_fmt;
275
276 /* Which name to use: wm_name, res_name, res_class. */
277 int win_name;
278
279 int startup_message;
280
281 /* Decides whether the window list is displayed in a row or a
282 column. */
283 int window_list_style;
284
285 /* Pointer warping toggle. */
286 int warp;
287
288 int history_size;
289 /* remove older history when adding the same again */
290 int history_compaction;
291 /* expand ! when compiled with libhistory */
292 int history_expansion;
293
294 char *frame_selectors;
295
296 /* How many frame sets to remember when undoing. */
297 int maxundos;
298
299 /* The name of the top level keymap */
300 char *top_kmap;
301
302 /* Frame indicator format */
303 char *frame_fmt;
304};
305
306/* Information about a child process. */
307struct rp_child_info
308{
309 /* The command that was executed. */
310 char *cmd;
311
312 /* PID of the process. */
313 int pid;
314
315 /* Return status when the child process finished. */
316 int status;
317
318 /* When this is != 0 then the process finished. */
319 int terminated;
320
321 /* what was current when it was launched? */
322 rp_group *group;
323 rp_frame *frame;
324 rp_screen *screen;
325
326 /* Non-zero when the pid has mapped a window. This is to prevent
327 every window the program opens from getting mapped in the frame
328 it was launched from. Only the first window should do this. */
329 int window_mapped;
330
331 /* This structure can exist in a list. */
332 struct list_head node;
333};
334
335/* These defines should be used to specify the modifier mask for keys
336 and they are translated into the X11 modifier mask when the time
337 comes to compare modifier masks. */
338#define RP_SHIFT_MASK 1
339#define RP_CONTROL_MASK 2
340#define RP_META_MASK 4
341#define RP_ALT_MASK 8
342#define RP_SUPER_MASK 16
343#define RP_HYPER_MASK 32
344
345struct modifier_info
346{
347/* unsigned int mode_switch_mask; */
348 unsigned int meta_mod_mask;
349 unsigned int alt_mod_mask;
350 unsigned int super_mod_mask;
351 unsigned int hyper_mod_mask;
352
353 /* Keep track of these because they mess up the grab and should be
354 ignored. */
355 unsigned int num_lock_mask;
356 unsigned int scroll_lock_mask;
357};
358
359typedef struct list_head *(*completion_fn)(char *string);
360
361/*
362 BASIC: The completion shall begin with the same characters as the partial
363 string. Case is ignored.
364
365 SUBSTRING: The partial string shall be a subpart of the completion. Case
366 is ignored.
367*/
368enum completion_styles
369{
370 BASIC,
371 SUBSTRING
372};
373
374struct rp_completions
375{
376 /* A pointer to the partial string that is being completed. We need
377 to store this so that the user can cycle through all possible
378 completions. */
379 char *partial;
380
381 /* A pointer to the string that was last matched string. Used to
382 keep track of where we are in the completion list. */
383 struct sbuf *last_match;
384
385 /* A list of sbuf's which are possible completions. */
386 struct list_head completion_list;
387
388 /* The function that generates the completions. */
389 completion_fn complete_fn;
390
391 /* virgin = 1 means no completions have been attempted on the input
392 string. */
393 unsigned short int virgin;
394
395 /* The completion style used to perform string comparisons */
396 enum completion_styles style;
397};
398
399struct rp_input_line
400{
401 char *buffer;
402 char *prompt;
403 char *saved;
404 size_t position;
405 size_t length;
406 size_t size;
407 rp_completions *compl;
408 Atom selection;
409 int history_id;
410};
411
412/* The hook dictionary. */
413struct rp_hook_db_entry
414{
415 char *name;
416 struct list_head *hook;
417};
418
419typedef struct rp_xselection rp_xselection;
420struct rp_xselection
421{
422 char *text;
423 int len;
424};
425
426#endif /* _RATPOISON_DATA_H */