//========================================= // prepare when ready //----------------------------------------- void prepare (void) { int count; char disp[80] = ""; if (displayname != NULL) { sprintf(disp,"DISPLAY=%s",displayname); putenv (disp); } //========================================= // start windowmanager... //----------------------------------------- wmpid = fork(); switch(wmpid) { case -1: perror("fork"); exit(1); break; case 0: execl(FVWM,"fvwm2","-f",FVWMRC,NULL); break; default: waitpid ( wmpid, NULL, WNOHANG | WUNTRACED ); } //========================================= // enable accessX... //----------------------------------------- XAccess(dpy,displayname); //========================================= // set the fashion style for all displays // including Xinerama handling here... //------------------------------------------ CountScreens (dpy); for (count = 0;count < scr_count; count++) { int bannerpid; int current_screen = scr[count]; Window root = RootWindow(dpy, current_screen); int depth = DefaultDepth(dpy,current_screen); char* display = (char*)malloc(sizeof(char)*128); char* dspstr = (char*)malloc(sizeof(char)*128); char* color = (char*)malloc(sizeof(char)*128); char screenStr [255] = ""; char x [128] = ""; char y [128] = ""; int x1,y1,width,height; GC mgc = DefaultGC(dpy,current_screen); Cursor cursor; //========================================= // set the background to darkSlateBlue //----------------------------------------- sprintf(color,"MidnightBlue"); if (blank) { sprintf(color,"black"); } XSetWindowBackground( dpy, root, NameToPixel( color,BlackPixel(dpy,current_screen),dpy,current_screen ) ); XClearWindow(dpy,root); XSetCloseDownMode(dpy, RetainPermanent); usleep (1000); if (blank) { XFlush(dpy); } //========================================= // set the corner marks //----------------------------------------- if (! blank) { setCorner ("10x15-0-0",dpy,current_screen); setCorner ("10x15-0+0",dpy,current_screen); setCorner ("10x15+0-0",dpy,current_screen); setCorner ("10x15+0+0",dpy,current_screen); //========================================= // set the bounding rectangle //----------------------------------------- setBounding (dpy,current_screen); //========================================= // set the SuSE Linux banner //----------------------------------------- if (DisplayPlanes (dpy, current_screen) >= 8) { sprintf(dspstr,"%s",displayname); dspstr = strtok (dspstr,"."); sprintf(display,"%s.%d",dspstr,current_screen); sprintf(x,"%d",DisplayWidth (dpy,current_screen) - 150); sprintf(y,"%d",DisplayHeight (dpy,current_screen) - 80); bannerpid = fork(); switch(bannerpid) { case -1: perror("fork"); exit(1); break; case 0: execl ( XBanner,"xbanner", "-file",XBannerFile,"-display",display, "-px",x,"-py",y,NULL ); break; default: waitpid ( bannerpid, NULL, 0 ); } //=================================================== // create a xlook banner on all non primary screen // pointing out, that this screen is not the one // the configuration program is running on //--------------------------------------------------- if (current_screen > 0) { int HasRender; sprintf(screenStr,"%s %d. %s 1.", gettext("Display"),count+1, gettext("Configuration on display") ); HasRender = XTestRender (dpy); if (! HasRender) { break; } img = setText ( dpy,current_screen,screenStr,&imgx,&imgy ); } //========================================= // set save area of the root window to be // restored on demand //----------------------------------------- x1 = DisplayWidth (dpy,current_screen) - 380; y1 = DisplayHeight (dpy,current_screen) - 120; width = 380; height = 120; save[current_screen].width = width; save[current_screen].height = height; save[current_screen].x1 = x1; save[current_screen].y1 = y1; save[current_screen].bg = XCreatePixmap ( dpy,root,width,height,depth ); XCopyArea ( dpy,root,save[current_screen].bg,mgc,x1,y1,width,height,0,0 ); } //========================================= // set the cursor look and feel //----------------------------------------- cursor = CreateCursorFromName(dpy,current_screen,"top_left_arrow"); if (cursor) { XDefineCursor (dpy,root,cursor); XFreeCursor (dpy,cursor); } } } //========================================= // Enter main loop, restore and redraw //----------------------------------------- if (! blank) { looppid = fork(); switch (looppid) { case -1: perror("fork"); exit(1); break; case 0: while(1) { usleep (50000); RedrawWindow(); } break; } } }
int main (int argc, char **argv) { Cursor cursor; Display *display; Window root, blub, *blubs = NULL; unsigned clients; unsigned long pixel; char *cname; XColor color; int cnt; Atom prop; Pixmap save_pixmap = (Pixmap)None; display = XOpenDisplay(NULL); if(!display) return 1; cname = argc == 2 ? argv[1] : "black"; screen = DefaultScreen(display); root = RootWindow(display, screen); pixel = BlackPixel(display, screen); if(XParseColor(display, DefaultColormap(display, screen), cname, &color)) { if(XAllocColor(display, DefaultColormap(display, screen), &color)) { pixel = color.pixel; } } XSetWindowBackground(display, root, pixel); XClearWindow(display, root); cursor = CreateCursorFromName(display,"watch"); if (cursor) { XDefineCursor (display, root, cursor); XFreeCursor (display, cursor); } if (fork() == 0) { Window win; XEvent xev; close(0); close(1); close(2); chdir("/"); display = XOpenDisplay(NULL); // open a client... if (display) { win = XCreateSimpleWindow ( display, root, 0, 0, 1, 1, 0, 0, pixel ); XSync(display, False); } // wait within event loop... for(;;) XNextEvent(display, &xev); } // wait until the child has opened a client cnt = 100; do { if (!XQueryTree (display, root, &blub, &blub, &blubs, &clients)) { XCloseDisplay(display); return 0; } usleep(50000); } while(clients < 1 && cnt--); save_pixmap = XCreatePixmap (display, root, 1, 1, 1); prop = XInternAtom (display, "_XSETROOT_ID", False); XChangeProperty ( display, root, prop, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &save_pixmap, 1 ); XSetCloseDownMode (display, RetainPermanent); // enable accessX // XAccess (display,NULL); XCloseDisplay(display); RunWindowManager(); return 0; }
int main (int argc, char **argv) { Cursor cursor; Display *display; Window root; unsigned long pixel; char *cname; XColor color; Atom prop; Pixmap save_pixmap = (Pixmap)None; //============================================ // open display and check if we got a display //-------------------------------------------- display = XOpenDisplay(NULL); if (!display) { exit (1); } if ((argc == 2) && (strcmp (argv[1],"--fast") == 0)) { XCloseDisplay(display); exit (0); } #if 0 // disabled: for details see bug: #273147 //============================================ // check the resolution //-------------------------------------------- if (!validResolution(display)) { fprintf (stderr, "testX: invalid dimensions, must be >= %dx%d Pixels\n", MIN_X,MIN_Y ); exit (2); } #endif //============================================ // install color map for background pixels //-------------------------------------------- cname = argc == 2 ? argv[1] : "black"; screen = DefaultScreen(display); root = RootWindow(display, screen); pixel = BlackPixel(display, screen); if(XParseColor(display, DefaultColormap(display, screen), cname, &color)) { if(XAllocColor(display, DefaultColormap(display, screen), &color)) { pixel = color.pixel; } } XSetWindowBackground(display, root, pixel); XClearWindow (display, root); //============================================ // set watch cursor //-------------------------------------------- cursor = CreateCursorFromName(display,"top_left_arrow"); if (cursor) { XDefineCursor (display, root, cursor); XFreeCursor (display, cursor); } //============================================ // run the windowmanager (FVWM) //-------------------------------------------- RunWindowManager(); //============================================ // save background as pixmap //-------------------------------------------- save_pixmap = XCreatePixmap ( display, root, 1, 1, 1 ); prop = XInternAtom (display, "_XSETROOT_ID", False); XChangeProperty ( display, root, prop, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &save_pixmap, 1 ); XSetCloseDownMode ( display, RetainPermanent ); //============================================ // enable accessX modifiers //-------------------------------------------- // XAccess (display,NULL); //============================================ // close display and exit //-------------------------------------------- XCloseDisplay(display); exit (0); }
int main(int argc, char** argv) { Cursor cursor; Display *display; Window root; unsigned long pixel; char* cname; XColor color; Atom prop; Pixmap save_pixmap = (Pixmap)None; //============================================ // open display and check if we got a display //-------------------------------------------- display = XOpenDisplay(NULL); if (!display) { exit (1); } if ((argc == 2) && (strcmp(argv[1], "--fast") == 0)) { XCloseDisplay(display); exit (0); } //============================================ // install color map for background pixels //-------------------------------------------- cname = argc == 2 ? argv[1] : "black"; screen = DefaultScreen(display); root = RootWindow(display, screen); pixel = BlackPixel(display, screen); if (XParseColor(display, DefaultColormap(display, screen), cname, &color)) { if (XAllocColor(display, DefaultColormap(display, screen), &color)) { pixel = color.pixel; } } XSetWindowBackground(display, root, pixel); XClearWindow(display, root); //============================================ // set watch cursor //-------------------------------------------- cursor = CreateCursorFromName(display, "top_left_arrow"); if (cursor) { XDefineCursor(display, root, cursor); XFreeCursor(display, cursor); } //============================================ // run the windowmanager (FVWM) //-------------------------------------------- RunWindowManager(); //============================================ // save background as pixmap //-------------------------------------------- save_pixmap = XCreatePixmap(display, root, 1, 1, 1); prop = XInternAtom(display, "_XSETROOT_ID", False); XChangeProperty(display, root, prop, XA_PIXMAP, 32, PropModeReplace, (unsigned char*) &save_pixmap, 1); XSetCloseDownMode(display, RetainPermanent); //============================================ // close display and exit //-------------------------------------------- XCloseDisplay(display); exit (0); }