Beispiel #1
0
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;
}
Beispiel #2
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);
}
Beispiel #3
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);
}