A tiling window manager
at master 224 lines 6.9 kB view raw
1/* 2 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca> 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License as published by the Free 6 * Software Foundation; either version 2 of the License, or (at your option) 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 16 * Place, Suite 330, Boston, MA 02111-1307 USA. 17 */ 18 19#ifndef GLOBALS_H 20#define GLOBALS_H 21 22#include "data.h" 23 24/* codes used in the cmdret code in actions.c */ 25#define RET_SUCCESS 1 26#define RET_FAILURE 0 27 28#define FONT_HEIGHT(s) ((s)->xft_font->ascent + (s)->xft_font->descent) 29#define FONT_ASCENT(s) ((s)->xft_font->ascent) 30#define FONT_DESCENT(s) ((s)->xft_font->descent) 31 32#define MAX_FONT_WIDTH(f) (rp_font_width) 33 34#define WIN_EVENTS (StructureNotifyMask | PropertyChangeMask | \ 35 ColormapChangeMask | FocusChangeMask) 36 37/* 38 * EMPTY is used when a frame doesn't contain a window, or a window doesn't 39 * have a frame. Any time a field refers to the number of a 40 * window/frame/screen/etc, Use EMPTY to denote a lack there of. 41 */ 42#define EMPTY -1 43 44/* Possible values for defaults.window_list_style */ 45#define STYLE_ROW 0 46#define STYLE_COLUMN 1 47 48/* Possible values for defaults.win_name */ 49#define WIN_NAME_TITLE 0 50#define WIN_NAME_RES_CLASS 1 51#define WIN_NAME_RES_NAME 2 52 53/* Possible directions to traverse the completions list. */ 54#define COMPLETION_NEXT 0 55#define COMPLETION_PREVIOUS 1 56 57/* Font styles */ 58#define STYLE_NORMAL 0 59#define STYLE_INVERSE 1 60 61/* Whether or not we support xrandr */ 62extern int rp_have_xrandr; 63 64/* 65 * Each child process is stored in this list. spawn, creates a new entry in 66 * this list, the SIGCHLD handler sets child.terminated to be true and 67 * handle_signals in events.c processes each terminated process by printing a 68 * message saying the process ended and displaying it's exit code. 69 */ 70extern struct list_head rp_children; 71 72extern struct rp_defaults defaults; 73 74/* Cached font info. */ 75extern int rp_font_ascent, rp_font_descent, rp_font_width; 76 77/* The prefix key also known as the command character under screen. */ 78extern struct rp_key prefix_key; 79 80/* 81 * A list of mapped windows. These windows show up in the window list and have 82 * a number assigned to them. 83 */ 84extern struct list_head rp_mapped_window; 85 86/* 87 * A list of unmapped windows. These windows do not have a number assigned to 88 * them and are not visible/active. 89 */ 90extern struct list_head rp_unmapped_window; 91 92/* The list of screens. */ 93extern struct list_head rp_screens; 94extern rp_screen *rp_current_screen; 95extern rp_global_screen rp_glob_screen; 96 97extern Display *dpy; 98 99extern XEvent rp_current_event; 100 101extern Atom rp_selection; 102 103extern Atom wm_name; 104extern Atom wm_state; 105extern Atom wm_change_state; 106extern Atom wm_protocols; 107extern Atom wm_delete; 108extern Atom wm_take_focus; 109extern Atom wm_colormaps; 110 111/* TEXT atoms */ 112extern Atom xa_string; 113extern Atom xa_compound_text; 114extern Atom xa_utf8_string; 115 116/* netwm atoms. */ 117extern Atom _net_active_window; 118extern Atom _net_client_list; 119extern Atom _net_client_list_stacking; 120extern Atom _net_current_desktop; 121extern Atom _net_number_of_desktops; 122extern Atom _net_supported; 123extern Atom _net_workarea; 124extern Atom _net_wm_name; 125extern Atom _net_wm_pid; 126extern Atom _net_wm_state; 127#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ 128#define _NET_WM_STATE_ADD 1 /* add/set property */ 129#define _NET_WM_STATE_TOGGLE 2 /* toggle property */ 130extern Atom _net_wm_state_fullscreen; 131extern Atom _net_wm_window_type; 132extern Atom _net_wm_window_type_dialog; 133extern Atom _net_wm_window_type_dock; 134extern Atom _net_wm_window_type_splash; 135extern Atom _net_wm_window_type_tooltip; 136extern Atom _net_wm_window_type_utility; 137extern Atom _net_supporting_wm_check; 138 139/* 140 * When unmapping or deleting windows, it is sometimes helpful to ignore a bad 141 * window when attempting to clean the window up. This does just that when set 142 * to 1 143 */ 144extern int ignore_badwindow; 145 146/* Arguments passed at startup. */ 147extern char **myargv; 148 149/* Keeps track of which mod mask each modifier is under. */ 150extern struct modifier_info rp_modifier_info; 151 152/* 153 * nonzero if an alarm signal was raised. This means we should hide our 154 * popup windows. 155 */ 156extern int alarm_signalled; 157extern int kill_signalled; 158extern int hup_signalled; 159extern int chld_signalled; 160 161/* rudeness levels */ 162extern int rp_honour_transient_raise; 163extern int rp_honour_normal_raise; 164extern int rp_honour_transient_map; 165extern int rp_honour_normal_map; 166extern int rp_honour_vscreen_switch; 167 168/* Keep track of X11 error messages. */ 169extern char *rp_error_msg; 170 171/* Number sets for windows. */ 172extern struct numset *rp_window_numset; 173 174extern struct list_head rp_key_hook; 175extern struct list_head rp_switch_win_hook; 176extern struct list_head rp_switch_frame_hook; 177extern struct list_head rp_switch_screen_hook; 178extern struct list_head rp_switch_vscreen_hook; 179extern struct list_head rp_delete_window_hook; 180extern struct list_head rp_quit_hook; 181extern struct list_head rp_restart_hook; 182extern struct list_head rp_new_window_hook; 183extern struct list_head rp_title_changed_hook; 184 185extern struct rp_hook_db_entry rp_hook_db[]; 186 187void set_rp_window_focus(rp_window * win); 188void set_window_focus(Window window); 189 190extern struct numset *rp_frame_numset; 191 192/* Selection handling globals */ 193extern rp_xselection selection; 194void set_selection(char *txt); 195void set_nselection(char *txt, int len); 196char *get_selection(void); 197 198/* Wrapper font functions to support Xft */ 199 200XftFont *rp_get_font(rp_screen *s, char *font); 201void rp_clear_cached_fonts(rp_screen *s); 202void rp_draw_string(rp_screen *s, Drawable d, int style, int x, int y, 203 char *string, int length, char *font, char *color); 204int rp_text_width(rp_screen *s, char *string, int count, char *font); 205 206void check_child_procs(void); 207void chld_handler(int signum); 208void set_sig_handler(int sig, void (*action)(int)); 209void set_close_on_exec(int fd); 210void read_rc_file(FILE *file); 211const char *get_homedir(void); 212char *get_config_dir(void); 213void clean_up(void); 214 215void register_atom(Atom *a, char *name); 216int set_atom(Window w, Atom a, Atom type, unsigned long *val, 217 unsigned long nitems); 218int append_atom(Window w, Atom a, Atom type, unsigned long *val, 219 unsigned long nitems); 220unsigned long get_atom(Window w, Atom a, Atom type, unsigned long off, 221 unsigned long *ret, unsigned long nitems, unsigned long *left); 222void remove_atom(Window w, Atom a, Atom type, unsigned long remove); 223 224#endif