jcs ratpoison hax
at oldjcs 426 lines 10 kB view raw
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_action rp_action; 39typedef struct rp_keymap rp_keymap; 40typedef struct rp_frame rp_frame; 41typedef struct rp_child_info rp_child_info; 42typedef struct rp_group rp_group; 43typedef struct rp_virtual rp_virtual; 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_virtual 154{ 155 char *fconfig; 156 int number; 157 158 struct list_head node; 159}; 160 161struct rp_screen 162{ 163 GC normal_gc, inverse_gc; 164 Window root, bar_window, key_window, input_window, frame_window, help_window, 165 fake_root_window; 166 int bar_is_raised; 167 int screen_num; /* Our screen number as dictated my X */ 168 int xine_screen_num; /* Our screen number for the Xinerama extension */ 169 Colormap def_cmap; 170 Cursor rat; 171 unsigned long fg_color, bg_color, fw_color, bw_color, fakeroot_color; /* The pixel color. */ 172 173 /* Here to abstract over the Xinerama vs X screens difference */ 174 int left, top, width, height; 175 176 char *display_string; 177 178 /* A list of frames that may or may not contain windows. There should 179 always be one in the list. */ 180 struct list_head frames; 181 182 /* Keep track of which numbers have been given to frames. */ 183 struct numset *frames_numset; 184 185 /* The number of the currently focused frame. One for each screen so 186 when you switch screens the focus doesn't get frobbed. */ 187 int current_frame; 188 189#ifdef USE_XFT_FONT 190 XftFont *xft_font; 191 XftColor xft_fg_color, xft_bg_color; 192#endif 193}; 194 195struct rp_action 196{ 197 KeySym key; 198 unsigned int state; 199 char *data; /* misc data to be passed to the function */ 200/* void (*func)(void *); */ 201}; 202 203struct rp_keymap 204{ 205 char *name; 206 rp_action *actions; 207 int actions_last; 208 int actions_size; 209 210 /* This structure can be part of a list. */ 211 struct list_head node; 212}; 213 214struct rp_key 215{ 216 KeySym sym; 217 unsigned int state; 218}; 219 220struct rp_defaults 221{ 222 /* Default positions for new normal windows, transient windows, and 223 normal windows with maxsize hints. */ 224 int win_gravity; 225 int trans_gravity; 226 int maxsize_gravity; 227 228 int input_window_size; 229 int window_border_width; 230 int gap; 231 int fakeroot; 232 233 int bar_x_padding; 234 int bar_y_padding; 235 int bar_location; 236 int bar_timeout; 237 int bar_border_width; 238 int bar_in_padding; 239 int bar_sticky; 240 241 int frame_indicator_timeout; 242 int frame_resize_unit; 243 244 int padding_left; 245 int padding_right; 246 int padding_top; 247 int padding_bottom; 248 249 int screen_width; 250 int screen_height; 251 252 XFontSet font; 253 char *font_string; 254 int utf8_locale; 255 256 char *fgcolor_string; 257 char *bgcolor_string; 258 char *fwcolor_string; 259 char *bwcolor_string; 260 char *fakerootcolor_string; 261 262 int wait_for_key_cursor; 263 264 char *window_fmt; 265 char *info_fmt; 266 267 /* Which name to use: wm_name, res_name, res_class. */ 268 int win_name; 269 270 int startup_message; 271 272 /* Decides whether the window list is displayed in a row or a 273 column. */ 274 int window_list_style; 275 276 /* Pointer warping toggle. */ 277 int warp; 278 279 int history_size; 280 /* remove older history when adding the same again */ 281 int history_compaction; 282 /* expand ! when compiled with libhistory */ 283 int history_expansion; 284 285 char *frame_selectors; 286 287 /* How many frame sets to remember when undoing. */ 288 int maxundos; 289 290 /* The name of the top level keymap */ 291 char *top_kmap; 292 293 /* Frame indicator format */ 294 char *frame_fmt; 295 296 /* Number of virtual workspaces */ 297 int virtuals; 298 299 /* Whether to ignore window size hints */ 300 int ignorehints; 301 302 /* Resize indicator format */ 303 char *resize_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 */