/*********************************************************************** * * Procedure: * main - start of module * ***********************************************************************/ int main(int argc, char **argv) { char *temp, *s; char *display_name = NULL; /* Record the program name for error messages */ temp = argv[0]; s=strrchr(argv[0], '/'); if (s != NULL) temp = s + 1; MyName = safemalloc(strlen(temp)+2); strcpy(MyName,"*"); strcat(MyName, temp); if((argc != 6)&&(argc != 7)) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName, VERSION); exit(1); } /* Open the X display */ if (!(dpy = XOpenDisplay(display_name))) { fprintf(stderr,"%s: can't open display %s", MyName, XDisplayName(display_name)); exit (1); } screen= DefaultScreen(dpy); ScreenHeight = DisplayHeight(dpy,screen); ScreenWidth = DisplayWidth(dpy,screen); /* We should exit if our fvwm pipes die */ signal (SIGPIPE, DeadPipe); fd[0] = atoi(argv[1]); fd[1] = atoi(argv[2]); /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendInfo(fd,"Send_WindowList",0); /* tell fvwm we're running */ SendFinishedStartupNotification(fd); Loop(fd); return 0; }
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; }
/* * * Procedure: * main - start of module * */ int main(int argc, char **argv) { /* The struct holding the module info */ static ModuleArgs* module; char *enter_fn="Silent Raise"; /* default */ char *leave_fn=NULL; char *buf; int len; unsigned long m_mask; unsigned long mx_mask; unsigned long last_win = 0; /* last window handled */ unsigned long focus_win = 0; /* current focus */ unsigned long raised_win = 0; fd_set_size_t fd_width; int fd[2]; int timeout; int sec = 0; int usec = 0; int n; struct timeval value; struct timeval *delay; fd_set in_fdset; Bool do_pass_id = False; Bool use_enter_mode = False; Bool use_leave_mode = False; #ifdef DEBUG int count = 0; #endif #ifdef DEBUGTOFILE freopen(".FvwmAutoDebug","w",stderr); #endif module = ParseModuleArgs(argc,argv,0); /* no alias in this module */ if (module==NULL) { fprintf(stderr,"FvwmAuto Version "VERSION" should only be executed by fvwm!\n"); exit(1); } if (module->user_argc < 1 || module->user_argc > 5) { fprintf(stderr,"FvwmAuto can use one to five arguments.\n"); exit(1); } /* Dead pipes mean fvwm died */ #ifdef HAVE_SIGACTION { struct sigaction sigact; sigemptyset(&sigact.sa_mask); sigaddset(&sigact.sa_mask, SIGPIPE); sigaddset(&sigact.sa_mask, SIGINT); sigaddset(&sigact.sa_mask, SIGHUP); sigaddset(&sigact.sa_mask, SIGQUIT); sigaddset(&sigact.sa_mask, SIGTERM); #ifdef SA_RESTART sigact.sa_flags = SA_RESTART; # else sigact.sa_flags = 0; #endif sigact.sa_handler = TerminateHandler; sigaction(SIGPIPE, &sigact, NULL); sigaction(SIGINT, &sigact, NULL); sigaction(SIGHUP, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); } #else /* We don't have sigaction(), so fall back to less robust methods. */ #ifdef USE_BSD_SIGNALS fvwmSetSignalMask( sigmask(SIGPIPE) | sigmask(SIGINT) | sigmask(SIGHUP) | sigmask(SIGQUIT) | sigmask(SIGTERM) ); #endif signal(SIGPIPE, TerminateHandler); signal(SIGINT, TerminateHandler); signal(SIGHUP, TerminateHandler); signal(SIGQUIT, TerminateHandler); signal(SIGTERM, TerminateHandler); #ifdef HAVE_SIGINTERRUPT siginterrupt(SIGPIPE, 0); siginterrupt(SIGINT, 0); siginterrupt(SIGHUP, 0); siginterrupt(SIGQUIT, 0); siginterrupt(SIGTERM, 0); #endif #endif fd[0] = module->to_fvwm; fd[1] = module->from_fvwm; if ((timeout = atoi(module->user_argv[0]) )) { sec = timeout / 1000; usec = (timeout % 1000) * 1000; } else { sec = 0; usec = 1000; } delay = &value; n = 1; if (n < module->user_argc && module->user_argv[n]) { char *token; /* -passid option */ if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-passid")) { do_pass_id = True; n++; } if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-menterleave")) { /* enterleave mode */ use_leave_mode = True; use_enter_mode = True; n++; } else if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-menter")) { /* enter mode */ use_leave_mode = False; use_enter_mode = True; n++; } else if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-mfocus")) { /* focus mode */ use_leave_mode = False; use_enter_mode = False; n++; } /*** enter command ***/ if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "Nop")) { /* nop */ enter_fn = NULL; n++; } else if (n < module->user_argc) { /* override default */ enter_fn = module->user_argv[n]; n++; } /* This is a hack to prevent user interaction with old configs. */ if (enter_fn) { token = PeekToken(enter_fn, NULL); if (!StrEquals(token, "Silent")) { enter_fn = safestrdup( CatString2("Silent ", enter_fn)); } } /*** leave command ***/ if (n < module->user_argc && module->user_argv[n] && *module->user_argv[n] && StrEquals(module->user_argv[n], "Nop")) { /* nop */ leave_fn = NULL; n++; } else if (n < module->user_argc) { /* leave function specified */ leave_fn=module->user_argv[n]; n++; } if (leave_fn) { token = PeekToken(leave_fn, NULL); if (!StrEquals(token, "Silent")) { leave_fn = safestrdup( CatString2("Silent ", leave_fn)); } } } /* Exit if nothing to do. */ if (!enter_fn && !leave_fn) { return -1; } if (use_enter_mode) { m_mask = 0; mx_mask = MX_ENTER_WINDOW | MX_LEAVE_WINDOW | M_EXTENDED_MSG; } else { mx_mask = M_EXTENDED_MSG; m_mask = M_FOCUS_CHANGE; } /* Disable special raise/lower support on general actions. * * This works as expected in most of cases. */ if (matchWildcards("*Raise*", CatString2(enter_fn, leave_fn)) || matchWildcards("*Lower*", CatString2(enter_fn, leave_fn))) { m_mask |= M_RAISE_WINDOW | M_LOWER_WINDOW; } /* migo (04/May/2000): It is simply incorrect to listen to raise/lower * packets and change the state if the action itself has no raise/lower. * Detecting whether to listen or not by the action name is good enough. m_mask = M_FOCUS_CHANGE | M_RAISE_WINDOW | M_LOWER_WINDOW; */ SetMessageMask(fd, m_mask); SetMessageMask(fd, mx_mask); /* tell fvwm we're running */ SendFinishedStartupNotification(fd); /* tell fvwm that we want to be lock on send */ SetSyncMask(fd, m_mask); SetSyncMask(fd, mx_mask); fd_width = fd[1] + 1; FD_ZERO(&in_fdset); /* create the command buffer */ len = 0; if (enter_fn != 0) { len = strlen(enter_fn); } if (leave_fn != NULL) { len = max(len, strlen(leave_fn)); } if (do_pass_id) { len += 32; } buf = safemalloc(len); while (!isTerminated) { char raise_window_now; static char have_new_window = 0; FD_SET(fd[1], &in_fdset); myfprintf( (stderr, "\nstart %d (hnw = %d, usec = %d)\n", count++, have_new_window, usec)); /* fill in struct - modified by select() */ delay->tv_sec = sec; delay->tv_usec = usec; #ifdef DEBUG { char tmp[32]; sprintf(tmp, "%d usecs", (delay) ? (int)delay->tv_usec : -1); myfprintf((stderr, "select: delay = %s\n", (have_new_window) ? tmp : "infinite" )); } #endif if (fvwmSelect(fd_width, &in_fdset, NULL, NULL, (have_new_window) ? delay : NULL) == -1) { myfprintf( (stderr, "select: error! (%s)\n", strerror(errno))); break; } raise_window_now = 0; if (FD_ISSET(fd[1], &in_fdset)) { FvwmPacket *packet = ReadFvwmPacket(fd[1]); if (packet == NULL) { myfprintf( (stderr, "Leaving because of null packet\n")); break; } myfprintf( (stderr, "pw = 0x%x, fw=0x%x, rw = 0x%x, lw=0x%x\n", (int)packet->body[0], (int)focus_win, (int)raised_win, (int)last_win)); switch (packet->type) { case MX_ENTER_WINDOW: focus_win = packet->body[0]; if (focus_win != raised_win) { myfprintf((stderr, "entered new window\n")); have_new_window = 1; raise_window_now = 0; } else if (focus_win == last_win) { have_new_window = 0; } else { myfprintf((stderr, "entered other window\n")); } break; case MX_LEAVE_WINDOW: if (use_leave_mode) { if (focus_win == raised_win) { focus_win = 0; } myfprintf((stderr, "left raised window\n")); have_new_window = 1; raise_window_now = 0; } break; case M_FOCUS_CHANGE: /* it's a focus package */ focus_win = packet->body[0]; if (focus_win != raised_win) { myfprintf((stderr, "focus on new window\n")); have_new_window = 1; raise_window_now = 0; } else { myfprintf((stderr, "focus on old window\n")); } break; case M_RAISE_WINDOW: myfprintf( (stderr, "raise packet 0x%x\n", (int)packet->body[0])); raised_win = packet->body[0]; if (have_new_window && focus_win == raised_win) { myfprintf( (stderr, "its the old window:" " don't raise\n")); have_new_window = 0; } break; case M_LOWER_WINDOW: myfprintf( (stderr, "lower packet 0x%x\n", (int)packet->body[0])); if (have_new_window && focus_win == packet->body[0]) { myfprintf( (stderr, "window was explicitly" " lowered, don't raise it" " again\n")); have_new_window = 0; } break; } /* switch */ SendUnlockNotification(fd); } else { if (have_new_window) { myfprintf((stderr, "must raise now\n")); raise_window_now = 1; } } if (raise_window_now) { myfprintf((stderr, "raising 0x%x\n", (int)focus_win)); if (leave_fn && ((last_win && !use_leave_mode) || (raised_win && use_enter_mode))) { /* if focus_win isn't the root */ if (do_pass_id) { sprintf(buf, "%s 0x%x\n", leave_fn, (int)last_win); } else { sprintf(buf, "%s\n", leave_fn); } SendInfo(fd, buf, last_win); if (use_enter_mode) { raised_win = 0; } } if (focus_win && enter_fn) { /* if focus_win isn't the root */ if (do_pass_id) { sprintf(buf, "%s 0x%x\n", enter_fn, (int)focus_win); } else { sprintf(buf, "%s\n", enter_fn); } SendInfo(fd, buf, focus_win); raised_win = focus_win; } else if (focus_win && enter_fn == NULL) { raised_win = focus_win; } /* force fvwm to synchronise on slow X connections to * avoid a race condition. Still possible, but much * less likely. */ SendInfo(fd, "XSync", focus_win); /* switch to wait mode again */ last_win = focus_win; have_new_window = 0; } } /* while */ return 0; }
/*********************************************************************** * * Procedure: * main - start of module * ***********************************************************************/ int main(int argc, char **argv) { char *display_name = NULL; int itemp,i; char line[100]; short opt_num; Window JunkRoot, JunkChild; int JunkX, JunkY; unsigned JunkMask; #ifdef I18N_MB setlocale(LC_CTYPE, ""); #endif /* Save our program name - for error messages */ MyName = GetFileNameFromPath(argv[0]); if(argc < 6) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName, 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 fvwmSetSignalMask( 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] = atoi(argv[1]); fd[1] = atoi(argv[2]); fd_width = GetFdWidth(); opt_num = 6; if (argc >= 7 && (StrEquals(argv[opt_num], "-transient") || StrEquals(argv[opt_num], "transient"))) { opt_num++; is_transient = True; do_ignore_next_button_release = True; } /* Check for an alias */ if (argc >= opt_num + 1) { char *s; if (!StrEquals(argv[opt_num], "*")) { for (s = argv[opt_num]; *s; s++) { if (!isdigit(*s) && (*s != '-' || s != argv[opt_num] || *(s+1) == 0)) { free(MyName); MyName=safestrdup(argv[opt_num]); opt_num++; break; } } } } if (argc < opt_num + 1) { desk1 = Scr.CurrentDesk; desk2 = Scr.CurrentDesk; } else if (StrEquals(argv[opt_num], "*")) { desk1 = Scr.CurrentDesk; desk2 = Scr.CurrentDesk; fAlwaysCurrentDesk = 1; } else { desk1 = atoi(argv[opt_num]); if (argc == opt_num+1) desk2 = desk1; else desk2 = atoi(argv[opt_num+1]); if(desk2 < desk1) { itemp = desk1; desk1 = desk2; desk2 = itemp; } } ndesks = desk2 - desk1 + 1; Desks = (DeskInfo *)safemalloc(ndesks*sizeof(DeskInfo)); memset(Desks, 0, ndesks * sizeof(DeskInfo)); for(i=0;i<ndesks;i++) { sprintf(line,"Desk %d",i+desk1); CopyString(&Desks[i].label,line); Desks[i].colorset = -1; Desks[i].highcolorset = -1; Desks[i].ballooncolorset = -1; } /* Initialize X connection */ if (!(dpy = XOpenDisplay(display_name))) { fprintf(stderr,"%s: can't open display %s", MyName, XDisplayName(display_name)); exit (1); } x_fd = XConnectionNumber(dpy); InitPictureCMap(dpy); FScreenInit(dpy); AllocColorset(0); FShapeInit(dpy); Scr.screen = DefaultScreen(dpy); Scr.Root = RootWindow(dpy, Scr.screen); /* make a temp window for any pixmaps, deleted later */ initialize_viz_pager(); #ifdef DEBUG fprintf(stderr,"[main]: Connection to X server established.\n"); #endif SetMessageMask(fd, M_ADD_WINDOW| M_CONFIGURE_WINDOW| M_DESTROY_WINDOW| M_FOCUS_CHANGE| M_NEW_PAGE| M_NEW_DESK| M_RAISE_WINDOW| M_LOWER_WINDOW| M_ICONIFY| M_ICON_LOCATION| M_DEICONIFY| M_RES_NAME| M_RES_CLASS| M_WINDOW_NAME| M_ICON_NAME| M_CONFIG_INFO| M_END_CONFIG_INFO| M_MINI_ICON| M_END_WINDOWLIST| M_RESTACK); #ifdef DEBUG fprintf(stderr,"[main]: calling ParseOptions\n"); #endif ParseOptions(); if (is_transient) { XQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild, &window_x, &window_y, &JunkX, &JunkY, &JunkMask); usposition = 1; xneg = 0; yneg = 0; } #ifdef DEBUG fprintf(stderr, "[main]: back from calling ParseOptions, calling init pager\n"); #endif if (PagerFore == NULL) PagerFore = safestrdup("black"); if (PagerBack == NULL) PagerBack = safestrdup("white"); if (HilightC == NULL) HilightC = safestrdup(PagerFore); if (WindowLabelFormat == NULL) WindowLabelFormat = safestrdup("%i"); if (font_string == NULL) font_string = safestrdup("fixed"); if ((HilightC == NULL) && (HilightPixmap == NULL)) HilightDesks = 0; if (BalloonFont == NULL) BalloonFont = safestrdup("fixed"); if (BalloonBorderColor == NULL) BalloonBorderColor = safestrdup("black"); if (BalloonTypeString == NULL) BalloonTypeString = safestrdup("%i"); if (BalloonFormatString == NULL) BalloonFormatString = safestrdup("%i"); /* open a pager window */ initialize_pager(); #ifdef DEBUG fprintf(stderr,"[main]: back from init pager, getting window list\n"); #endif /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendInfo(fd,"Send_WindowList",0); #ifdef DEBUG fprintf(stderr,"[main]: back from getting window list, looping\n"); #endif if (is_transient) { Bool is_pointer_grabbed = False; Bool is_keyboard_grabbed = False; XSync(dpy,0); for (i = 0; i < 50 && !(is_pointer_grabbed && is_keyboard_grabbed); i++) { if (!is_pointer_grabbed && XGrabPointer( dpy, Scr.Root, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask| PointerMotionMask|EnterWindowMask|LeaveWindowMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess) { is_pointer_grabbed = True; } if (!is_keyboard_grabbed && XGrabKeyboard( dpy, Scr.Root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) { is_keyboard_grabbed = True; } /* If you go too fast, other windows may not get a change to release * any grab that they have. */ usleep(20000); } if (!is_pointer_grabbed) { XBell(dpy, 0); fprintf(stderr, "%s: could not grab pointer in transient mode. exiting.\n", MyName); exit(1); } XSync(dpy,0); } /* tell fvwm we're running */ SendFinishedStartupNotification(fd); Loop(fd); #ifdef DEBUG if (debug_term_signal) { fprintf(stderr,"[main]: Terminated due to signal %d\n", debug_term_signal); } #endif return 0; }
int main(int argc, char *argv[]) { char match[128]; char *config_line; int scr; console = fopen("/dev/console","w"); if (!console) console = stderr; module = ParseModuleArgs(argc,argv,0); if (module == NULL) { fprintf(stderr,"FvwmRearrange: module should be executed by fvwm only\n"); exit(-1); } fd[0] = module->to_fvwm; fd[1] = module->from_fvwm; if (!(dpy = XOpenDisplay(NULL))) { fprintf(console, "%s: couldn't open display %s\n", module->name, XDisplayName(NULL)); exit(-1); } signal (SIGPIPE, DeadPipe); FScreenInit(dpy); scr = DefaultScreen(dpy); fd_width = GetFdWidth(); strcpy(match, "*"); strcat(match, module->name); InitGetConfigLine(fd,match); GetConfigLine(fd, &config_line); while (config_line != NULL) { if (strncasecmp(config_line, XINERAMA_CONFIG_STRING, sizeof(XINERAMA_CONFIG_STRING) - 1) == 0) { FScreenConfigureModule( config_line + sizeof(XINERAMA_CONFIG_STRING) - 1); } GetConfigLine(fd, &config_line); } FScreenGetScrRect(NULL, FSCREEN_CURRENT, &dx, &dy, &dwidth, &dheight); if (strcmp(module->name, "FvwmCascade") && (!strcmp(module->name, "FvwmTile") || (argc >= 7 && !strcmp(argv[6], "-tile")))) { FvwmTile = 1; FvwmCascade = 0; resize = 1; } else { FvwmCascade = 1; FvwmTile = 0; resize = 0; } parse_args("module args", module->user_argc, module->user_argv, 0); SetMessageMask(fd, M_CONFIGURE_WINDOW | M_END_WINDOWLIST); SetMessageMask(fd, M_EXTENDED_MSG); if (FvwmTile) { if (maxx == dx) maxx = dx + dwidth; if (maxy == dy) maxy = dy + dheight; } SendText(fd, "Send_WindowList", 0); /* tell fvwm we're running */ SendFinishedStartupNotification(fd); while (get_window()) /* */; if (wins_count) { if (FvwmCascade) cascade_windows(); else /* FvwmTile */ tile_windows(); } free_window_list(wins); if (console != stderr) fclose(console); 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; }