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