/** *** ParseOptions() **/ void ParseOptions(button_info *ub) { char *s; char *items[]= {"iconpath","pixmappath",NULL,NULL}; items[2]=mymalloc(strlen(MyName)+2); sprintf(items[2],"*%s",MyName); GetConfigLine(fd,&s); while(s && s[0]) { switch(MatchSeveralLines(s,items,&s)) { case -1: break; case 0: CopyString(&iconPath,s); break; case 1: CopyString(&pixmapPath,s); break; case 2: if(s && s[0] && !config_file) ParseConfigLine(&ub,s); } GetConfigLine(fd,&s); } if(config_file) ParseConfigFile(ub); return; }
/** *** ParseOptions() **/ void ParseConfiguration(button_info *ub) { char *s; char *items[] = { NULL, /* filled out below */ "imagepath", "colorset", XINERAMA_CONFIG_STRING, NULL }; items[0] = mymalloc(strlen(MyName) + 2); sprintf(items[0], "*%s", MyName); /* send config lines with MyName */ InitGetConfigLine(fd, items[0]); GetConfigLine(fd, &s); while (s && s[0]) { char *rest; switch (GetTokenIndex(s,items,-1,&rest)) { case -1: break; case 0: if (rest && rest[0] && !config_file) { ParseConfigLine(&ub, rest); } break; case 1: if (imagePath) { free(imagePath); } CopyString(&imagePath, rest); break; case 2: /* store colorset sent by fvwm */ LoadColorset(rest); break; case 3: /* Xinerama state */ FScreenConfigureModule(rest); break; } GetConfigLine(fd,&s); } if (config_file) { ParseConfigFile(ub); } free(items[0]); return; }
/****************************************************************************** ParseConfig - Parse the configuration file fvwm to us to use Based on part of main() from FvwmIdent: Copyright 1994, Robert Nation and Nobutaka Suzuki. ******************************************************************************/ void ParseConfig(void) { char *tline; GetConfigLine(Fvwm_fd,&tline); while(tline != (char *)0) { if(strlen(tline)>1) { if(strncasecmp(tline, CatString3(Module, "Font",""),Clength+4)==0) CopyString(&font_string,&tline[Clength+4]); else if(strncasecmp(tline,CatString3(Module,"Fore",""), Clength+4)==0) CopyString(&ForeColor[0],&tline[Clength+4]); else if(strncasecmp(tline,CatString3(Module,"IconFore",""), Clength+8)==0) CopyString(&ForeColor[1],&tline[Clength+8]); else if(strncasecmp(tline,CatString3(Module,"FocusFore",""), Clength+9)==0) { CopyString(&ForeColor[2],&tline[Clength+9]); CopyString(&ForeColor[3],&tline[Clength+9]); } else if(strncasecmp(tline,CatString3(Module, "Geometry",""), Clength+8)==0) CopyString(&geometry,&tline[Clength+8]); else if(strncasecmp(tline,CatString3(Module, "Back",""), Clength+4)==0) CopyString(&BackColor[0],&tline[Clength+4]); else if(strncasecmp(tline,CatString3(Module,"IconBack",""), Clength+8)==0) CopyString(&BackColor[1],&tline[Clength+8]); else if(strncasecmp(tline,CatString3(Module,"FocusBack",""), Clength+9)==0) { CopyString(&BackColor[2],&tline[Clength+9]); CopyString(&BackColor[3],&tline[Clength+9]); } else if(strncasecmp(tline,CatString3(Module, "NoAnchor",""), Clength+8)==0) Anchor=0; else if(strncasecmp(tline,CatString3(Module, "Action",""), Clength+6)==0) LinkAction(&tline[Clength+6]); else if(strncasecmp(tline,CatString3(Module, "UseSkipList",""), Clength+11)==0) UseSkipList=1; else if(strncasecmp(tline,CatString3(Module, "UseIconNames",""), Clength+12)==0) UseIconNames=1; else if(strncasecmp(tline,CatString3(Module, "ShowCurrentDesk",""), Clength+15)==0) ShowCurrentDesk=1; else if(strncasecmp(tline,CatString3(Module, "LeftJustify",""), Clength+11)==0) LeftJustify=1; else if(strncasecmp(tline,CatString3(Module, "TruncateLeft",""), Clength+12)==0) TruncateLeft=1; else if(strncasecmp(tline,CatString3(Module, "MinWidth",""), Clength+8)==0) MinWidth=atoi(&tline[Clength+8]); else if(strncasecmp(tline,CatString3(Module, "MaxWidth",""), Clength+8)==0) MaxWidth=atoi(&tline[Clength+8]); else if(strncasecmp(tline,CatString3(Module, "DontDepressFocus",""), Clength+16)==0) ShowFocus=0; } GetConfigLine(Fvwm_fd,&tline); } }
/* ParseConfig - Parse the configuration file fvwm to us to use */ void ParseConfig(void) { char *line_start; char *tline; line_start = safemalloc(strlen(Module) + 2); strcpy(line_start, "*"); strcat(line_start, Module); InitGetConfigLine(fvwm_fd, line_start); GetConfigLine(fvwm_fd, &tline); while(tline != (char *)0) { ParseConfigLine(tline); GetConfigLine(fvwm_fd, &tline); } free(line_start); }
/* Lecture du fichier system.fvwmrc ou .fvwmrc */ void ParseOptions(void) { char *tline; GetConfigLine(fd,&tline); while(tline != (char *)0) { if((strlen(&tline[0])>1)&&(strncasecmp(tline,"PixmapPath",10)==0)) { CopyString(&pixmapPath,&tline[10]); } if((strlen(&tline[0])>1)&&(strncasecmp(tline,"*FvwmScriptPath",15)==0)) { CopyString(&ScriptPath,&tline[15]); } GetConfigLine(fd,&tline); } }
/****************************************************************************** ParseConfig - Parse the configuration file fvwm to us to use Based on part of main() from FvwmIdent: Copyright 1994, Robert Nation and Nobutaka Suzuki. ******************************************************************************/ void ParseConfig() { char line2[40]; char *tline; sprintf(line2,"*%sDesk",Module); GetConfigLine(Fvwm_fd,&tline); while(tline != (char *)0) { if(strlen(tline)>1) { if(strncasecmp(tline,line2,strlen(line2))==0) AddCommand(&tline[strlen(line2)]); } GetConfigLine(Fvwm_fd,&tline); } }
static void parseOptions (int fd[2]) { char *tline= NULL; int clength; clength = strlen (myName); while (GetConfigLine (fd, &tline),tline != NULL) { if (strlen (tline) > 1) { if (strncasecmp (tline, CatString3 ("*", myName, "Pixmap"), clength + 7) ==0) { if (pixmapName == (char *) 0) { CopyString (&pixmapName, &tline[clength+7]); if (pixmapName[0] == 0) { free (pixmapName); pixmapName = (char *) 0; } } continue; } if (strncasecmp (tline, CatString3 ("*", myName, "Timeout"), clength + 8) ==0) { timeout = atoi(&tline[clength+8]) * 1000000; continue; } if (strncasecmp(tline, "PixmapPath",10)==0) { CopyString (&pixmapPath, &tline[10]); if (pixmapPath[0] == 0) { free (pixmapPath); pixmapPath = (char *) 0; } continue; } } } return; }
/* * * 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; }
/***************************************************************************** * * This routine is responsible for reading and parsing the config file * ****************************************************************************/ void ParseOptions(void) { char *tline= NULL; int desk; int dx = 3; int dy = 3; Scr.FvwmRoot = NULL; Scr.Hilite = NULL; Scr.VScale = 32; Scr.MyDisplayWidth = DisplayWidth(dpy, Scr.screen); Scr.MyDisplayHeight = DisplayHeight(dpy, Scr.screen); InitGetConfigLine(fd,CatString3("*",MyName,0)); for (GetConfigLine(fd,&tline); tline != NULL; GetConfigLine(fd,&tline)) { int g_x, g_y, flags; unsigned width,height; char *resource; char *resource_string; char *arg1; char *arg2; char *tline2; char *token; char *next; Bool MoveThresholdSetForModule = False; resource_string = arg1 = arg2 = NULL; token = PeekToken(tline, &next); if (StrEquals(token, "Colorset")) { LoadColorset(next); continue; } else if (StrEquals(token, XINERAMA_CONFIG_STRING)) { FScreenConfigureModule(next); } else if (StrEquals(token, "DesktopSize")) { token = PeekToken(next, &next); if (token) { sscanf(token, "%d", &dx); token = PeekToken(next, &next); if (token) sscanf(token, "%d", &dy); } continue; } else if (StrEquals(token, "ImagePath")) { if (ImagePath != NULL) { free(ImagePath); ImagePath = NULL; } GetNextToken(next, &ImagePath); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: ImagePath = %s\n", ImagePath); #endif continue; } else if (StrEquals(token, "MoveThreshold")) { if (!MoveThresholdSetForModule) { int val; if (GetIntegerArguments(next, NULL, &val, 1) > 0) { if (val >= 0) MoveThreshold = val; else MoveThreshold = DEFAULT_PAGER_MOVE_THRESHOLD; } } continue; } tline2 = GetModuleResource(tline, &resource, MyName); if (!resource) continue; tline2 = GetNextToken(tline2, &arg1); if (!arg1) { arg1 = (char *)safemalloc(1); arg1[0] = 0; } tline2 = GetNextToken(tline2, &arg2); if (!arg2) { arg2 = (char *)safemalloc(1); arg2[0] = 0; } if(StrEquals(resource,"Colorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->colorset), &(((PagerStringList *)(NULL))->colorset), &globalcolorset); } else if(StrEquals(resource,"BalloonColorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->ballooncolorset), &(((PagerStringList *)(NULL))->ballooncolorset), &globalballooncolorset); } else if(StrEquals(resource,"HilightColorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->highcolorset), &(((PagerStringList *)(NULL))->highcolorset), &globalhighcolorset); } else if (StrEquals(resource, "Geometry")) { window_w = 0; window_h = 0; window_x = 0; window_y = 0; xneg = 0; yneg = 0; usposition = 0; flags = FScreenParseGeometry(arg1,&g_x,&g_y,&width,&height); if (flags & WidthValue) { window_w = width; } if (flags & HeightValue) { window_h = height; } if (flags & XValue) { window_x = g_x; usposition = 1; if (flags & XNegative) { xneg = 1; } } if (flags & YValue) { window_y = g_y; usposition = 1; if (flags & YNegative) { yneg = 1; } } } else if (StrEquals(resource, "IconGeometry")) { icon_w = 0; icon_h = 0; icon_x = -10000; icon_y = -10000; icon_xneg = 0; icon_yneg = 0; flags = FScreenParseGeometry(arg1,&g_x,&g_y,&width,&height); if (flags & WidthValue) icon_w = width; if (flags & HeightValue) icon_h = height; if (flags & XValue) { icon_x = g_x; if (flags & XNegative) { icon_xneg = 1; } } if (flags & YValue) { icon_y = g_y; if (flags & YNegative) { icon_yneg = 1; } } } else if (StrEquals(resource, "Label")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { /* replace label */ if (item->next->label != NULL) { free(item->next->label); item->next->label = NULL; } CopyString(&(item->next->label), arg2); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); CopyString(&(item->label), arg2); } if (desk == Scr.CurrentDesk) { free(Desks[0].label); CopyString(&Desks[0].label, arg2); } } else if((desk >= desk1)&&(desk <=desk2)) { free(Desks[desk - desk1].label); CopyString(&Desks[desk - desk1].label, arg2); } } else if (StrEquals(resource, "Font")) { if (font_string) free(font_string); if (next && next[0] == '\"') { int l; next++; CopyString(&font_string, next); l = strlen(font_string); if (l > 0 && font_string[l - 1] == '\"') { font_string[l - 1] = 0; } } else { CopyString(&font_string,next); } if(strncasecmp(font_string,"none",4) == 0) uselabel = 0; } else if (StrEquals(resource, "Fore")) { if(Pdepth > 1) { if (PagerFore) free(PagerFore); CopyString(&PagerFore,arg1); } } else if (StrEquals(resource, "Back")) { if(Pdepth > 1) { if (PagerBack) free(PagerBack); CopyString(&PagerBack,arg1); } } else if (StrEquals(resource, "DeskColor")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { /* replace Dcolor */ if (item->next->Dcolor != NULL) { free(item->next->Dcolor); item->next->Dcolor = NULL; } CopyString(&(item->next->Dcolor), arg2); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); CopyString(&(item->Dcolor), arg2); } if (desk == Scr.CurrentDesk) { free(Desks[0].Dcolor); CopyString(&Desks[0].Dcolor, arg2); } } else if((desk >= desk1)&&(desk <=desk2)) { free(Desks[desk - desk1].Dcolor); CopyString(&Desks[desk - desk1].Dcolor, arg2); } } else if (StrEquals(resource, "DeskPixmap")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { if (item->next->bgPixmap != NULL) { DestroyPicture(dpy, item->next->bgPixmap); item->next->bgPixmap = NULL; } item->next->bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); item->bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } if (desk == Scr.CurrentDesk) { if (Desks[0].bgPixmap != NULL) { DestroyPicture(dpy, Desks[0].bgPixmap); Desks[0].bgPixmap = NULL; } Desks[0].bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } } else if((desk >= desk1)&&(desk <=desk2)) { int dNr = desk - desk1; if (Desks[dNr].bgPixmap != NULL) { DestroyPicture(dpy, Desks[dNr].bgPixmap); Desks[dNr].bgPixmap = NULL; } Desks[dNr].bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } #ifdef DEBUG fprintf(stderr, "[ParseOptions]: Desk %d: bgPixmap = %s\n", desk, arg2); #endif } else if (StrEquals(resource, "Pixmap")) { if(Pdepth > 1) { if (PixmapBack) { DestroyPicture (dpy, PixmapBack); PixmapBack = NULL; } PixmapBack = CachePicture (dpy, Scr.Pager_w, ImagePath, arg1, 0); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: Global: bgPixmap = %s\n", arg1); #endif } } else if (StrEquals(resource, "HilightPixmap")) { if(Pdepth > 1) { if (HilightPixmap) { DestroyPicture (dpy, HilightPixmap); HilightPixmap = NULL; } HilightPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg1, 0); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: HilightPixmap = %s\n", arg1); #endif } } else if (StrEquals(resource, "DeskHilight")) { HilightDesks = 1; } else if (StrEquals(resource, "NoDeskHilight")) { HilightDesks = 0; } else if (StrEquals(resource, "Hilight")) { if(Pdepth > 1) { if (HilightC) free(HilightC); CopyString(&HilightC,arg1); } } else if (StrEquals(resource, "SmallFont")) { if (smallFont) free(smallFont); if (next && next[0] == '\"') { int l; next++; CopyString(&smallFont, next); l = strlen(smallFont); if (l > 0 && smallFont[l - 1] == '\"') { smallFont[l - 1] = 0; } } else { CopyString(&smallFont,next); } if (strncasecmp(smallFont,"none",4) == 0) { free(smallFont); smallFont = NULL; } } else if (StrEquals(resource, "MiniIcons")) { MiniIcons = 1; } else if (StrEquals(resource, "StartIconic")) { StartIconic = 1; } else if (StrEquals(resource, "NoStartIconic")) { StartIconic = 0; } else if (StrEquals(resource, "LabelsBelow")) { LabelsBelow = 1; } else if (StrEquals(resource, "LabelsAbove")) { LabelsBelow = 0; } else if (FHaveShapeExtension && StrEquals(resource, "ShapeLabels")) { ShapeLabels = 1; } else if (FHaveShapeExtension && StrEquals(resource, "NoShapeLabels")) { ShapeLabels = 0; } else if (StrEquals(resource, "Rows")) { sscanf(arg1,"%d",&Rows); } else if (StrEquals(resource, "Columns")) { sscanf(arg1,"%d",&Columns); } else if (StrEquals(resource, "DeskTopScale")) { sscanf(arg1,"%d",&Scr.VScale); } else if (StrEquals(resource, "WindowColors")) { if (Pdepth > 1) { if (WindowFore) free(WindowFore); if (WindowBack) free(WindowBack); if (WindowHiFore) free(WindowHiFore); if (WindowHiBack) free(WindowHiBack); CopyString(&WindowFore, arg1); CopyString(&WindowBack, arg2); tline2 = GetNextToken(tline2, &WindowHiFore); GetNextToken(tline2, &WindowHiBack); } } else if (StrEquals(resource, "WindowBorderWidth")) { sscanf(arg1, "%d", &WindowBorderWidth); MinSize = 2 * WindowBorderWidth + 1; } else if (StrEquals(resource, "Window3dBorders")) { WindowBorders3d = True; } else if (StrEquals(resource,"WindowColorsets")) { sscanf(arg1,"%d",&windowcolorset); AllocColorset(windowcolorset); sscanf(arg2,"%d",&activecolorset); AllocColorset(activecolorset); } else if (StrEquals(resource,"WindowLabelFormat")) { if (WindowLabelFormat) free(WindowLabelFormat); CopyString(&WindowLabelFormat,arg1); } else if (StrEquals(resource, "MoveThreshold")) { int val; if (GetIntegerArguments(next, NULL, &val, 1) > 0 && val >= 0) { MoveThreshold = val; MoveThresholdSetForModule = True; } } else if (StrEquals(resource, "SloppyFocus")) { do_focus_on_enter = True; } else if (StrEquals(resource, "SolidSeparators")) { use_dashed_separators = False; use_no_separators = False; } else if (StrEquals(resource, "NoSeparators")) { use_no_separators = True; } /* ... and get Balloon config options ... -- [email protected] */ else if (StrEquals(resource, "Balloons")) { if (BalloonTypeString) free(BalloonTypeString); CopyString(&BalloonTypeString, arg1); if ( strncasecmp(BalloonTypeString, "Pager", 5) == 0 ) { ShowPagerBalloons = 1; ShowIconBalloons = 0; } else if ( strncasecmp(BalloonTypeString, "Icon", 4) == 0 ) { ShowPagerBalloons = 0; ShowIconBalloons = 1; } else { ShowPagerBalloons = 1; ShowIconBalloons = 1; } /* turn this on initially so balloon window is created; later this variable is changed to match ShowPagerBalloons or ShowIconBalloons whenever we receive iconify or deiconify packets */ ShowBalloons = 1; } else if (StrEquals(resource, "BalloonBack")) { if (Pdepth > 1) { if (BalloonBack) free(BalloonBack); CopyString(&BalloonBack, arg1); } } else if (StrEquals(resource, "BalloonFore")) { if (Pdepth > 1) { if (BalloonFore) free(BalloonFore); CopyString(&BalloonFore, arg1); } } else if (StrEquals(resource, "BalloonFont")) { if (BalloonFont) free(BalloonFont); CopyStringWithQuotes(&BalloonFont, next); } else if (StrEquals(resource, "BalloonBorderColor")) { if (BalloonBorderColor) free(BalloonBorderColor); CopyString(&BalloonBorderColor, arg1); } else if (StrEquals(resource, "BalloonBorderWidth")) { sscanf(arg1, "%d", &BalloonBorderWidth); } else if (StrEquals(resource, "BalloonYOffset")) { sscanf(arg1, "%d", &BalloonYOffset); } else if (StrEquals(resource,"BalloonStringFormat")) { if (BalloonFormatString) free(BalloonFormatString); CopyString(&BalloonFormatString,arg1); } free(resource); free(arg1); free(arg2); } Scr.VxMax = dx * Scr.MyDisplayWidth - Scr.MyDisplayWidth; Scr.VyMax = dy * Scr.MyDisplayHeight - Scr.MyDisplayHeight; if(Scr.VxMax <0) Scr.VxMax = 0; if(Scr.VyMax <0) Scr.VyMax = 0; Scr.VxPages = Scr.VxMax / Scr.MyDisplayWidth; Scr.VyPages = Scr.VyMax / Scr.MyDisplayHeight; Scr.VWidth = Scr.VxMax + Scr.MyDisplayWidth; Scr.VHeight = Scr.VyMax + Scr.MyDisplayHeight; Scr.Vx = 0; Scr.Vy = 0; return; }
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; }
/*********************************************************************** * * Procedure: * main - start of module * ***********************************************************************/ int main(int argc, char **argv) { char *temp, *s; FILE *file; char *display_name = NULL; int Clength; char *tline; /* Save the program name for error messages and config parsing */ temp = argv[0]; s=strrchr(argv[0], '/'); if (s != NULL) temp = s + 1; MyName = safemalloc(strlen(temp)+2); strcpy(MyName,"*"); strcat(MyName, temp); Clength = strlen(MyName); if((argc != 6)&&(argc != 7)) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName, VERSION); exit(1); } /* Dead pipe == dead fvwm */ signal (SIGPIPE, DeadPipe); fd[0] = atoi(argv[1]); fd[1] = atoi(argv[2]); /* An application window may have already been selected - look for it */ sscanf(argv[4],"%x",(unsigned int *)&app_win); /* Open the Display */ if (!(dpy = XOpenDisplay(display_name))) { fprintf(stderr,"%s: can't open display %s", MyName, XDisplayName(display_name)); exit (1); } x_fd = XConnectionNumber(dpy); screen= DefaultScreen(dpy); Root = RootWindow(dpy, screen); d_depth = DefaultDepth(dpy, screen); ScreenHeight = DisplayHeight(dpy,screen); ScreenWidth = DisplayWidth(dpy,screen); 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); /* scan config file for set-up parameters */ /* Colors and fonts */ GetConfigLine(fd,&tline); while(tline != (char *)0) { if(strlen(tline)>1) { if(strncasecmp(tline, CatString3(MyName,"Font",""),Clength+4)==0) { CopyString(&font_string,&tline[Clength+4]); } else if(strncasecmp(tline,CatString3(MyName,"Fore",""), Clength+4)==0) { CopyString(&ForeColor,&tline[Clength+4]); } else if(strncasecmp(tline,CatString3(MyName, "Back",""), Clength+4)==0) { CopyString(&BackColor,&tline[Clength+4]); } } GetConfigLine(fd,&tline); } if(app_win == 0) GetTargetWindow(&app_win); fd_width = GetFdWidth(); /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendInfo(fd,"Send_WindowList",0); Loop(fd); return 0; }
int main(int argc, char *argv[]) { #ifdef USERC char match[128]; int config_line_count, len; char *config_line; #endif console = fopen("/dev/console","w"); if (!console) console = stderr; if (!(argv0 = strrchr(argv[0],'/'))) argv0 = argv[0]; else ++argv0; if (argc < 6) { fprintf(stderr, #ifdef FVWM1 "%s: module should be executed by fvwm only\n", #else "%s: module should be executed by fvwm2 only\n", #endif argv0); exit(-1); } fd[0] = atoi(argv[1]); fd[1] = atoi(argv[2]); if (!(dpy = XOpenDisplay(NULL))) { fprintf(console, "%s: couldn't open display %s\n", argv0, XDisplayName(NULL)); exit(-1); } signal (SIGPIPE, DeadPipe); { int s = DefaultScreen(dpy); dwidth = DisplayWidth(dpy, s); dheight = DisplayHeight(dpy, s); } fd_width = GetFdWidth(); #ifdef USERC strcpy(match, "*"); strcat(match, argv0); len = strlen(match); #ifdef FVWM1 if ((config_line = GetConfigLine(argv[3], match))) { char **args = NULL; config_line_count = parse_line(config_line, &args); parse_args("config args", config_line_count, args, 0); free(config_line); free(args); } #else GetConfigLine(fd, &config_line); while (config_line != NULL) { if (strncmp(match,config_line,len)==0) { char **args = NULL; int cllen = strlen(config_line); if (config_line[cllen - 1] == '\n') config_line[cllen - 1] = 0; config_line_count = parse_line(config_line, &args); parse_args("config args", config_line_count, args, 0); free(args); } GetConfigLine(fd, &config_line); } #endif /* FVWM1 */ #endif /* USERC */ if (strcmp(argv0, "FvwmCascade") && (!strcmp(argv0, "FvwmTile") || (argc >= 7 && !strcmp(argv[6], "-tile")))) { FvwmTile = 1; FvwmCascade = 0; resize = 1; } else { FvwmCascade = 1; FvwmTile = 0; resize = 0; } parse_args("module args", argc, argv, 6); #ifdef FVWM1 { char msg[256]; sprintf(msg, "SET_MASK %lu\n",(unsigned long)( M_CONFIGURE_WINDOW| M_END_WINDOWLIST )); SendInfo(fd,msg,0); #ifdef FVWM1_MOVENULL /* avoid interactive placement in fvwm version 1 */ if (!ofsx) ++ofsx; if (!ofsy) ++ofsy; #endif } #else SetMessageMask(fd, M_CONFIGURE_WINDOW | M_END_WINDOWLIST ); #endif if (FvwmTile) { if (!maxx) maxx = dwidth; if (!maxy) maxy = dheight; } SendInfo(fd,"Send_WindowList",0); 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; }