コード例 #1
0
ファイル: time.c プロジェクト: MichalPokorny/xosdutil
static int hide(void* r) {
	int f = 0;
	time_renderer_data* _r = r;

	if (_r && _r->osd) {
		if (xosd_hide(_r->osd) != 0) {
			msg("xosd_hide failed: %s\n", xosd_error);
			f = 1;
		}
	} else {
		msg("Error: hiding an uninitialized time renderer.\n");
		f = 1;
	}
	return f;
}
コード例 #2
0
ファイル: xmms_osd.c プロジェクト: skripac/libxosd
/*
 * Free memory and release resources.
 */
static void cleanup(void)
{
  DEBUG("cleanup");
  assert(osd);
  if (timeout_tag)
    gtk_timeout_remove(timeout_tag);
  timeout_tag = 0;

  if (font) {
    g_free (font);
    font=NULL;
  }

  if (colour) {
    g_free (colour);
    colour=NULL;
  }

  save_previous_title(NULL);

  xosd_hide (osd);
  xosd_uninit (osd);
  osd=NULL;
}
コード例 #3
0
ファイル: xosd.c プロジェクト: mboeh/ruby-xosd
/* A "safe" version of xosd_hide that doesn't re-hide the OSD if it's hidden. */
void safe_hide(xosd* osd) {
  if (chkerror(xosd_is_onscreen(osd))) {
    chkerror(xosd_hide(osd));
  }
}
コード例 #4
0
ファイル: sublim.c プロジェクト: enkiv2/asublim
	--screen-height	Specify screen height\n\n";
int main(int argc, char** argv) {
	signal(SIGINT, intHandler);
	
	xosd *osd;

	Display* d=XOpenDisplay(":0");
	
	int screenCount = ScreenCount(d);
	fprintf(stderr, "\nNumber of screens: %d\n", screenCount);
	int i;
	for (i=0; i<screenCount ; i++) {
		fprintf(stderr, " %d: %dx%x\n", i, DisplayWidth(d, i), DisplayHeight(d, i));
	}	

	int timeout;
	char* color="LawnGreen";
	char* font="-*-fixed-*-*-*-*-15-140-*-*-*-*-*-*";
	FILE* input=stdin;
	int delayShowMax=10000;
	int delayShowMin=1000;
	int delayWordMax=50;
	int delayWordMin=10;

	int screenWidthOverride=0;
	int screenHeightOverride=0;

	int ret;
	while((ret=getopt_long(argc, argv, ASublimOptString, lopts, NULL)) != -1) {
		switch(ret) {
			case 'S':
				delayShowMax=atoi(optarg);
				break;
			case 's':
				delayShowMin=atoi(optarg);
				break;
			case 'D':
				delayWordMax=atoi(optarg);
				break;
			case 'd':
				delayWordMin=atoi(optarg);
				break;
			case 't':
				timeout=atoi(optarg);
				break;
			case 'f':
				font=strncpy(malloc(strlen(optarg)+1), optarg, strlen(optarg)+1);
				break;
			case 'c':
				color=malloc(strlen(optarg));
				color=strncpy(malloc(strlen(optarg)+1), optarg, strlen(optarg)+1);
				break;
			case 'F':
				input=fopen(optarg, "r");
				if(errno) {
					fprintf(stderr, "File error! Defaulting to stdin.\n");
					input=stdin;
				}
				break;
			case 'w':
				screenWidthOverride=atoi(optarg);
				break;
			case 'y':
				screenHeightOverride=atoi(optarg);
				break;
			case 'h':
			case '?':
				fprintf(stderr, "Usage: %s %s", argv[0], helpstr);
				exit(0);
				break;
		}
	}

	osd = xosd_create(1);
	if(xosd_set_font(osd, font)==-1) {
		fprintf(stderr, "Font not found\n");
		exit(1);
	}
	if(xosd_set_colour(osd, color)==-1) {
		fprintf(stderr, "Color set error\n");
		exit(1);
	}
	if(xosd_set_timeout(osd, timeout)==-1) {
		fprintf(stderr, "Timeout set error\n");
		exit(1);
	}

	xosd_set_shadow_offset(osd, 3);
	srand48(time(NULL));
	char* buf=calloc(1025, sizeof(char));

	int height=screenHeightOverride;
	int width=screenWidthOverride;
	ret=fscanf(input, "%1024s", buf);
	while(buf[0]!=EOF && ret>0) {
		int screen = lrand48() % screenCount;
		if (!(screenWidthOverride && screenHeightOverride)) {
			height=	DisplayHeight(d, screen);
			width=	DisplayWidth(d, screen);
		}
		xosd_set_vertical_offset(osd, lrand48()%height);
		xosd_set_horizontal_offset(osd, lrand48()%width);
		xosd_display(osd, screen, XOSD_string, buf);
		
		xosd_show(osd);
		usleep((unsigned int)((lrand48()%(delayShowMax-delayShowMin)))+delayShowMin);
		xosd_hide(osd);
		
		ret=fscanf(input, "%1024s", buf);
		usleep((unsigned int)((lrand48()%(delayWordMax-delayWordMin)))+delayWordMin);
	}
	
	xosd_wait_until_no_display(osd);
	xosd_destroy(osd);

	return 0;
}