1 /********************************************************************** 2 * 3 * Codes for afterstep builtins 4 * 5 **********************************************************************/ 6 7 #ifndef _FUNCTIONS_ 8 #define _FUNCTIONS_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 15 struct ASHashTable; 16 struct TermDef; 17 struct ASImage; 18 19 typedef enum FunctionCode{ 20 F_NOP = 0, 21 F_TITLE, 22 F_BEEP, 23 F_QUIT, 24 F_RESTART, 25 F_SYSTEM_SHUTDOWN, 26 F_LOGOUT, 27 F_QUIT_WM, 28 F_SUSPEND, 29 F_HIBERNATE, 30 F_REFRESH, 31 #ifndef NO_VIRTUAL 32 F_SCROLL, 33 F_GOTO_PAGE, 34 F_TOGGLE_PAGE, 35 #endif 36 F_MOVECURSOR, 37 F_WARP_F, 38 F_WARP_B, 39 F_WAIT, 40 F_DESK, 41 F_GOTO_DESKVIEWPORT, 42 #ifndef NO_WINDOWLIST 43 F_WINDOWLIST, 44 #endif 45 F_STOPMODULELIST, 46 F_RESTARTMODULELIST, 47 F_POPUP, 48 F_FUNCTION, 49 F_CATEGORY, 50 F_CATEGORY_TREE, 51 F_MINIPIXMAP, 52 F_SMALL_MINIPIXMAP, 53 F_LARGE_MINIPIXMAP, 54 F_Preview, 55 F_DesktopEntry, 56 F_EXEC, 57 F_ExecInDir, 58 F_MODULE, 59 F_ExecToolStart, 60 F_ExecInTerm=F_ExecToolStart, 61 F_ExecBrowser, 62 F_ExecEditor, 63 F_ExecToolEnd = F_ExecEditor, 64 F_KILLMODULEBYNAME, 65 F_RESTARTMODULEBYNAME, 66 F_KILLALLMODULESBYNAME, 67 F_QUICKRESTART, 68 F_CHANGE_BACKGROUND, 69 F_CHANGE_BACKGROUND_FOREIGN, 70 F_CHANGE_LOOK, 71 F_CHANGE_FEEL, 72 F_CHANGE_THEME, 73 F_CHANGE_THEME_FILE, 74 F_CHANGE_COLORSCHEME, 75 F_INSTALL_LOOK, 76 F_INSTALL_FEEL, 77 F_INSTALL_BACKGROUND, 78 F_INSTALL_FONT, 79 F_INSTALL_ICON, 80 F_INSTALL_TILE, 81 F_INSTALL_THEME_FILE, 82 F_INSTALL_COLORSCHEME, 83 F_SAVE_WORKSPACE, 84 F_SIGNAL_RELOAD_GTK_RCFILE, 85 F_KIPC_SEND_MESSAGE_ALL, /* sends KIPC message to all KDE windows */ 86 F_ENDFUNC, 87 F_ENDPOPUP, 88 F_TAKE_SCREENSHOT, 89 F_SET, 90 F_Test, /* for debugging purposes to be able to test new features before actually 91 * enabling them for user */ 92 F_Remap, 93 94 /* this functions require window as aparameter */ 95 F_WINDOW_FUNC_START, 96 F_MOVE, 97 F_RESIZE, 98 F_RAISE, 99 F_LOWER, 100 F_RAISELOWER, 101 F_PUTONTOP, 102 F_PUTONBACK, 103 F_SETLAYER, 104 F_TOGGLELAYER, 105 F_SHADE, 106 F_DELETE, 107 F_DESTROY, 108 F_CLOSE, 109 F_ICONIFY, 110 F_MAXIMIZE, 111 F_FULLSCREEN, 112 F_STICK, 113 F_FOCUS, 114 F_CHANGEWINDOW_UP, 115 F_CHANGEWINDOW_DOWN, 116 F_GOTO_BOOKMARK, 117 F_GETHELP, 118 F_PASTE_SELECTION, 119 F_CHANGE_WINDOWS_DESK, 120 F_BOOKMARK_WINDOW, 121 F_PIN_MENU, 122 F_TAKE_WINDOWSHOT, 123 F_TAKE_FRAMESHOT, 124 F_SWALLOW_WINDOW, 125 /* end of window functions */ 126 /* these are commands to be used only by modules */ 127 /* end of window functions */ 128 /* these are commands to be used only by modules */ 129 F_MODULE_FUNC_START, 130 F_SEND_WINDOW_LIST, 131 F_SET_MASK, 132 F_SET_NAME, 133 F_UNLOCK, 134 F_SET_FLAGS, 135 /* these are internal commands */ 136 F_INTERNAL_FUNC_START, 137 F_RAISE_IT, 138 F_Folder, 139 /* this one is treated by AS same as F_EXEC but it really 140 should be used only in Wharf config : */ 141 F_SWALLOW_FUNC_START, 142 F_Swallow = F_SWALLOW_FUNC_START, 143 F_MaxSwallow, 144 F_SwallowModule, 145 F_MaxSwallowModule, 146 F_SWALLOW_FUNC_END, 147 F_Size = F_SWALLOW_FUNC_END, 148 F_Transient, 149 F_FUNCTIONS_NUM 150 } FunctionCode ; 151 152 #define NEED_NAME (1<<0) 153 #define NEED_PATH (1<<1) 154 #define NEED_WINDOW (1<<2) 155 #define NEED_WINIFNAME (1<<3) 156 #define NEED_CMD (1<<4) 157 /* this one instructs us to append numeric arguments at the end of the 158 function definition */ 159 #define USES_NUMVALS (1<<5) 160 161 #define FUNC_ERR_START -100 162 #define FUNC_ERR_NO_NAME -100 163 #define FUNC_ERR_NO_TEXT -101 164 165 typedef enum { 166 MINIPIXMAP_Icon = 0, 167 MINIPIXMAP_Preview, 168 MINIPIXMAP_TypesNum 169 } MinipixmapTypes; 170 171 #define GetMinipixmapType(f) (((f) >= F_MINIPIXMAP && (f) <= F_LARGE_MINIPIXMAP)? 0 : ((f)==F_Preview) ? 1 : 2) 172 #define IsMinipixmap(t) ((t)< MINIPIXMAP_TypesNum) 173 174 175 #define IsWindowFunc(f) ((f)>F_WINDOW_FUNC_START&&(f)<F_MODULE_FUNC_START) 176 #define IsModuleFunc(f) ((f)>F_MODULE_FUNC_START&&(f)<F_INTERNAL_FUNC_START) 177 #define IsInternFunc(f) ((f)>F_INTERNAL_FUNC_START&&(f)<F_FUNCTIONS_NUM) 178 #define IsValidFunc(f) ((f)>=0&&(f)<F_FUNCTIONS_NUM) 179 #define IsSwallowFunc(f) ((f)>=F_SWALLOW_FUNC_START&&(f)<F_SWALLOW_FUNC_END) 180 #define IsExecFunc(f) ((f)>= F_EXEC && (f)< F_KILLMODULEBYNAME) 181 #define IsMinipixmapFunc(f) (IsMinipixmap(GetMinipixmapType(f))) 182 183 #ifndef NO_WINDOWLIST 184 #define IsDynamicPopup(f) ((f) >= F_WINDOWLIST && (f) <= F_RESTARTMODULELIST) 185 #else 186 #define IsDynamicPopup(f) ((f) >= F_STOPMODULELIST && (f) <= F_RESTARTMODULELIST) 187 #endif 188 189 void ChangeWarpIndex(const long, FunctionCode); 190 191 #define MAX_FUNC_ARGS 2 192 193 typedef struct FunctionData 194 { 195 CARD32 func; /* AfterStep built in function */ 196 INT32 func_val[MAX_FUNC_ARGS]; 197 #define DEFAULT_MAXIMIZE 100 198 #define DEFAULT_OTHERS 0 199 INT32 unit_val[MAX_FUNC_ARGS]; 200 char unit[MAX_FUNC_ARGS] ; 201 #define APPLY_VALUE_UNIT(size,value,unit) (((unit)>0)?(value)*(unit):((value)*(size))/100) 202 203 #define DEFAULT_MAXIMIZE 100 204 205 char* name ; 206 char* text ; 207 #define COMPLEX_FUNCTION_NAME(pd) (((pd)->text)?(pd)->text:(pd)->name) 208 char hotkey ; 209 void* popup ; /* actually a MenuRoot pointer */ 210 int name_encoding ; 211 } FunctionData ; 212 213 typedef struct ComplexFunction 214 { 215 unsigned long magic; 216 char *name ; 217 218 FunctionData *items; 219 unsigned int items_num; 220 }ComplexFunction; 221 222 typedef struct { 223 char *filename; /* we always read filename from config !! */ 224 struct ASImage *image; 225 int loadCount; 226 }MinipixmapData; 227 228 typedef struct MenuDataItem 229 { 230 231 unsigned long magic; 232 struct MenuDataItem *next; /* next menu item */ 233 struct MenuDataItem *prev; /* prev menu item */ 234 235 /* same flags are used for both MenuDataItem and MenuData */ 236 237 #define MD_Disabled (0x01<<0) 238 #define MD_ScaleMinipixmapDown (0x01<<1) 239 #define MD_ScaleMinipixmapUp (0x01<<2) 240 #define MD_NameIsUTF8 (0x01<<16) 241 #define MD_CommentIsUTF8 (0x01<<17) 242 /* can't think of anything else atm - maybe add something later ? */ 243 244 ASFlagType flags ; 245 struct FunctionData *fdata ; 246 MinipixmapData minipixmap[MINIPIXMAP_TypesNum]; 247 248 char *preview ; /* we always read filename from config !! */ 249 struct ASImage *preview_image ; 250 char *item; /* the character string displayed on left */ 251 char *item2; /* the character string displayed on right */ 252 char *comment ; 253 254 time_t last_used_time ; 255 }MenuDataItem; 256 257 typedef struct MenuData 258 { 259 unsigned long magic; 260 struct MenuDataItem *first; /* first item in menu */ 261 struct MenuDataItem *last; /* last item in menu */ 262 short items_num; /* number of items in the menu */ 263 264 ASFlagType flags ; 265 char *name; /* name of root */ 266 char *comment ; 267 int recent_items ; /* negative value indicates that default, 268 set in feel should be used */ 269 270 }MenuData; 271 272 #define MAX_MENU_ITEM_HEIGHT (ASDefaultScrHeight>>4) 273 #define MAX_MENU_WIDTH (ASDefaultScrWidth>>1) 274 #define MAX_MENU_HEIGHT ((ASDefaultScrHeight*9)/10) 275 #define MIN_MENU_X 5 276 #define MAX_MENU_X (ASDefaultScrWidth-5) 277 #define MIN_MENU_Y 5 278 #define MAX_MENU_Y (ASDefaultScrHeight-5) 279 #define DEFAULT_ARROW_SIZE (ASDefaultScrWidth>>7) 280 #define DEFAULT_SCROLLBAR_SIZE (ASDefaultScrWidth>>6) 281 282 /* Types of events for the FUNCTION builtin */ 283 #define MOTION 'm' 284 #define MOTION_UPPER 'M' 285 #define IMMEDIATE 'i' 286 #define IMMEDIATE_UPPER 'I' 287 #define CLICK 'c' 288 #define CLICK_UPPER 'C' 289 #define DOUBLE_CLICK 'd' 290 #define DOUBLE_CLICK_UPPER 'D' 291 #define TRIPLE_CLICK 't' 292 #define TRIPLE_CLICK_UPPER 'T' 293 #define ONE_AND_A_HALF_CLICKS 'o' 294 #define ONE_AND_A_HALF_CLICKS_UPPER 'O' 295 #define TWO_AND_A_HALF_CLICKS 'h' 296 #define TWO_AND_A_HALF_CLICKS_UPPER 'H' 297 #define CLICKS_TRIGGERS_LOWER "mcodht" 298 #define CLICKS_TRIGGERS_UPPER "MCODHT" 299 #define MAX_CLICKS_HANDLED 6 300 301 struct ASEvent; 302 303 typedef void (*as_function_handler)(struct FunctionData *data, struct ASEvent *event, int module); 304 305 struct TermDef *txt2fterm (const char *txt, int quiet); 306 int txt2func (const char *text, FunctionData * fdata, int quiet); 307 int txt2func_code (const char *text); 308 int parse_func (const char *text, FunctionData * data, int quiet); 309 FunctionData *String2Func ( const char *string, FunctionData *p_fdata, Bool quiet ); 310 311 /* changes function meaning in the parsing table, has no effect on already parsed function data */ 312 FunctionCode change_func_code (const char *func_name, FunctionCode new_code); 313 314 void init_func_data (FunctionData * data); 315 void copy_func_data (FunctionData * dst, FunctionData * src); 316 void dup_func_data (FunctionData * dst, FunctionData * src); 317 inline FunctionData *create_named_function( int func, char *name); 318 void set_func_val (FunctionData * data, int arg, int value); 319 int free_func_data (FunctionData * data); 320 void destroy_func_data( FunctionData **pdata ); 321 long default_func_val( FunctionCode func ); 322 void decode_func_units (FunctionData * data); 323 void complex_function_destroy(ASHashableValue value, void *data); 324 void really_destroy_complex_func(ComplexFunction *cf); 325 void init_list_of_funcs(struct ASHashTable **list, Bool force); 326 ComplexFunction *new_complex_func( struct ASHashTable *list, char *name ); 327 ComplexFunction *find_complex_func( struct ASHashTable *list, char *name ); 328 void menu_data_item_destroy(MenuDataItem *mdi); 329 void purge_menu_data_items(MenuData *md); 330 void destroy_menu_data( MenuData **pmd ); 331 void init_list_of_menus ( ASHashTable **list, Bool force); 332 MenuData *create_menu_data( char *name ); 333 MenuData *new_menu_data ( ASHashTable *list, char *name ); 334 MenuData *find_menu_data( ASHashTable *list, char *name ); 335 MenuDataItem *new_menu_data_item( MenuData *menu ); 336 int parse_menu_item_name (MenuDataItem * item, char **name); 337 338 Bool check_fdata_availability( FunctionData *fdata ); 339 340 MenuDataItem * add_menu_fdata_item( MenuData *menu, FunctionData *fdata, MinipixmapData *minipixmaps); 341 MenuDataItem * menu_data_item_from_func (MenuData * menu, FunctionData * fdata, Bool do_check_availability); 342 struct ASImage *check_scale_menu_pmap( struct ASImage *im, ASFlagType flags ); 343 void free_menu_pmaps( MenuData *menu); 344 void load_menuitem_pmap (MenuDataItem *mdi, MinipixmapTypes type, Bool force); 345 void reload_menu_pmaps( MenuData *menu, Bool force ); 346 347 /* usefull to qsort array of FunctionData pointers : */ 348 int compare_func_data_name(const void *a, const void *b); 349 350 Bool is_web_background (FunctionData *fdata); 351 352 353 void print_func_data(const char *file, const char *func, int line, FunctionData *data); 354 char *format_FunctionData (FunctionData *data); 355 356 #define MenuDataItemFromFunc(m,f) menu_data_item_from_func((m),(f), False) 357 358 359 360 #ifdef __cplusplus 361 } 362 #endif 363 364 365 366 #endif /* _FUNCTIONS_ */ 367