static void redraw_handler(struct widget *widget, void *data) { struct window *window; struct rectangle allocation; cairo_t *cr; widget_get_allocation(widget, &allocation); window = widget_get_user_data(widget); cr = widget_cairo_create(widget); cairo_translate(cr, allocation.x, allocation.y); /* Draw background. */ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); set_window_background_colour(cr, window); cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); cairo_fill(cr); /* Print the instructions. */ cairo_move_to(cr, 5, 15); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); draw_string(cr, "Window: %p\n" "Fullscreen? %u\n" "Maximized? %u\n" "Transient? %u\n" "Keys: (f)ullscreen, (m)aximize,\n" " (n)ew window, (p)opup,\n" " (q)uit, (t)ransient window\n", window, window_is_fullscreen(window), window_is_maximized(window), window_get_parent(window) ? 1 : 0); cairo_destroy(cr); }
void parse_config_line(lstate *state, char *buf, int lineno) { char *p, *pp, *name, *icon; int n; litem *new_litem, *li; ssitem *new_ssitem, *tmp_ssitem; stitem *new_stitem, *tmp_stitem; GR_IMAGE_INFO imageinfo; p = buf; if((!*p) || (*p == '#') || (*p == '\n')) return; while(isspace(*p)) p++; name = p; while(*p && (!isspace(*p))) p++; if(!*p) goto premature; *p++ = 0; if(!strcmp(name, "$screensaver")) { new_ssitem = my_malloc(sizeof(ssitem)); if(!(new_ssitem->prog = make_prog_item(p, lineno))) { free(new_ssitem); return; } state->numssitems++; new_ssitem->next = NULL; if(!state->ssitems) state->ssitems = new_ssitem; else { tmp_ssitem = state->ssitems; while(tmp_ssitem->next) tmp_ssitem = tmp_ssitem->next; tmp_ssitem->next = new_ssitem; } return; } else if(!strcmp(name, "$startup")) { new_stitem = my_malloc(sizeof(stitem)); if(!(new_stitem->prog = make_prog_item(p, lineno))) { free(new_stitem); return; } new_stitem->next = NULL; if(!state->stitems) state->stitems = new_stitem; else { tmp_stitem = state->stitems; while(tmp_stitem->next) tmp_stitem = tmp_stitem->next; tmp_stitem->next = new_stitem; } return; } else if(!strcmp(name, "$screensaver_timeout")) { n = strtol(p, NULL, 10); GrSetScreenSaverTimeout(n); return; } else if(!strcmp(name, "$screensaver_rotate_time")) { state->rotatess = strtol(p, NULL, 10); return; } else if(!strcmp(name, "$random_screensaver")) { srand(time(0)); state->randomss = 1; return; } else if(!strcmp(name, "$window_background_image")) { while(isspace(*p)) p++; if(!*p) goto premature; pp = p; while(*p && (!isspace(*p))) p++; *p = 0; state->window_background_image = strdup(pp); return; } else if(!strcmp(name, "$window_background_mode")) { state->window_background_mode = (int) strtol(p, NULL, 10); return; } else if(!strcmp(name, "$window_background_colour")) { set_window_background_colour(p, lineno); return; } while(isspace(*p)) p++; if(!*p) goto premature; icon = p; while(*p && (!isspace(*p))) p++; if(!*p) goto premature; *p++ = 0; new_litem = my_malloc(sizeof(litem)); if(!(new_litem->name = strdup(name))) { free(new_litem); goto nomem; } if(!(new_litem->icon = strdup(icon))) { free(new_litem->name); free(new_litem); goto nomem; } if(!(new_litem->prog = make_prog_item(p, lineno))) { free(new_litem->name); free(new_litem->icon); free(new_litem); return; } new_litem->iconid = 0; if(strcmp("-", icon)) { li = state->litems; while(li) { if(!(strcmp(icon, li->name))) { new_litem->iconid = li->iconid; break; } li = li->next; } if(!new_litem->iconid) { if(!(new_litem->iconid = GrLoadImageFromFile(icon, 0))){ GrError("Couldn't load icon \"%s\"\n", icon); } else { GrGetImageInfo(new_litem->iconid, &imageinfo); if((imageinfo.width != ICON_WIDTH) || (imageinfo.height != ICON_HEIGHT)) { GrError("Icon \"%s\" is the " "wrong size (%dx%d instead of %dx%d)" "\n", icon, imageinfo.width, imageinfo.height, ICON_WIDTH, ICON_HEIGHT); GrFreeImage(new_litem->iconid); new_litem->iconid = 0; } } } } new_litem->prev = NULL; new_litem->next = NULL; if(!state->litems) { state->lastlitem = new_litem; state->litems = new_litem; } else { new_litem->next = state->litems; state->litems->prev = new_litem; state->litems = new_litem; } state->numlitems++; return; nomem: GrError("Out of memory\n"); exit(1); premature: GrError("Premature end of line on line %d of config file\n", lineno); }