Ejemplo n.º 1
0
int main(int argc, char **argv)
{
    XEvent event;
    XpmColorSymbol colors[2] = { {"Back0", NULL, 0}, {"Back1", NULL, 0} };
    int ncolor = 0;

    /* Parse CommandLine */
    parse_arguments(argc, argv);

    /* Initialize Application */
    dockapp_open_window(display_name, PACKAGE, SIZE, SIZE, argc, argv);
    dockapp_set_eventmask(ButtonPressMask);

    if (light_color) {
	colors[0].pixel = dockapp_getcolor(light_color);
	colors[1].pixel = dockapp_blendedcolor(light_color, -24, -24, -24, 1.0);
	ncolor = 2;
    }

    /* change raw xpm data to pixmap */
    if (dockapp_iswindowed)
	backdrop_on_xpm[1] = backdrop_off_xpm[1] = WINDOWED_BG;
    if (!is_led_style) {
	dockapp_xpm2pixmap(backdrop_on_xpm, &backdrop_on, &mask, colors,ncolor);
	dockapp_xpm2pixmap(backdrop_off_xpm, &backdrop_off, NULL, NULL, 0);
    } else {
	dockapp_xpm2pixmap(backdrop_led_xpm, &backdrop_led, &mask, colors, ncolor);
    }
    dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor);
    /* shape window */
    if (!dockapp_iswindowed)
	dockapp_setshape(mask, 0, 0);
    if (mask) XFreePixmap(display, mask);
    /* pixmap: draw area */
    pixmap = dockapp_XCreatePixmap(SIZE, SIZE);

    /* Initialize pixmap */
    longrun_init(cpuid_dev, msr_dev);
    update();
    dockapp_set_background(pixmap);
    dockapp_show();

    /* Main loop */
    for (;;) {
	if (dockapp_nextevent_or_timeout(&event, update_interval)) {
	/* Next Event */
	    switch(event.type) {
		case ButtonPress:
		    if (!is_led_style) {  /* led does not have back-light */
			switch_light();
			update();
		    }
		    break;
		default: /* make gcc happy */
		    break;
	    }
	} else {
	/* Time Out */
	    update();
	}
    }

    return 0;
}
Ejemplo n.º 2
0
int
main(int argc, char **argv)
{
    XEvent event;
    XpmColorSymbol colors[2] = { {"Back0", NULL, 0}, {"Back1", NULL, 0} };
    int ncolor = 0;

    /* Parse Command-Line */
    cpu_opts.ignore_nice = False;
    cpu_opts.cpu_number = CPUNUM_NONE;
    cpu_opts.ignore_procs = 0;
    parse_arguments(argc, argv);

    /* Initialize Application */
    cpu_init();
    dockapp_open_window(display_name, title == NULL ? PACKAGE : title,
			SIZE, SIZE, argc, argv);
    dockapp_set_eventmask(ButtonPressMask);

    if (light_color) {
	colors[0].pixel = dockapp_getcolor_pixel(light_color);
	colors[1].pixel = dockapp_blendedcolor(light_color, -24, -24, -24, 1.0);
	ncolor = 2;
    }

    /* change raw xpm data to pixmap */
    if (dockapp_stat == WINDOWED_WITH_PANEL) {
	backlight_on_xpm[1] = backlight_off_xpm[1] = WINDOWED_BG;
    }
    dockapp_xpm2pixmap(backlight_on_xpm, &backdrop_on, &mask, colors, ncolor);
    dockapp_xpm2pixmap(backlight_off_xpm, &backdrop_off, NULL, NULL, 0);
    dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor);
    /* shape window */
    if (dockapp_stat == DOCKABLE_ICON || dockapp_stat == WINDOWED) {
	dockapp_setshape(mask, 0, 0);
    }
    if (mask) XFreePixmap(display, mask);
    /* pixmap : draw area */
    pixmap = dockapp_XCreatePixmap(SIZE, SIZE);
    pix_chartbuf = dockapp_XCreatePixmap(SIZE, SIZE);

    /* Initialize pixmap */
    if (backlight == LIGHTON) {
	dockapp_copyarea(backdrop_on, pixmap, 0, 0, SIZE, SIZE, 0, 0);
    } else {
	dockapp_copyarea(backdrop_off, pixmap, 0, 0, SIZE, SIZE, 0, 0);
    }
    dockapp_set_background(pixmap);
    dockapp_show();

    /* Main loop */
    for (;;) {
	if (dockapp_nextevent_or_timeout(&event, update_interval * 1000)) {
	/* Next Event */
	    switch(event.type) {
		case ButtonPress:
		    switch_light();
		    break;
		default: /* make gcc happy */
		    break;
	    }
	} else {
	/* Time Out */
	    update();
	}
    }

    return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {
    XEvent event;
    XpmColorSymbol colors[2] = { {"Back0", NULL, 0}, {"Back1", NULL, 0} };
    int ncolor = 0;
    struct sigaction sa;

    sa.sa_handler = SIG_IGN;
    sa.sa_flags = SA_NOCLDWAIT;

    sigemptyset(&sa.sa_mask);
    sigaction(SIGCHLD, &sa, NULL);

    /* Parse CommandLine */
    parse_arguments(argc, argv);

    /* Initialize Application */

    dockapp_open_window(display_name, PACKAGE, SIZE, SIZE, argc, argv);
    dockapp_set_eventmask(ButtonPressMask);

    if(light_color) {
        colors[0].pixel = dockapp_getcolor(light_color);
        colors[1].pixel =
            dockapp_blendedcolor(light_color, -24, -24, -24, 1.0);
        ncolor = 2;
    }

    /* change raw xpm data to pixmap */
    if(dockapp_iswindowed)
        backlight_on_xpm[1] = backlight_off_xpm[1] = WINDOWED_BG;

    if(!dockapp_xpm2pixmap(backlight_on_xpm, &backdrop_on, &mask, colors, ncolor)) {
        fprintf(stderr, "Error initializing backlit background image.\n");
        exit(1);
    }
    if(!dockapp_xpm2pixmap(backlight_off_xpm, &backdrop_off, NULL, NULL, 0)) {
        fprintf(stderr, "Error initializing background image.\n");
        exit(1);
    }
    if(!dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor)) {
        fprintf(stderr, "Error initializing parts image.\n");
        exit(1);
    }

    /* shape window */
    if(!dockapp_iswindowed)
        dockapp_setshape(mask, 0, 0);
    if(mask)
        XFreePixmap(display, mask);

    /* pixmap : draw area */
    pixmap = dockapp_XCreatePixmap(SIZE, SIZE);

    /* Initialize pixmap */
    if(backlight == LIGHTON)
        dockapp_copyarea(backdrop_on, pixmap, 0, 0, SIZE, SIZE, 0, 0);
    else
        dockapp_copyarea(backdrop_off, pixmap, 0, 0, SIZE, SIZE, 0, 0);

    dockapp_set_background(pixmap);
    dockapp_show();

    /* initialize ibam */
    i.update();
    if(i.valid())
        i.update_statistics();
    else
        i.ignore_statistics();
    i.save();

    update();

    /* Main loop */
    while(1) {
        if(dockapp_nextevent_or_timeout(&event, update_interval * 1000)) {
            /* Next Event */
            switch(event.type) {
            case ButtonPress:
                switch(event.xbutton.button) {
                case 1:
                    switch_light();
                    break;
                case 2:
                    if(event.xbutton.state == ControlMask)
                        my_system((char *)(suspend_cmd ? suspend_cmd : SUSPEND_CMD));	/* Suspend */
                    else
                        my_system((char *)(standby_cmd ? standby_cmd : STANDBY_CMD));	/* Standby */
                    break;
                case 3:
                    switch_authorized = !switch_authorized;
                    break;
                default:
                    break;
                }
                break;
            default:
                break;
            }
        } else {
            /* Time Out */
            update();
        }
    }

    return 0;
}