int main(int argc, char **argv) { char *temp, *s; commands = (CommandChain*)safemalloc(sizeof(CommandChain)); commands->first = commands->last = NULL; /* Save the program name for error messages and config parsing */ temp = argv[0]; s = strrchr(argv[0], '/'); if (s != NULL) { temp = s + 1; } Module = temp; configPrefix = CatString2("*", Module); if ((argc != 6) && (argc != 7)) { fprintf(stderr, "%s Version %s should only be executed by fvwm!\n", Module, VERSION); exit(1); } fvwm_fd[0] = atoi(argv[1]); fvwm_fd[1] = atoi(argv[2]); /* Grab the X display information now. */ dpy = XOpenDisplay(displayName); if (!dpy) { fprintf(stderr, "%s: unable to open display '%s'\n", Module, XDisplayName (displayName)); exit (2); } screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); MyDisplayHeight = DisplayHeight(dpy, screen); MyDisplayWidth = DisplayWidth(dpy, screen); XSetErrorHandler(ErrorHandler); flib_init_graphics(dpy); XA_XSETROOT_ID = XInternAtom(dpy, "_XSETROOT_ID", False); XA_ESETROOT_PMAP_ID = XInternAtom(dpy, "ESETROOT_PMAP_ID", False); XA_XROOTPMAP_ID = XInternAtom(dpy, "_XROOTPMAP_ID", False); signal (SIGPIPE, DeadPipe); /* Parse the config file */ ParseConfig(); SetMessageMask(fvwm_fd, M_NEW_PAGE | M_NEW_DESK | M_CONFIG_INFO | M_END_CONFIG_INFO | M_SENDCONFIG); /* ** we really only want the current desk/page, and window list sends it */ SendInfo(fvwm_fd, "Send_WindowList", 0); /* tell fvwm we're running */ SendFinishedStartupNotification(fvwm_fd); /* Recieve all messages from fvwm */ EndLessLoop(); /* Should never get here! */ return 1; }
/* * * Procedure: * main - start of module * */ int main(int argc, char **argv) { char *tline; module = ParseModuleArgs(argc,argv,0); /* no alias allowed */ if (module==NULL) { fprintf(stderr,"FvwmScroll Version %s should only be executed by fvwm!\n", VERSION); exit(1); } if(module->user_argc >= 1) { extern int Reduction_H; extern int Percent_H; int len; len = strlen(module->user_argv[0])-1; if (len >= 0 && module->user_argv[0][len] == 'p') { module->user_argv[0][len] = '\0'; Percent_H = atoi(module->user_argv[0]); } else { Reduction_H = atoi(module->user_argv[0]); } } if(module->user_argc >= 2) { extern int Reduction_V; extern int Percent_V; int len; len = strlen(module->user_argv[1])-1; if (len >= 0 && module->user_argv[1][len] == 'p') { module->user_argv[1][len] = '\0'; Percent_V = atoi(module->user_argv[1]); } else { Reduction_V = atoi(module->user_argv[1]); } } /* Dead pipe == dead fvwm */ signal (SIGPIPE, DeadPipe); fd[0] = module->to_fvwm; fd[1] = module->from_fvwm; /* Open the Display */ if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr,"%s: can't open display\n", module->name); exit (1); } x_fd = XConnectionNumber(dpy); screen= DefaultScreen(dpy); Root = RootWindow(dpy, screen); ScreenHeight = DisplayHeight(dpy,screen); ScreenWidth = DisplayWidth(dpy,screen); SetMessageMask(fd, M_CONFIG_INFO | M_END_CONFIG_INFO | M_SENDCONFIG); SetMessageMask(fd, MX_PROPERTY_CHANGE); flib_init_graphics(dpy); /* scan config file for set-up parameters */ /* Colors and fonts */ InitGetConfigLine(fd,CatString3("*",module->name,0)); GetConfigLine(fd,&tline); while(tline != (char *)0) { if(strlen(tline)>1) { if(strncasecmp(tline,CatString3("*",module->name, "Back"), module->namelen+4)==0) { CopyString(&BackColor,&tline[module->namelen+4]); colorset = -1; } else if(strncasecmp(tline,CatString3("*",module->name,"Colorset"), module->namelen+8)==0) { sscanf(&tline[module->namelen+8], "%d", &colorset); AllocColorset(colorset); } else if(strncasecmp(tline, "Colorset", 8) == 0) { LoadColorset(&tline[8]); } } GetConfigLine(fd,&tline); } XSetErrorHandler(ErrorHandler); if(module->window == 0) GetTargetWindow(&module->window); if(module->window == 0) return 0; fd_width = GetFdWidth(); GrabWindow(module->window); /* tell fvwm we're running */ SendFinishedStartupNotification(fd); Loop(module->window); return 0; }
int SetRootWindow(char *tline) { Pixmap shapeMask = None, temp_pix = None, alpha = None; int w, h; int depth; int nalloc_pixels = 0; Pixel *alloc_pixels = NULL; char *file_path; FvwmPictureAttributes fpa; if (use_our_color_limit) { PictureColorLimitOption colorLimitop = {-1, -1, -1, -1, -1}; colorLimitop.color_limit = opt_color_limit; PictureInitCMapRoot( dpy, !NoColorLimit, &colorLimitop, True, True); } else { /* this use the default visual (not the fvwm one) as * getenv("FVWM_VISUALID") is NULL in any case. But this use * the same color limit than fvwm. * This is "broken" when fvwm use depth <= 8 and a private * color map (i.e., fvwm is started with the -visual{ID} * option), because when fvwm use a private color map the * default color limit is 244. There is no way to know here if * getenv("FVWM_VISUALID") !=NULL. * So, in this unfortunate case the user should use the * --color-limit option */ PictureInitCMap(dpy); } flib_init_graphics(dpy); /* try built-in image path first, but not before pwd */ PictureSetImagePath(".:+"); file_path = PictureFindImageFile(tline, NULL, R_OK); if (file_path == NULL) { file_path = tline; } fpa.mask = FPAM_NO_ALLOC_PIXELS | FPAM_NO_ALPHA; if (Pdepth <= 8 && !NoDither) { fpa.mask |= FPAM_DITHER; } else if (Pdepth <= 16 && Dither) { fpa.mask |= FPAM_DITHER; } if (NoColorLimit) { fpa.mask |= FPAM_NO_COLOR_LIMIT; } if (!PImageLoadPixmapFromFile( dpy, root, file_path, &temp_pix, &shapeMask, &alpha, &w, &h, &depth, &nalloc_pixels, &alloc_pixels, 0, fpa)) { fprintf( stderr, "[fvwm-root] failed to load image file '%s'\n", tline); return -1; } if (depth == Pdepth) { rootImage = temp_pix; } else { XGCValues gcv; GC gc; gcv.background= WhitePixel(dpy, screen); gcv.foreground= BlackPixel(dpy, screen); gc = fvwmlib_XCreateGC( dpy, root, GCForeground | GCBackground, &gcv); rootImage = XCreatePixmap(dpy, root, w, h, Pdepth); XCopyPlane(dpy, temp_pix, rootImage, gc, 0, 0, w, h, 0, 0, 1); XFreePixmap(dpy, temp_pix); XFreeGC(dpy, gc); } XSetWindowBackgroundPixmap(dpy, root, rootImage); save_colors = 1; XClearWindow(dpy, root); return 0; }
/* * * Procedure: * main - start of module * */ int main(int argc, char **argv) { char *display_name = NULL; char *tline; FlocaleInit(LC_CTYPE, "", "", "MvwmIdent"); module = ParseModuleArgs(argc,argv,0); /* no alias */ if (module == NULL) { fprintf( stderr, "MvwmIdent Version %s should only be executed" " by mvwm!\n", VERSION); exit(1); } #ifdef HAVE_SIGACTION { struct sigaction sigact; sigemptyset(&sigact.sa_mask); sigaddset(&sigact.sa_mask, SIGPIPE); sigaddset(&sigact.sa_mask, SIGTERM); sigaddset(&sigact.sa_mask, SIGQUIT); sigaddset(&sigact.sa_mask, SIGINT); sigaddset(&sigact.sa_mask, SIGHUP); # ifdef SA_INTERRUPT sigact.sa_flags = SA_INTERRUPT; # else sigact.sa_flags = 0; # endif sigact.sa_handler = TerminateHandler; sigaction(SIGPIPE, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGINT, &sigact, NULL); sigaction(SIGHUP, &sigact, NULL); } #else /* We don't have sigaction(), so fall back to less robust methods. */ #ifdef USE_BSD_SIGNALS mvwmSetSignalMask( sigmask(SIGPIPE) | sigmask(SIGTERM) | sigmask(SIGQUIT) | sigmask(SIGINT) | sigmask(SIGHUP) ); #endif signal(SIGPIPE, TerminateHandler); signal(SIGTERM, TerminateHandler); signal(SIGQUIT, TerminateHandler); signal(SIGINT, TerminateHandler); signal(SIGHUP, TerminateHandler); #ifdef HAVE_SIGINTERRUPT siginterrupt(SIGPIPE, 1); siginterrupt(SIGTERM, 1); siginterrupt(SIGQUIT, 1); siginterrupt(SIGINT, 1); siginterrupt(SIGHUP, 1); #endif #endif fd[0] = module->to_mvwm; fd[1] = module->from_mvwm; /* Open the Display */ if (!(dpy = XOpenDisplay(display_name))) { fprintf(stderr,"%s: can't open display %s", module->name, XDisplayName(display_name)); exit (1); } x_fd = XConnectionNumber(dpy); screen= DefaultScreen(dpy); Root = RootWindow(dpy, screen); XSetErrorHandler(ErrorHandler); flib_init_graphics(dpy); FlocaleAllocateWinString(&FwinString); SetMessageMask(fd, M_CONFIGURE_WINDOW | M_WINDOW_NAME | M_ICON_NAME | M_RES_CLASS | M_RES_NAME | M_END_WINDOWLIST | M_CONFIG_INFO | M_END_CONFIG_INFO | M_SENDCONFIG); SetMessageMask(fd, MX_PROPERTY_CHANGE); /* scan config file for set-up parameters */ /* Colors and fonts */ InitGetConfigLine(fd,CatString3("*",module->name,0)); GetConfigLine(fd,&tline); while (tline != (char *)0) { if (strlen(tline) <= 1) { continue; } if (strncasecmp(tline, CatString3("*",module->name,0), module->namelen+1) == 0) { tline += (module->namelen +1); if (strncasecmp(tline, "Font", 4) == 0) { CopyStringWithQuotes(&font_string, &tline[4]); } else if (strncasecmp(tline, "Fore", 4) == 0) { CopyString(&ForeColor, &tline[4]); colorset = -1; } else if (strncasecmp(tline, "Back", 4) == 0) { CopyString(&BackColor, &tline[4]); colorset = -1; } else if (strncasecmp(tline, "Colorset", 8) == 0) { sscanf(&tline[8], "%d", &colorset); AllocColorset(colorset); } else if (strncasecmp(tline, "MinimalLayer", 12) == 0) { char *layer_str = PeekToken(&tline[12], NULL); if (layer_str == NULL) { minimal_layer = default_layer; } else if (sscanf( layer_str, "%d", &minimal_layer) != 1) { if (strncasecmp( layer_str, "none", 4) == 0) { minimal_layer = -1; } else { minimal_layer = default_layer; } } } } else if (strncasecmp(tline, "Colorset", 8) == 0) { LoadColorset(&tline[8]); } GetConfigLine(fd, &tline); } if(module->window == 0) { mvwmlib_get_target_window( dpy, screen, module->name, &(module->window), True); } fd_width = GetFdWidth(); /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendText(fd, "Send_WindowList", 0); /* tell mvwm we're running */ SendFinishedStartupNotification(fd); if (module->window == Root) { exit(0); } Loop(fd); return 0; }