1 #ifndef ASAPP_HEADER_FILE_INCLUDED 2 #define ASAPP_HEADER_FILE_INCLUDED 3 4 #ifdef ISC 5 #include <sys/bsdtypes.h> 6 #endif 7 8 #include <errno.h> 9 #include <stdlib.h> 10 #include <stdio.h> 11 #include <string.h> 12 #include <ctype.h> 13 14 #ifdef BROKEN_SUN_HEADERS 15 #include "sun_headers.h" 16 #endif 17 18 /*#if defined(__alpha) 19 #include "alpha_header.h" 20 #endif NEEDS_ALPHA_HEADER */ 21 22 /* Some people say that AIX and AIXV3 need 3 preceding underscores, other say 23 * no. I'll do both */ 24 #if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || defined AIXV3 || defined _SEQUENT_ 25 #include <sys/select.h> 26 #endif 27 28 #include <X11/Xlib.h> 29 #include <X11/Xmd.h> 30 #include <X11/Xproto.h> 31 #include <X11/Xatom.h> 32 #include <X11/Xutil.h> 33 #ifdef I18N 34 #include <X11/Xlocale.h> 35 #endif 36 #ifdef SHAPE 37 #include <X11/extensions/shape.h> 38 #endif /* SHAPE */ 39 #ifdef HAVE_XINERAMA 40 #include <X11/extensions/Xinerama.h> 41 #endif /* HAVE_XINERAMA */ 42 43 44 #ifdef AFTERSTEP_INTERNALS 45 #include "../include/afterbase.h" 46 #endif 47 48 #include "functions.h" 49 #include "afterstep.h" 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 55 struct SyntaxDef; 56 struct TermDef; 57 struct ASSession; 58 struct ASDesktopCategory; 59 struct ASDesktopEntry; 60 struct ASCategoryTree; 61 struct ASDatabase; 62 63 /* compatibility macros : */ 64 #define GetFdWidth get_fd_width 65 #define PutHome(f) put_file_home(f) 66 #define CopyFile(f1,f2) copy_file((f1),(f2)) 67 68 #define replaceEnvVar(p) replace_envvar (p) 69 70 #ifdef SIGNALRETURNSINT 71 #define SIGNAL_T int 72 #define SIGNAL_RETURN return 0 73 #else 74 #define SIGNAL_T void 75 #define SIGNAL_RETURN return 76 #endif 77 78 /************************************************************************ 79 * ReapChildren - wait() for all dead child processes 80 ************************************************************************/ 81 #ifdef HAVE_SYS_WAIT_H 82 #include <sys/wait.h> 83 #define ReapChildren() while ((waitpid(-1, NULL, WNOHANG)) > 0) 84 #define WAIT_CHILDREN(pstatus) waitpid(-1, pstatus, WNOHANG) 85 #elif defined (HAVE_WAIT3) 86 #define ReapChildren() while ((wait3(NULL, WNOHANG, NULL)) > 0) 87 #define WAIT_CHILDREN(pstatus) wait3(pstatus, WNOHANG, NULL) 88 #else 89 #define ReapChildren() while (1>0) 90 #define WAIT_CHILDREN(pstatus) (*pstatus=-1) 91 #endif 92 93 #define SESSION_ID_ENVVAR "DESKTOP_AUTOSTART_ID" 94 95 struct charstring 96 { 97 char key; 98 int value; 99 }; 100 101 /*********************************************************************************/ 102 /* Some usefull data structures and operations on them : */ 103 /*********************************************************************************/ 104 105 typedef struct CommandLineOpts 106 { 107 char *short_opt, *long_opt; 108 char *descr1, *descr2 ; 109 void (*handler)( char *argv, void *trg, long param ); 110 void *trg; 111 long param; 112 #define CMO_HasArgs (0x01<<0) 113 #define CMO_IsParam (0x01<<1) 114 ASFlagType flags; 115 }CommandLineOpts; 116 117 #define STANDARD_CMDL_OPTS_NUM 22 118 119 extern CommandLineOpts as_standard_cmdl_options[STANDARD_CMDL_OPTS_NUM];/* really its terminated by NULL element */ 120 121 void print_command_line_opt(const char *prompt, CommandLineOpts *options, ASFlagType mask); 122 int match_command_line_opt( char *argvi, CommandLineOpts *options ); 123 124 void handler_show_info( char *argv, void *trg, long param ); 125 void handler_set_flag( char *argv, void *trg, long param ); 126 void handler_set_string( char *argv, void *trg, long param ); 127 void handler_set_dup_string( char *argv, void *trg, long param ); 128 void handler_set_int( char *argv, void *trg, long param ); 129 void handler_set_geometry( char *argv, void *trg, long param ); 130 void handler_set_gravity( char *argv, void *trg, long param ); 131 132 133 #define ASXMLVAR_IconButtonWidth "icon.button.width" 134 #define ASXMLVAR_IconButtonHeight "icon.button.height" 135 #define ASXMLVAR_IconWidth "icon.width" 136 #define ASXMLVAR_IconHeight "icon.height" 137 #define ASXMLVAR_MinipixmapWidth "minipixmap.width" 138 #define ASXMLVAR_MinipixmapHeight "minipixmap.height" 139 #define ASXMLVAR_TitleFontSize "title.font.size" 140 #define ASXMLVAR_MenuFontSize "menu.font.size" 141 #define ASXMLVAR_MenuShowMinipixmaps "menu.show_minipixmaps" 142 #define ASXMLVAR_MenuShowUnavailable "menu.show_unavailable" 143 #define ASXMLVAR_MenuTxtItemsInd "menu.texture_items_individualy" 144 #define ASXMLVAR_MenuRecentSubmenuItems "menu.recent_submenu_items" 145 #define ASXMLVAR_MenuFolderPixmap "menu.folder_pixmap" 146 147 148 typedef struct ASProgArgs 149 { 150 /* backup of the cmdline : */ 151 int saved_argc ; 152 char **saved_argv ; 153 154 #define OPTION_SINGLE (0x01<<4) /* see declaration of as_cmdl_options in globals.c*/ 155 #define OPTION_RESTART (0x01<<5) /* see declaration of as_cmdl_options in globals.c*/ 156 #define OPTION_DISPLAY (0x01<<6) /* see declaration of as_cmdl_options in globals.c*/ 157 158 #define OPTION_USAGE_FORMAT "\nusage: %s [standard_options]" 159 #define OPTION_SHORT_FORMAT " -%s" 160 #define OPTION_NOSHORT_FORMAT " " 161 #define OPTION_DESCR1_FORMAT_VAL " --%-16.16s <val> - %s.\n" 162 #define OPTION_DESCR1_FORMAT_NOVAL " --%-16.16s - %s.\n" 163 #define OPTION_DESCR2_FORMAT OPTION_NOSHORT_FORMAT " %s.\n" 164 #define OPTION_PARAM_FORMAT " %-20.20s - %s.\n" 165 166 ASFlagType mask ; /* mask, specifying what options are not supported */ 167 168 char *override_config; 169 char *override_home, *override_share ; 170 char *override_look, *override_feel ; 171 172 char *display_name ; /* our display name */ 173 174 ASFlagType flags ; /* debugging/restarting/single, etc - see afterstep.h */ 175 176 int verbosity_level ; 177 178 Window src_window; /* window in which action accured that ended up launching us */ 179 int src_context; /* context in window in which action accured that ended up launching us */ 180 #ifdef DEBUG_TRACE_X 181 char *trace_calls ; 182 #endif 183 char *log_file ; 184 char *locale ; 185 186 ASGeometry geometry; 187 int gravity ; 188 189 }ASProgArgs; 190 191 typedef enum ASToolType 192 { 193 ASTool_Term = 0, 194 ASTool_Browser, 195 ASTool_Editor, 196 ASTool_Count 197 }ASToolType; 198 199 typedef struct ASEnvironment 200 { 201 #define ASE_NoSharedMemory (0x01<<0) 202 #define ASE_NoKDEGlobalsTheming (0x01<<1) 203 ASFlagType flags ; 204 205 char *module_path; 206 char *sound_path; 207 char *icon_path; 208 char *pixmap_path; 209 char *font_path; 210 char *cursor_path; 211 unsigned short desk_pages_h, desk_pages_v ; 212 unsigned short desk_scale ; 213 214 enum{ ASE_AllowModuleNameCollision = 0, 215 ASE_KillOldModuleOnNameCollision, 216 ASE_KillNewModuleOnNameCollision 217 }module_name_collision ; 218 char *tool_command[ASTool_Count] ; 219 220 char *gtkrc_path ; 221 char *gtkrc20_path ; 222 char *IconTheme; 223 char *IconThemePath; 224 char *IconThemeFallback; 225 }ASEnvironment; 226 227 /* 228 * FEW PRESET LEVELS OF OUTPUT : 229 */ 230 #define OUTPUT_LEVEL_PARSE_ERR 1 231 #define OUTPUT_LEVEL_HINTS OUTPUT_VERBOSE_THRESHOLD 232 #define OUTPUT_LEVEL_DATABASE OUTPUT_VERBOSE_THRESHOLD 233 #define OUTPUT_LEVEL_VROOT 7 234 #define OUTPUT_LEVEL_WINDOW_LIST (OUTPUT_LEVEL_DEBUG+9) /* too much output - too slow */ 235 236 237 ASEnvironment *make_default_environment(); 238 void set_environment_tool_from_list( ASEnvironment *e, ASToolType type, char ** list, int list_len ); 239 void destroy_asenvironment( ASEnvironment **penv ); 240 struct ASImage; 241 struct ASImage *load_environment_icon (const char* category, const char* name, int desired_size); 242 struct ASImage *load_environment_icon_any (const char *filename, int desired_size); 243 244 /***********************************************************************************/ 245 /* general purpose application launcher : */ 246 /***********************************************************************************/ 247 248 #define MAX_SINGLETONS_NUM 32 249 #define BACKGROUND_SINGLETON_ID (MAX_SINGLETONS_NUM-1) 250 #define SOUND_SINGLETON_ID (MAX_SINGLETONS_NUM-2) 251 #define TAR_SINGLETON_ID (MAX_SINGLETONS_NUM-3) 252 #define MAX_USER_SINGLETONS_NUM (MAX_SINGLETONS_NUM-3) 253 /* Singleton is the child process of which we should not launch more then one 254 * instance. singleton_id should be in range of 0...MAX_SINGLETONS_NUM. Some 255 * IDs are reserved for special use - background drawing, sound playing, etc. 256 */ 257 /* use this function to see if previously launched instance of the singleton 258 * is still alive. Optionally you can request to kill it. 259 */ 260 261 int check_singleton_child (int singleton_id, Bool kill_it_to_death); 262 int spawn_child( const char *cmd, int singleton_id, int screen, const char *orig_display, Window w, int context, Bool do_fork, Bool pass_args, ... ); 263 int spawn_download (const char *url, const char* cachedFileName); 264 Bool check_download_complete (int pid, const char *cachedFileName, int *sizeDownloaded, int *size); 265 Bool is_url (const char *url); 266 char *make_log_name (const char *FileName); 267 268 269 /***********************************************************************************/ 270 /* GLOBALS : */ 271 /***********************************************************************************/ 272 /* this call will set most of them up : */ 273 typedef void (*DeadPipe_handler)(int nonsense); 274 DeadPipe_handler set_DeadPipe_handler( DeadPipe_handler new_handler ); 275 void ASDeadPipe( int nonsense ); 276 277 void InitMyApp ( const char *app_class, int agrc, char **argv, void (*version_func) (void), void (*custom_usage_func) (void), ASFlagType opt_mask ); 278 void SetMyName (char *argv0); 279 /* overrides envvars supplied on startup : */ 280 void override_environ( char **envp ); 281 void destroy_asdatabase(); 282 283 struct ASDesktopCategory* name2desktop_category( const char *name, struct ASCategoryTree **tree_return ); 284 struct ASDesktopEntry* name2desktop_entry( const char *name, struct ASCategoryTree **tree_return ); 285 286 287 void free_as_app_args(); 288 void FreeMyAppResources(); 289 290 void InitSession(); 291 void free_func_hash (); 292 293 294 /* Command Line stuff : */ 295 extern ASProgArgs *MyArgsPtr; 296 #define MyArgs (*MyArgsPtr) /* some typical progy cmd line options - set by SetMyArgs( argc, argv )*/ 297 #define MyArgs_IS_MACRO 298 extern char *MyName; /* name are we known by - set by SetMyName(argv[0]) */ 299 #define MAX_MY_CLASS 64 300 extern char MyClass[MAX_MY_CLASS+1]; /* application Class name ( Pager, Wharf, etc. ) - set by SetMyClass(char *) */ 301 extern void (*MyVersionFunc) (void); 302 extern void (*MyUsageFunc) (void); 303 304 extern char *as_afterstep_dir_name; 305 extern char *as_save_dir_name; 306 extern char *as_start_dir_name; 307 extern char *as_share_dir_name; 308 309 extern char *as_background_dir_name ; 310 extern char *as_look_dir_name ; 311 extern char *as_theme_dir_name ; 312 extern char *as_colorscheme_dir_name ; 313 extern char *as_theme_file_dir_name ; 314 extern char *as_feel_dir_name ; 315 extern char *as_font_dir_name ; 316 extern char *as_icon_dir_name ; 317 extern char *as_tile_dir_name ; 318 319 320 extern int fd_width; 321 /* set by screen.c:setup_modifiers() in screen.c:ConnectX() :*/ 322 extern unsigned int nonlock_mods; /* a mask for non-locking modifiers */ 323 #define MAX_LOCK_MODS 256 324 extern unsigned int lock_mods[MAX_LOCK_MODS]; /* all combinations of lock modifier masks */ 325 /* Now for each display we may have one or several screens ; */ 326 extern int x_fd; /* descriptor of the X Windows connection */ 327 extern Display *dpy; 328 extern struct ScreenInfo *ASDefaultScr; /* ScreenInfo for the default screen */ 329 #define ASDefaultRoot (ASDefaultScr->Root) 330 #define ASDefaultScrWidth (ASDefaultScr->MyDisplayWidth) 331 #define ASDefaultScrHeight (ASDefaultScr->MyDisplayHeight) 332 #define ASDefaultVisual (ASDefaultScr->asv) 333 #define ASDefaultDrawGC (ASDefaultScr->DrawGC) 334 335 /* this is for compatibility with old code : */ 336 #define Scr (*ASDefaultScr) 337 #define Scr_IS_MACRO 338 339 340 /* this two are unused in as-stable yet : */ 341 extern struct ScreenInfo **all_screens ; /* all ScreenInfo structures for NumberOfScreens screens */ 342 extern struct ASHashTable *screens_window_hash; /* so we can easily track what window is on what screen */ 343 344 extern int SingleScreen ; /* if >= 0 then [points to the only ScreenInfo structure available */ 345 extern unsigned int NumberOfScreens; /* number of screens on display */ 346 extern int PointerScreen ; /* screen that currently has pointer */ 347 348 enum FunctionCode; 349 350 extern struct SyntaxDef *pFuncSyntax ; 351 extern struct SyntaxDef *pPopupFuncSyntax; 352 353 struct TermDef *func2fterm (enum FunctionCode func, int quiet); 354 355 extern struct ASSession *Session; /* filenames of look, feel and background */ 356 extern struct ASEnvironment *Environment; 357 extern struct ASDatabase *Database; 358 359 extern struct ASCategoryTree *StandardCategories ; 360 extern struct ASCategoryTree *AfterStepCategories ; 361 extern struct ASCategoryTree *KDECategories ; 362 extern struct ASCategoryTree *GNOMECategories ; 363 extern struct ASCategoryTree *OtherCategories ; 364 extern struct ASCategoryTree *CombinedCategories ; 365 366 /* this two are unused in as-stable yet : */ 367 struct ASFeel; 368 struct MyLook; 369 extern struct ASFeel *DefaultFeel; 370 extern struct MyLook *DefaultLook; 371 372 373 extern void (*CloseOnExec)(); 374 375 #ifdef __cplusplus 376 } 377 #endif 378 379 380 #endif /* #ifndef AFTERSTEP_LIB_HEADER_FILE_INCLUDED */ 381