static Disp_Obj * default_x_display(SINGLE_QSP_ARG_DECL) { const char *dname; Disp_Obj *dop; int which_depth; char *s; dname = check_display(SINGLE_QSP_ARG); /* these two lines added so this can be called more than once */ dop = disp_obj_of(QSP_ARG dname); if( dop != NO_DISP_OBJ ) return(dop); s=getenv("DESIRED_DEPTH"); if( s != NULL ){ int desired_depth; desired_depth=atoi(s); sprintf(ERROR_STRING,"Desired depth %d obtained from environment",desired_depth); advise(ERROR_STRING); dop = open_display(QSP_ARG dname,desired_depth); if( dop != NO_DISP_OBJ ) return(dop); sprintf(ERROR_STRING,"Unable to open display %s with $DESIRED_DEPTH (%d)", dname,desired_depth); NWARN(ERROR_STRING); } for(which_depth=0;which_depth<MAX_DISPLAY_DEPTHS;which_depth++){ dop = open_display(QSP_ARG dname,possible_depths[which_depth]); if( dop != NO_DISP_OBJ ){ if( verbose ){ sprintf(ERROR_STRING, "Using depth %d on display %s", possible_depths[which_depth],dname); advise(ERROR_STRING); } return(dop); } else { if( verbose && which_depth<(MAX_DISPLAY_DEPTHS-1) ){ sprintf(ERROR_STRING, "Couldn't get %d bit visual on device %s, trying %d", possible_depths[which_depth],dname, possible_depths[which_depth+1]); advise(ERROR_STRING); } } } if( verbose ){ sprintf(ERROR_STRING, "Couldn't get %d bit visual on device %s, giving up", possible_depths[MAX_DISPLAY_DEPTHS-1],dname); advise(ERROR_STRING); } return(dop); } /* end default_x_display */
// Print the current idle time static void print_idle_time() { open_display(); XScreenSaverInfo ssi; int event_basep, error_basep; // Create sigaction struct struct sigaction act; memset(&act, '\0', sizeof(act)); // Use the sa_sigaction field because the handles // have two additional parameters act.sa_sigaction = &signal_callback_handler; // The SA_SIGINFO flag tells sigaction() to use the // sa_sigaction field, not sa_handler. act.sa_flags = SA_SIGINFO; // Register signal and signal handler if(sigaction(SIGTERM, &act, NULL) < 0) { perror(_("Error: sigaction")); exit(EXIT_FAILURE); } // Enable line buffering on stdout setlinebuf(stdout); // Get the current idle time check_xss_supported(event_basep, error_basep); try_xss_query(ssi); printf("%lu\n", workaroundX11(dpy, ssi.idle)); }
/* * Vstupní bod programu */ int main(int argc, char *argv[]) { progname = argv[0]; open_display(); create_resources(argc, argv); event_loop(); close_display(); return 0; }
int main (int argc, char **argv) { GstElement *pipeline; GstBus *bus; #ifndef GST_DISABLE_PARSE GError *error = NULL; #endif gst_init (&argc, &argv); if (argc != 2) { g_print ("Usage: %s \"pipeline description with launch format\"\n", argv[0]); g_print ("The pipeline should contain an element implementing XOverlay.\n"); g_print ("Example: %s \"videotestsrc ! ximagesink\"\n", argv[0]); return -1; } #ifdef GST_DISABLE_PARSE g_print ("GStreamer was built without pipeline parsing capabilities.\n"); g_print ("Please rebuild GStreamer with pipeline parsing capabilities activated to use this example.\n"); return 1; #else pipeline = gst_parse_launch (argv[1], &error); if (error) { g_print ("Error while parsing pipeline description: %s\n", error->message); return -1; } #endif loop = g_main_loop_new (NULL, FALSE); open_display (); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, pipeline); gst_element_set_state (pipeline, GST_STATE_PLAYING); /* We want to get out after */ //g_timeout_add (500000, (GSourceFunc) terminate_playback, pipeline); g_timeout_add (10000, (GSourceFunc) pause_playback, pipeline); g_timeout_add (20000, (GSourceFunc) start_playback, pipeline); g_main_loop_run (loop); close_display (); g_main_loop_unref (loop); return 0; }
static COMMAND_FUNC( do_new_do ) { const char *s; s=NAMEOF("display"); #ifdef HAVE_X11 if( open_display(s,8) == NULL ){ sprintf(ERROR_STRING,"unable to open %s",s); WARN(ERROR_STRING); } #endif /* HAVE_X11 */ }
extern void init_wm(struct wm * wm, unsigned options) { std::call_once(one_time_init_flag, one_time_init, wm, options); assert(wm); Display * d = open_display(); int default_screen = XDefaultScreen(d); assert(d); wm->display = d; wm->default_screen = default_screen; }
static COMMAND_FUNC( do_open_do ) { const char *s; int d; s=NAMEOF("display"); d=HOW_MANY("desired bit depth"); #ifdef HAVE_X11 if( open_display(s,d) == NULL ){ sprintf(ERROR_STRING,"unable to open %s",s); WARN(ERROR_STRING); } #endif /* HAVE_X11 */ }
int main(int argc, char *argv[]) { if (!open_display()) { printf("Cannot open display\n"); return 1; } init_atoms(); iterate_client_list(get_number_of_desktops()); event_loop(); XCloseDisplay (dpy); return 0; }
/*-----------------------------------------------------------------*/ main (int argc, char **argv) { static char bits[256]; if (argc!=2) { printf ("BARGRA <codigo>\n"); exit(1); } open_display (); monta_bar (argv[1], bits); print_i25 (bits); getch(); close_display (); return(0); }
/* * Vstupní bod programu */ int main(int argc, char *argv[]) { progname = argv[0]; if(argc != 3) usage(); if(!strcmp(argv[1], "Forget")) bit_gravity = ForgetGravity; else if(!strcmp(argv[1], "Static")) bit_gravity = StaticGravity; else if(!strcmp(argv[1], "NorthWest")) bit_gravity = NorthWestGravity; else if(!strcmp(argv[1], "North")) bit_gravity = NorthGravity; else if(!strcmp(argv[1], "NorthEast")) bit_gravity = NorthEastGravity; else if(!strcmp(argv[1], "West")) bit_gravity = WestGravity; else if(!strcmp(argv[1], "Center")) bit_gravity = CenterGravity; else if(!strcmp(argv[1], "East")) bit_gravity = EastGravity; else if(!strcmp(argv[1], "SouthWest")) bit_gravity = SouthWestGravity; else if(!strcmp(argv[1], "South")) bit_gravity = SouthGravity; else if(!strcmp(argv[1], "SouthEast")) bit_gravity = SouthEastGravity; else usage(); if(!strcmp(argv[2], "Unmap")) win_gravity = UnmapGravity; else if(!strcmp(argv[2], "Static")) win_gravity = StaticGravity; else if(!strcmp(argv[2], "NorthWest")) win_gravity = NorthWestGravity; else if(!strcmp(argv[2], "North")) win_gravity = NorthGravity; else if(!strcmp(argv[2], "NorthEast")) win_gravity = NorthEastGravity; else if(!strcmp(argv[2], "West")) win_gravity = WestGravity; else if(!strcmp(argv[2], "Center")) win_gravity = CenterGravity; else if(!strcmp(argv[2], "East")) win_gravity = EastGravity; else if(!strcmp(argv[2], "SouthWest")) win_gravity = SouthWestGravity; else if(!strcmp(argv[2], "South")) win_gravity = SouthGravity; else if(!strcmp(argv[2], "SouthEast")) win_gravity = SouthEastGravity; else usage(); open_display(); create_resources(argc, argv); event_loop(); close_display(); return 0; }
int main(int argc,char **argv) { int major_ver, minor_ver; VAStatus va_status; pthread_t thread1; int ret; char c; int i; char str_src_fmt[5], str_dst_fmt[5]; static struct option long_options[] = { {"fmt1", required_argument, NULL, '1'}, {"fmt2", required_argument, NULL, '2'}, {0, 0, 0, 0} }; while ((c =getopt_long(argc,argv,"w:h:g:r:d:f:tcep?n:1:2:v", long_options, NULL)) != EOF) { switch (c) { case '?': printf("putsurface <options>\n"); printf(" -g <widthxheight+x_location+y_location> window geometry\n"); printf(" -w/-h resolution of surface\n"); printf(" -r <framerate>\n"); printf(" -d the dimension of black/write square box, default is 32\n"); printf(" -t multi-threads\n"); printf(" -c test clipbox\n"); printf(" -f <1/2> top field, or bottom field\n"); printf(" -1 source format (fourcc) for color conversion test\n"); printf(" -2 dest format (fourcc) for color conversion test\n"); printf(" --fmt1 same to -1\n"); printf(" --fmt2 same to -2\n"); printf(" -v verbose output\n"); exit(0); break; case 'g': ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y); if (ret != 4) { printf("invalid window geometry, must be widthxheight+x_location+y_location\n"); exit(0); } else printf("Create window at (%d, %d), width = %d, height = %d\n", win_x, win_y, win_width, win_height); break; case 'r': frame_rate = atoi(optarg); break; case 'w': surface_width = atoi(optarg); break; case 'h': surface_height = atoi(optarg); break; case 'n': frame_num_total = atoi(optarg); break; case 'd': box_width = atoi(optarg); break; case 't': multi_thread = 1; printf("Two threads to do vaPutSurface\n"); break; case 'e': check_event = 0; break; case 'p': put_pixmap = 1; break; case 'c': test_clip = 1; break; case 'f': if (atoi(optarg) == 1) { printf("Display TOP field\n"); display_field = VA_TOP_FIELD; } else if (atoi(optarg) == 2) { printf("Display BOTTOM field\n"); display_field = VA_BOTTOM_FIELD; } else printf("The validate input for -f is: 1(top field)/2(bottom field)\n"); break; case '1': sscanf(optarg, "%s", str_src_fmt); csc_src_fourcc = map_str_to_vafourcc (str_src_fmt); if (!csc_src_fourcc) { printf("invalid fmt1: %s\n", str_src_fmt ); exit(0); } break; case '2': sscanf(optarg, "%s", str_dst_fmt); csc_dst_fourcc = map_str_to_vafourcc (str_dst_fmt); if (!csc_dst_fourcc) { printf("invalid fmt1: %s\n", str_dst_fmt ); exit(0); } break; case 'v': verbose = 1; printf("Enable verbose output\n"); break; } } if (csc_src_fourcc && csc_dst_fourcc) { test_color_conversion = 1; } win_display = (void *)open_display(); if (win_display == NULL) { fprintf(stderr, "Can't open the connection of display!\n"); exit(-1); } create_window(win_display, win_x, win_y, win_width, win_height); va_dpy = vaGetDisplay(win_display); va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); CHECK_VASTATUS(va_status, "vaInitialize"); if (test_color_conversion) { ret = csc_preparation(); } if (!test_color_conversion || !ret ) { va_status = vaCreateSurfaces( va_dpy, VA_RT_FORMAT_YUV420, surface_width, surface_height, &surface_id[0], SURFACE_NUM, NULL, 0 ); } CHECK_VASTATUS(va_status, "vaCreateSurfaces"); if (multi_thread == 0) /* upload the content for all surfaces */ upload_source_YUV_once_for_all(); if (check_event) pthread_mutex_init(&gmutex, NULL); for(i = 0; i< SURFACE_NUM; i++) pthread_mutex_init(&surface_mutex[i], NULL); if (multi_thread == 1) ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1); putsurface_thread((void *)drawable_thread0); if (multi_thread == 1) pthread_join(thread1, (void **)&ret); printf("thread1 is free\n"); if (test_color_conversion) { // destroy temp surface/image va_status = vaDestroySurfaces(va_dpy, &csc_render_surface, 1); CHECK_VASTATUS(va_status,"vaDestroySurfaces"); va_status = vaDestroyImage(va_dpy, csc_dst_fourcc_image.image_id); CHECK_VASTATUS(va_status,"vaDestroyImage"); } if (vpp_config_id != VA_INVALID_ID) { vaDestroyConfig (va_dpy, vpp_config_id); vpp_config_id = VA_INVALID_ID; } vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); vaTerminate(va_dpy); free(va_image_formats); free(va_surface_attribs); close_display(win_display); return 0; }
int main(int argc, char *argv[]) { char c; cmnd = windowtitle = *argv; if (strrchr(cmnd, '/')) cmnd = windowtitle = (char *) (strrchr(cmnd, '/') + 1); while (--argc) { if ((strcmp(*++argv, "-s") == 0) && argc > 1) { shrink = atof(*++argv); if (shrink <= 0) usage(0); argc--; } else if (strcmp(*argv, "-landscape") == 0 || strcmp(*argv, "-land") == 0 || strcmp(*argv, "-l") == 0) { landscape = 1 - landscape; } else if (strcmp(*argv, "-reverse") == 0 || strcmp(*argv, "-rv") == 0) { reverse = 1 - reverse; } else if (strcmp(*argv, "-color") == 0 || strcmp(*argv, "-c") == 0) { c_flg = 1 - c_flg; } else if (strcmp(*argv, "-mono") == 0 || strcmp(*argv, "-m") == 0) { mono_flg = 1 - mono_flg; } else if (strcmp(*argv, "-fno") == 0 && argc > 1) { fno = atoi(*++argv); argc--; } else if (strcmp(*argv, "-bold") == 0 || strcmp(*argv, "-b") == 0) { fno += 4; } else if (strcmp(*argv, "-fg") == 0 && argc > 1) { fore_color = *++argv; argc--; } else if (strcmp(*argv, "-bg") == 0 && argc > 1) { back_color = *++argv; argc--; } else if (strcmp(*argv, "-hl") == 0 && argc > 1) { high_color = *++argv; argc--; } else if (strcmp(*argv, "-bd") == 0 && argc > 1) { brdr_color = *++argv; argc--; } else if (strcmp(*argv, "-ms") == 0 && argc > 1) { mous_color = *++argv; argc--; } else if ((strcmp(*argv, "-geometry") == 0 || strcmp(*argv, "-g") == 0) && argc > 1) { geometry = *++argv; argc--; } else if ((strcmp(*argv, "-display") == 0 || strcmp(*argv, "-d") == 0) && argc > 1) { dpy = *++argv; argc--; } else if ((strcmp(*argv, "-title") == 0 || strcmp(*argv, "-t") == 0) && argc > 1) { windowtitle = *++argv; argc--; } else if (strcmp(*argv, "-h") == 0 || strcmp(*argv, "--") == 0 || strcmp(*argv, "-?") == 0) { usage(0); } else usage(1); } ungetc(c = getchar(), stdin); if (c == EOF) return (-1); else if (c != '=') { fprintf(stderr, "%s : Unexpected data format!\n", cmnd); return (-1); } open_display(dpy); init_window(argc, argv); init_pixmap(); plot(); main_loop(); close_window(); return (0); }
int main(int argc, const char * argv[]) { if ( (argc < 2) || (argc > 3) || ((argc == 3) && (strcmp("--config", argv[1]) != 0)) || (strcmp("-h", argv[1]) == 0) || (strcmp("--help", argv[1]) == 0) ) { fprintf(stderr, "Usage: %s config_path\n", argv[0]); fprintf(stderr, " %s --config js_device_path\n", argv[0]); exit(-1); } Display * display = open_display("xjoy2key"); if (display == NULL) return -1; struct config cfg; if (strcmp("--config", argv[1]) == 0) { probe_config(&cfg, argv[2]); fill_config(&cfg, display); write_config(&cfg, display, stdout); exit(0); } if (file_exists(argv[1])) read_config(&cfg, display, argv[1]); else { fprintf(stderr, "File doesn't exist: %s\n", argv[1]); exit(-1); } int fd = open(cfg.device, O_RDONLY); if (fd == -1) { fprintf(stderr, "Unable to open joystick '%s': %s\n", cfg.device, strerror(errno)); exit(-1); } struct sigaction new_action, old_action; new_action.sa_handler = sigint; sigemptyset(&new_action.sa_mask); new_action.sa_flags = 0; sigaction(SIGINT, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction(SIGINT, &new_action, NULL); while (!done) { struct js_event event; if (read_timeout_usec(fd, &event, sizeof(struct js_event), 100) == sizeof(struct js_event)) { handle_event(&event, display, &cfg); } } XCloseDisplay(display); free_config(&cfg); return close(fd); }
int main(int argc,char **argv) { int major_ver, minor_ver; VAStatus va_status; pthread_t thread1; int ret; char c; int i; while ((c =getopt(argc,argv,"w:h:g:r:d:f:tcep?n:v") ) != EOF) { switch (c) { case '?': printf("putsurface <options>\n"); printf(" -g <widthxheight+x_location+y_location> window geometry\n"); printf(" -w/-h resolution of surface\n"); printf(" -r <framerate>\n"); printf(" -d the dimension of black/write square box, default is 32\n"); printf(" -t multi-threads\n"); printf(" -c test clipbox\n"); printf(" -f <1/2> top field, or bottom field\n"); printf(" -v verbose output\n"); exit(0); break; case 'g': ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y); if (ret != 4) { printf("invalid window geometry, must be widthxheight+x_location+y_location\n"); exit(0); } else printf("Create window at (%d, %d), width = %d, height = %d\n", win_x, win_y, win_width, win_height); break; case 'r': frame_rate = atoi(optarg); break; case 'w': surface_width = atoi(optarg); break; case 'h': surface_height = atoi(optarg); break; case 'n': frame_num_total = atoi(optarg); break; case 'd': box_width = atoi(optarg); break; case 't': multi_thread = 1; printf("Two threads to do vaPutSurface\n"); break; case 'e': check_event = 0; break; case 'p': put_pixmap = 1; break; case 'c': test_clip = 1; break; case 'f': if (atoi(optarg) == 1) { printf("Display TOP field\n"); display_field = VA_TOP_FIELD; } else if (atoi(optarg) == 2) { printf("Display BOTTOM field\n"); display_field = VA_BOTTOM_FIELD; } else printf("The validate input for -f is: 1(top field)/2(bottom field)\n"); break; case 'v': verbose = 1; printf("Enable verbose output\n"); break; } } win_display = (void *)open_display(); if (win_display == NULL) { fprintf(stderr, "Can't open the connection of display!\n"); exit(-1); } create_window(win_display, win_x, win_y, win_width, win_height); va_dpy = vaGetDisplay(win_display); va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); CHECK_VASTATUS(va_status, "vaInitialize"); va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height, VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]); CHECK_VASTATUS(va_status, "vaCreateSurfaces"); if (multi_thread == 0) /* upload the content for all surfaces */ upload_source_YUV_once_for_all(); if (check_event) pthread_mutex_init(&gmutex, NULL); for(i = 0; i< SURFACE_NUM; i++) pthread_mutex_init(&surface_mutex[i], NULL); if (multi_thread == 1) ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1); putsurface_thread((void *)drawable_thread0); if (multi_thread == 1) pthread_join(thread1, (void **)&ret); printf("thread1 is free\n"); vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); vaTerminate(va_dpy); close_display(win_display); return 0; }