Ejemplo n.º 1
0
static Errcode init_after_screen()
/* initializes and allocs every thing that has to be done after the screen
 * and before the dynamic stuff (tempflx) and push/pop stuff is opened */
{
	init_cursors();
	vb.screen->menu_cursor = &menu_cursor;
	vb.screen->cursor = &menu_cursor;
	set_cursor_ccolor((Pixel *)(&vs.ccolor)); /* only works with 80x86 */
	return(init_brushes());
}
Ejemplo n.º 2
0
static int ingestion_init_s5p_l1b_ra(const harp_ingestion_module *module, coda_product *product,
                                     const harp_ingestion_options *options, harp_product_definition **definition,
                                     void **user_data)
{
    ingest_info *info;

    (void)options;

    info = malloc(sizeof(ingest_info));
    if (info == NULL)
    {
        harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)",
                       sizeof(ingest_info), __FILE__, __LINE__);
        return -1;
    }
    info->product = product;
    info->band = -1;

    if (init_cursors(info, NULL) != 0)
    {
        ingestion_done(info);
        return -1;
    }
    if (init_dimensions(info, info->observation_cursor, "radiance") != 0)
    {
        ingestion_done(info);
        return -1;
    }

    /* Initialize cursors and fill values for datasets which will be read using partial reads. */
    if (init_dataset
        (info->instrument_cursor, "nominal_wavelength", info->num_pixels * info->num_channels, &info->wavelength_cursor,
         &info->wavelength_fill_value) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    if (init_dataset
        (info->observation_cursor, "radiance", info->num_scanlines * info->num_pixels * info->num_channels,
         &info->observable_cursor, &info->observable_fill_value) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    *definition = *module->product_definition;
    *user_data = info;

    return 0;
}
Ejemplo n.º 3
0
int
fl_create_bitmap_cursor( const char * source,
                         const char * mask,
                         int          w,
                         int          h,
                         int          hotx,
                         int          hoty )
{
    Cursor cur;

    init_cursors( );
    cur = create_bitmap_cursor( source, mask, w, h, hotx, hoty );
    add_cursor( user_cur_name, cur );

    return user_cur_name++;
}
Ejemplo n.º 4
0
void
fl_set_cursor( Window win,
               int    name )
{
    CurStruct *c = cursors;

    init_cursors( );

    if ( win == 0 )
    {
        M_err( "fl_set_cursor", "Bad Window" );
        return;
    }

    for ( ; c->name; c++ )
    {
        if ( c->name == name )
        {
            if ( c->ncursor > 1 )
            {
                int n = c->cur_cursor % c->ncursor;
                XDefineCursor( flx->display, win, c->cur[ n ] );;
                c->cur_cursor++;
                c->win = win;
                if ( c->timeout_id == 0 )
                    c->timeout_id =
                              fl_add_timeout( c->timeout, animate_cursor, c );
            }
            else
            {
                CurStruct *cur = find_timeout( win );

                if ( cur && cur->timeout_id )
                {
                    fl_remove_timeout( cur->timeout_id );
                    cur->timeout_id = 0;
                }
                XDefineCursor( flx->display, win, c->cur[ 0 ] );;
            }
            return;
        }
    }

    XDefineCursor( flx->display, win, fli_get_cursor_byname( name ) );
}
Ejemplo n.º 5
0
Cursor
fli_get_cursor_byname( int name )
{
    CurStruct *c;
    Cursor cur = 0;

    init_cursors( );

    for ( c = cursors; c->name; c++ )
    {
        if ( c->name == name )
        {
            int n = c->cur_cursor % c->ncursor;
            c->cur_cursor++;
            return c->cur[ n ];
        }
    }

    /* Take a wild shot: since we can generate the default X cursor on the
       fly we don't have to always save them to the cursor structure */

    if ( name < XC_num_glyphs - 1 )
    {
        static int nn;
        cur = XCreateFontCursor( flx->display, name );
        if ( nn < 10 )
        {
            add_cursor( name, cur );
            nn++;
        }
    }
    else
    {
        M_err( "fli_get_cursor_byname", "Unknown cursor: %d\n", name );
        cur = fli_get_cursor_byname( FL_DEFAULT_CURSOR );    /* recursion */
    }

    return cur;
}
Ejemplo n.º 6
0
static int ingestion_init(const harp_ingestion_module *module, coda_product *product,
                          const harp_ingestion_options *options, harp_product_definition **definition, void **user_data)
{
    ingest_info *info;

    info = malloc(sizeof(ingest_info));
    if (info == NULL)
    {
        harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)",
                       sizeof(ingest_info), __FILE__, __LINE__);
        return -1;
    }
    info->product = product;
    info->band_id = 0;
    info->radiance = NULL;

    if (parse_option_band(info, options) != 0)
    {
        ingestion_done(info);
        return -1;
    }
    if (init_cursors(info) != 0)
    {
        ingestion_done(info);
        return -1;
    }
    if (init_num_main(info) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    *definition = module->product_definition[info->band_id];
    *user_data = info;

    return 0;
}
Ejemplo n.º 7
0
static int setup_display() {
    int major = 1;
    int minor = 0;
	int majorOpcode = 0;
	int eventBase = 0;
	int errorBase = 0;

    int depth, i, formatCount, convDepth = -1;
    XPixmapFormatValues* formats;

    if (s_setup_done) {
        return 1;
    }

    s_display = XOpenDisplay(0);

    if (!s_display) {
        printf("Unable to open X11 display\n");
        return 0;
    }

    s_context = XUniqueContext();
    s_screen = DefaultScreen(s_display);
    s_visual = DefaultVisual(s_display, s_screen);
    formats = XListPixmapFormats(s_display, &formatCount);
    depth = DefaultDepth(s_display, s_screen);

    for (i = 0; i < formatCount; ++i) {
        if (depth == formats[i].depth) {
            convDepth = formats[i].bits_per_pixel;
            break;
        }
    }
  
    XFree(formats);

    // We only support 32-bit right now
    if (convDepth != 32) {
        printf("Unable to find 32-bit format for X11 display\n");
        XCloseDisplay(s_display);
        return 0;
    }

    s_depth = depth;

    s_gc = DefaultGC(s_display, s_screen);

    s_screen_width = DisplayWidth(s_display, s_screen);
    s_screen_height = DisplayHeight(s_display, s_screen);

    const char* wmDeleteWindowName = "WM_DELETE_WINDOW";
    XInternAtoms(s_display, (char**)&wmDeleteWindowName, 1, False, &s_wm_delete_window);

    s_setup_done = 1;

    init_cursors();

	s_keyb_ext = XkbQueryExtension(s_display, &majorOpcode, &eventBase, &errorBase, &major, &minor);

    return 1;
}
Ejemplo n.º 8
0
static int ingestion_init_s5p_l1b_ir(const harp_ingestion_module *module, coda_product *product,
                                     const harp_ingestion_options *options, harp_product_definition **definition,
                                     void **user_data)
{
    ingest_info *info;
    char product_group_name[17];
    int band_available;

    info = malloc(sizeof(ingest_info));
    if (info == NULL)
    {
        harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)",
                       sizeof(ingest_info), __FILE__, __LINE__);
        return -1;
    }
    info->product = product;
    info->band = -1;

    if (parse_option_band(info, options) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    snprintf(product_group_name, ARRAY_SIZE(product_group_name), "BAND%d_IRRADIANCE", info->band);
    if (get_product_group_availability(info->product, product_group_name, &band_available) != 0)
    {
        ingestion_done(info);
        return -1;
    }
    if (!band_available)
    {
        harp_set_error(HARP_ERROR_INGESTION, "no data for band '%d'", info->band);
        ingestion_done(info);
        return -1;
    }

    if (init_cursors(info, product_group_name) != 0)
    {
        ingestion_done(info);
        return -1;
    }
    if (init_dimensions(info, info->observation_cursor, "irradiance") != 0)
    {
        ingestion_done(info);
        return -1;
    }

    /* Initialize cursors and fill values for datasets which will be read using partial reads. */
    if (init_dataset
        (info->instrument_cursor, "calibrated_wavelength", info->num_pixels * info->num_channels,
         &info->wavelength_cursor, &info->wavelength_fill_value) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    if (init_dataset
        (info->observation_cursor, "irradiance", info->num_scanlines * info->num_pixels * info->num_channels,
         &info->observable_cursor, &info->observable_fill_value) != 0)
    {
        ingestion_done(info);
        return -1;
    }

    assert(info->band >= 1 && info->band <= 8);
    if (info->band < 7)
    {
        *definition = module->product_definition[info->band - 1];
    }
    else
    {
        *definition = module->product_definition[info->band - 7];
    }
    *user_data = info;

    return 0;
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: bartman/wmii
int
main(int argc, char *argv[]) {
	IxpMsg m;
	char **oargv;
	char *wmiirc, *s;
	int i;

	quotefmtinstall();
	fmtinstall('r', errfmt);
	fmtinstall('a', afmt);
	fmtinstall('C', Cfmt);
extern int fmtevent(Fmt*);
	fmtinstall('E', fmtevent);

	wmiirc = "wmiirc";

	oargv = argv;
	ARGBEGIN{
	case 'a':
		address = EARGF(usage());
		break;
	case 'r':
		wmiirc = EARGF(usage());
		break;
	case 'v':
		print("%s", version);
		exit(0);
	case 'D':
		s = EARGF(usage());
		m = ixp_message(s, strlen(s), 0);
		msg_debug(&m);
		break;
	default:
		usage();
		break;
	}ARGEND;

	if(argc)
		usage();

	setlocale(LC_CTYPE, "");
	starting = true;

	initdisplay();

	traperrors(true);
	selectinput(&scr.root, EnterWindowMask
			     | SubstructureRedirectMask);
	if(traperrors(false))
		fatal("another window manager is already running");

	passwd = getpwuid(getuid());
	user = estrdup(passwd->pw_name);

	init_environment();

	fmtinstall('F', Ffmt);
	ixp_printfcall = printfcall;

	sock = ixp_announce(address);
	if(sock < 0)
		fatal("Can't create socket '%s': %r", address);
	closeexec(ConnectionNumber(display));
	closeexec(sock);

	if(wmiirc[0])
		spawn_command(wmiirc);

	init_traps();
	init_cursors();
	init_lock_keys();
	ewmh_init();
	xext_init();

	srv.preselect = check_preselect;
	ixp_listen(&srv, sock, &p9srv, serve_9pcon, nil);
	ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay);

	def.border = 1;
	def.colmode = Colstack;
	def.font = loadfont(FONT);
	def.incmode = ISqueeze;

	def.mod = Mod1Mask;
	strcpy(def.grabmod, "Mod1");

	loadcolor(&def.focuscolor, FOCUSCOLORS);
	loadcolor(&def.normcolor, NORMCOLORS);

	disp.sel = pointerscreen();

	init_screens();
	root_init();

	disp.focus = nil;
	setfocus(screen->barwin, RevertToParent);
	view_select("1");

	scan_wins();
	starting = false;

	view_update_all();
	ewmh_updateviews();

	event("FocusTag %s\n", selview->name);

	i = ixp_serverloop(&srv);
	if(i)
		fprint(2, "%s: error: %r\n", argv0);
	else
		event("Quit");

	cleanup();

	if(exitsignal)
		raise(exitsignal);
	if(execstr) {
		char *toks[32];
		int n;

		n = unquote(strdup(execstr), toks, nelem(toks)-1);
		toks[n] = nil;
		execvp(toks[0], toks);
		fprint(2, "%s: failed to exec %q: %r\n", argv0, execstr);
		execvp(argv0, oargv);
		fatal("failed to exec myself");
	}
	return i;
}
Ejemplo n.º 10
0
Archivo: main.c Proyecto: aztrock/wmii
int
main(int argc, char *argv[]) {
	char *wmiirc;
	WMScreen *s;
	WinAttr wa;
	int i;

	fmtinstall('r', errfmt);
	fmtinstall('C', Cfmt);

	wmiirc = "wmiistartrc";

	ARGBEGIN{
	case 'v':
		print("%s", version);
		exit(0);
	case 'V':
		verbose = True;
		break;
	case 'a':
		address = EARGF(usage());
		break;
	case 'r':
		wmiirc = EARGF(usage());
		break;
	default:
		usage();
		break;
	}ARGEND;

	if(argc)
		usage();

	setlocale(LC_CTYPE, "");
	starting = True;

	initdisplay();

	xlib_errorhandler = XSetErrorHandler(errorhandler);

	check_other_wm = True;
	XSelectInput(display, scr.root.w,
			  SubstructureRedirectMask
			| EnterWindowMask);
	XSync(display, False);

	check_other_wm = False;

	passwd = getpwuid(getuid());
	user = estrdup(passwd->pw_name);

	init_environment();

	sock = ixp_announce(address);
	if(sock < 0)
		fatal("Can't create socket '%s': %r", address);

	if(wmiirc)
		spawn_command(wmiirc);

	init_traps();
	init_atoms();
	init_cursors();
	init_lock_keys();

	srv.preselect = check_preselect;
	ixp_listen(&srv, sock, &p9srv, serve_9pcon, nil);
	ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay);

	def.font = loadfont(FONT);
	def.border = 1;
	def.colmode = Coldefault;

	def.mod = Mod1Mask;
	strcpy(def.grabmod, "Mod1");

	loadcolor(&def.focuscolor, FOCUSCOLORS);
	loadcolor(&def.normcolor, NORMCOLORS);

	num_screens = 1;
	screens = emallocz(num_screens * sizeof(*screens));
	screen = &screens[0];
	for(i = 0; i < num_screens; i++) {
		s = &screens[i];
		init_screen(s);

		s->ibuf = allocimage(Dx(s->r), Dy(s->r), scr.depth);

		wa.event_mask = 
				  SubstructureRedirectMask
				| SubstructureNotifyMask
				| EnterWindowMask
				| LeaveWindowMask
				| FocusChangeMask;
		wa.cursor = cursor[CurNormal];
		setwinattr(&scr.root, &wa,
				  CWEventMask
				| CWCursor);
		initbar(s);
	}

	screen->focus = nil;
	setfocus(screen->barwin, RevertToParent);

	scan_wins();
	starting = False;

	select_view("nil");
	update_views();
	write_event("FocusTag %s\n", screen->sel->name);

	check_x_event(nil);
	i = ixp_serverloop(&srv);
	if(i)
		fprint(2, "%s: error: %r\n", argv0);

	cleanup();

	if(exitsignal)
		raise(exitsignal);
	if(execstr)
		execl("/bin/sh", "sh", "-c", execstr, nil);
	return i;
}