1 #ifndef AS_STYLE_H 2 #define AS_STYLE_H 3 4 #include "afterstep.h" 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 struct wild_reg_exp; 11 12 /* we clean up flags usage in style and use : 13 * set_flags/flags pair instead of on_flags/off_flags 14 */ 15 /* this are flags defining that particular value is set and enable/disabled */ 16 #define STYLE_ICON (1 << 0) /* also goes into style->icon_file */ 17 #define STYLE_STARTUP_DESK (1 << 1) /* also goes into style->Desk */ 18 #define STYLE_BORDER_WIDTH (1 << 2) /* style->border_width */ 19 #define STYLE_HANDLE_WIDTH (1 << 3) /* style->resize_width */ 20 #define STYLE_DEFAULT_GEOMETRY (1 << 4) /* to override PPosition's geometry */ 21 #define STYLE_VIEWPORTX (1 << 5) /* style->ViewportX */ 22 #define STYLE_VIEWPORTY (1 << 6) /* style->ViewportY */ 23 #define STYLE_GRAVITY (1 << 7) /* if user wants us to override gravity from WM_NORMAL_HINTS */ 24 #define STYLE_LAYER (1 << 8) /* style->layer - layer is defined */ 25 #define STYLE_FRAME (1 << 9) /* style->frame - frame is defined */ 26 #define STYLE_WINDOWBOX (1 << 10) /* style->windowbox - windowbox is defined */ 27 #define STYLE_WINDOW_OPACITY (1 << 11) /* style->window_opacity - opacity of the window is defined */ 28 29 30 /* this are pure flags */ 31 #define STYLE_PAGER (1 << 4) 32 #define STYLE_IGNORE_RESTACK (1 << 5) /* if set - client will not be able to rise/lower 33 the window */ 34 #define STYLE_FULLSCREEN (1 << 6) 35 #define STYLE_KDE_HINTS (1 << 7) /* if set - then we should honor KDE Hints */ 36 #define STYLE_CURRENT_VIEWPORT (1 << 8) /* Ignore ConfigRequests for the client */ 37 #define STYLE_IGNORE_CONFIG (1 << 9) /* Ignore ConfigRequests for the client */ 38 #define STYLE_LONG_LIVING (1 << 10) 39 #define STYLE_STICKY (1 << 11) 40 #define STYLE_TITLE (1 << 12) 41 #define STYLE_CIRCULATE (1 << 13) 42 #define STYLE_WINLIST (1 << 14) 43 #define STYLE_START_ICONIC (1 << 15) 44 #define STYLE_ICON_TITLE (1 << 16) 45 #define STYLE_FOCUS (1 << 17) 46 #define STYLE_AVOID_COVER (1 << 18) 47 #define STYLE_VERTICAL_TITLE (1 << 19) /* if this window has a vertical titlebar */ 48 #define STYLE_HANDLES (1 << 20) 49 #define STYLE_PPOSITION (1 << 21) /* if set - then we should honor PPosition */ 50 #define STYLE_GROUP_HINTS (1 << 22) /* if set - then we should use Group Hint for initial placement */ 51 #define STYLE_TRANSIENT_HINTS (1 << 23) /* if set - then we should use Transient Hint for initial placement */ 52 #define STYLE_MOTIF_HINTS (1 << 24) /* if set - then we should honor Motif Hints */ 53 #define STYLE_GNOME_HINTS (1 << 25) /* if set - then we should honor Gnome Hints */ 54 #define STYLE_EXTWM_HINTS (1 << 26) /* if set - then we should honor Extended WM Hints */ 55 #define STYLE_XRESOURCES_HINTS (1 << 27) /* if set - then we should honor data from .XDefaults */ 56 #define STYLE_FOCUS_ON_MAP (1 << 28) /* if set - window will be focused as soon as its mapped */ 57 58 59 /* the following is needed for MATCH_ enum - see styledb.c for more */ 60 #define STYLE_MYSTYLES (1 << 29) /* */ 61 #define STYLE_BUTTONS (1 << 30) /* */ 62 #define STYLE_FLAGS (1 << 31) /* */ 63 64 #define STYLE_DEFAULTS (STYLE_PAGER | STYLE_TITLE|STYLE_CIRCULATE|STYLE_WINLIST| \ 65 STYLE_FOCUS|STYLE_FOCUS_ON_MAP|STYLE_HANDLES| \ 66 STYLE_ICON_TITLE|STYLE_PPOSITION|STYLE_GROUP_HINTS| \ 67 STYLE_TRANSIENT_HINTS|STYLE_MOTIF_HINTS|STYLE_KDE_HINTS| \ 68 STYLE_GNOME_HINTS|STYLE_EXTWM_HINTS|STYLE_LONG_LIVING) 69 70 /************************************************************************************ 71 * Data structure definitions : 72 ************************************************************************************/ 73 /* 74 * This one is used to read up data from the config file/ save data into config file 75 * ( basically just an interface with libASConfig ) 76 */ 77 typedef struct name_list 78 { 79 struct name_list *next; /* pointer to the next list elemaent structure */ 80 char *name; /* the name of the window */ 81 82 /* new approach : 83 * If flag is set in both set_flags and flags 84 - then it is present in config and value is On 85 * If flag is set in set_flags but not in flags 86 - then it is present in config and value is Off 87 * if flag is not set in set_flags 88 - then it is not present in config and value is Undefined 89 */ 90 unsigned long set_flags; 91 unsigned long flags; 92 /* flag that defines which of the following data members are set in config: */ 93 unsigned long set_data_flags; 94 95 char *icon_file; /* icon name */ 96 ASGeometry default_geometry ; 97 int Desk; /* Desktop number */ 98 int layer; /* layer number */ 99 int ViewportX, ViewportY; 100 101 int border_width; 102 int resize_width; 103 int gravity ; 104 105 char *window_styles[BACK_STYLES]; 106 char *frame_name; 107 char *windowbox_name; 108 109 int window_opacity; 110 111 unsigned long on_buttons; 112 unsigned long off_buttons; 113 } 114 name_list; 115 116 /* 117 * this is somewhat compiled/preprocessed version, suitable for database storin, 118 * and searching through: 119 */ 120 typedef struct ASDatabaseRecord 121 { 122 unsigned long magic ; /* magic number identifying valid record */ 123 124 struct wild_reg_exp *regexp ; 125 unsigned long set_flags; /* (set_flags&flags) will get you flags that are ON */ 126 unsigned long flags; /* (set_flags&(~flags)) will get you flags that are OFF */ 127 unsigned long set_buttons; /* (set_buttons&buttons) will get you buttons that are ON */ 128 unsigned long buttons; /* (set_buttons&(~buttons)) will get you buttons that are OFF */ 129 unsigned long set_data_flags; /* flag that defines which of the following data members are set in config: */ 130 ASGeometry default_geometry ; 131 int desk; /* Startup Desktop number */ 132 int layer; /* Startup layer number */ 133 int viewport_x, viewport_y; /* Startup viewport */ 134 int border_width; 135 int resize_width; 136 int gravity; 137 138 char *icon_file; 139 char *frame_name; 140 char *windowbox_name; 141 int window_opacity; 142 143 char *window_styles[BACK_STYLES]; 144 Bool own_strings ; 145 146 }ASDatabaseRecord; 147 148 typedef struct ASDatabase 149 { 150 size_t allocated_num ; 151 152 ASDatabaseRecord *styles_table ;/* list of all available styles excluding default */ 153 size_t styles_num ; /* number of entries in above table */ 154 size_t default_styles_idx ; /* number of entries in above table */ 155 156 ASDatabaseRecord style_default;/* this one is not included in above table to speed up search */ 157 158 int *match_list ; /* indexes of matched styles in last search (-1 default style)*/ 159 }ASDatabase; 160 161 /************************************************************************************ 162 * This is the high level interface that should be used by application to 163 * sort through and find matches in the Database : 164 ************************************************************************************/ 165 ASDatabaseRecord *make_asdb_record ( name_list * nl, struct wild_reg_exp *regexp, 166 ASDatabaseRecord *reusable_memory ); 167 /* NULL terminated list of names/aliases sorted in order of descending importance */ 168 ASDatabaseRecord *fill_asdb_record (ASDatabase *db, char **names, 169 ASDatabaseRecord *reusable_memory, Bool dup_strings); 170 void destroy_asdb_record(ASDatabaseRecord *rec, Bool reusable); 171 ASDatabaseRecord *get_asdb_record (ASDatabase * db, int index); 172 Bool is_default_asdb_record( ASDatabase * db, ASDatabaseRecord *db_rec ); 173 174 175 ASDatabase* build_asdb( name_list *nl ); 176 void destroy_asdb( ASDatabase **db ); 177 /* 178 * Note that Database cannot be build on stack 179 * But Record can. Make sure not to destroy something you should not. 180 */ 181 182 void print_asdb_matched_rec( stream_func func, void *stream, ASDatabase *db, ASDatabaseRecord *db_rec ); 183 void print_asdb( stream_func func, void *stream, ASDatabase *db ); 184 void print_asdb_match_list( stream_func func, void *stream, ASDatabase *db ); 185 void print_asdb_record( stream_func func, void *stream, ASDatabaseRecord *db_rec, const char *prompt ); 186 187 /************************************************************************************ 188 * this are low level functions typically used by configuration management facilities 189 * like ASCP and such : 190 ************************************************************************************/ 191 void style_init (name_list * nl); 192 name_list *style_new (name_list ** tail); 193 /* this one just copies all the pointers, without allocating any more memory */ 194 void style_copy (name_list * to, name_list * from); 195 /* this one actually allocates memory for copies of the strings : */ 196 name_list *style_dup (name_list * from); 197 void style_delete (name_list * style, name_list ** phead); 198 void delete_name_list ( name_list **head); 199 200 /* This one will have to go : */ 201 struct ASWindow; 202 void style_fill_by_name (name_list * nl, struct ASWindow *t); 203 204 #ifdef __cplusplus 205 } 206 #endif 207 208 209 210 #endif /* AS_STYLE_H */ 211