Exemple #1
0
int
main(int argc, char *argv[]) {
    gchar **uris = NULL;
    xdgHandle xdg;

    /* clean up any zombies */
    sigchld(0);

    gtk_init(&argc, &argv);
    if (!g_thread_supported())
        g_thread_init(NULL);

    /* parse command line opts and get uris to load */
    uris = parseopts(argc, argv);

    /* get XDG basedir data */
    xdgInitHandle(&xdg);

    init_directories(&xdg);
    init_lua(uris, &xdg);

    /* we are finished with this */
    xdgWipeHandle(&xdg);

    gtk_main();
    return EXIT_SUCCESS;
}
Exemple #2
0
void setup(){
   // remove zombies on SIGCHLD
   sigchld(0);

   gScreen = DefaultScreen(gDisplay);
   gRoot = RootWindow(gDisplay, gScreen);
   XSelectInput(gDisplay, gRoot, ROOT_EVENT_MASK);

   // initialize subsystems
   inputs_init();
   clientlist_init();
   layout_init();
	systray_init();
   update_status();
}
Exemple #3
0
void
setup(void) {
	char *proxy;
	char *new_proxy;
	SoupURI *puri;
	SoupSession *s;

	/* clean up any zombies immediately */
	sigchld(0);
	gtk_init(NULL, NULL);
	if (!g_thread_supported())
		g_thread_init(NULL);

	dpy = GDK_DISPLAY();
	s = webkit_get_default_session();

	/* atoms */
	atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
	atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
	atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);

	/* dirs and files */
	cookiefile = buildpath(cookiefile);
	scriptfile = buildpath(scriptfile);
	stylefile = buildpath(stylefile);

	/* request handler */
	s = webkit_get_default_session();
	soup_session_remove_feature_by_type(s, soup_cookie_get_type());
	soup_session_remove_feature_by_type(s, soup_cookie_jar_get_type());
	g_signal_connect_after(G_OBJECT(s), "request-started", G_CALLBACK(newrequest), NULL);

	/* proxy */
	if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
		new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) :
			g_strdup_printf("http://%s", proxy);
		puri = soup_uri_new(new_proxy);
		g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
		soup_uri_free(puri);
		g_free(new_proxy);
	}


	XSetErrorHandler(&xerrorhandler);
}
Exemple #4
0
void
setup(void) {
	SoupSession *s;
	char *proxy;
	char *new_proxy;
	SoupURI *puri;

	/* clean up any zombies immediately */
	sigchld(0);
	gtk_init(NULL, NULL);
	if (!g_thread_supported())
		g_thread_init(NULL);

	dpy = GDK_DISPLAY();
	session = webkit_get_default_session();
	uriprop = XInternAtom(dpy, "_SURF_URI", False);
	findprop = XInternAtom(dpy, "_SURF_FIND", False);

	/* create dirs and files */
	cookiefile = buildpath(cookiefile);
	dldir = buildpath(dldir);
	scriptfile = buildpath(scriptfile);
	stylefile = buildpath(stylefile);

	/* cookie persistance */
	s = webkit_get_default_session();
	cookies = soup_cookie_jar_new();
	soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookies));
	g_signal_connect(cookies, "changed", G_CALLBACK(changecookie), NULL);
	if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
		new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) :
			    g_strdup_printf("http://%s", proxy);

		puri = soup_uri_new(new_proxy);
		g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
		soup_uri_free(puri);
		g_free(new_proxy);
	}
	reloadcookies();
}
Exemple #5
0
int
main(int argc, char *argv[]) {
	Arg arg;
	Client *c;
	GdkGeometry hints = { 1, 1 };

	memset(&arg, 0, sizeof(arg));

	/* command line args */
	ARGBEGIN {
	case 'e':
		embed = strtol(EARGF(usage()), NULL, 0);
		break;
	case 'v':
		die("turf-"VERSION", ©2014 turf engineers, "
				"see LICENSE for details\n");
	case 'x':
		showxid = TRUE;
		break;
	default:
		usage();
	} ARGEND;
	if(argc > 0)
		arg.v = argv[0];

	sigchld(0);

	gtk_init(NULL, NULL);
	gtk_gl_init(NULL, NULL);

	dpy = GDK_DISPLAY();

	/* atoms */
	atoms[AtomFind] = XInternAtom(dpy, "_TURF_FIND", False);
	atoms[AtomGo] = XInternAtom(dpy, "_TURF_GO", False);
	atoms[AtomUri] = XInternAtom(dpy, "_TURF_URI", False);

	if(!(c = calloc(1, sizeof(Client))))
		die("Cannot malloc!\n");

	/* WIndow */
	if(embed) {
		c->win = gtk_plug_new(embed);
	} else {
		c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		gtk_window_set_wmclass(GTK_WINDOW(c->win), "turf", "Turf");
		gtk_window_set_role(GTK_WINDOW(c->win), "Turf");
	}
	gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
	g_signal_connect(G_OBJECT(c->win),
			"destroy",
			G_CALLBACK(destroywin), c);

	c->vbox = gtk_vbox_new(FALSE, 0);

	/* cef init */
	cef_settings_t *settings;
	if(!(settings = malloc(sizeof(cef_settings_t))))
		die("Cannot malloc\n");

	cef_initialize(NULL, settings, NULL);

	/* cef set as child (vbox) */

	gtk_container_add(GTK_CONTAINER(c->win), c->vbox);


	gtk_widget_show_all(GTK_WIDGET(c->win));
	gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
			GDK_HINT_MIN_SIZE);
	gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
	/* process X events for window - aka AtomFind/AtomGo
	 * gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
	 * setatom(c, AtomFind, "");
	 * setatom(c, AtomUri, "about:blank");
	 */

	c->title = NULL;
	c->next = clients;
	clients = c;

	if(showxid) {
		gdk_display_sync(gtk_widget_get_display(c->win));
		printf("%u\n",
			(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
		fflush(NULL);
		if (fclose(stdout) != 0) {
			die("Error closing stdout");
		}
	}

	if(arg.v)
		loaduri(clients, &arg);

	gtk_main();
	cleanup();

	return EXIT_SUCCESS;
}
Exemple #6
0
//PAGEBREAK: 42
// Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
// Scheduler never returns.  It loops, doing:
//  - choose a process to run
//  - swtch to start running that process
//  - eventually that process transfers control
//      via swtch back to the scheduler.
void
scheduler(void)
{
    struct proc *p;
    uint mask;
    sighandler_t *handler;

    for(;;) {
        // Enable interrupts on this processor.
        sti();

        // Loop over process table looking for process to run.
        acquire(&ptable.lock);
        for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) {
            if(p->state != RUNNABLE)
                continue;

            // Switch to chosen process.  It is the process's job
            // to release ptable.lock and then reacquire it
            // before jumping back to us.
            proc = p;
            switchuvm(p);

            /* A&T - SIGNALS start */
            if (p->signal != 0) {	/* A&T - were any signals recieved? */
                /* cprintf("DEBUG: pid=%d, p->signal=%d\n", p->pid, p->signal); */
                mask = (1 << 31);	/* the stack is a LIFO structure, so
                                 * we'll be pushing the LEAST important
                                 * signals first, so they'll run last. */
                /* cprintf("DEBUG: mask=%d\n", mask); */
                handler = &proc->handlers[31];
                while(mask > 8) {
                    /* a mask to check whether a signal's
                                        bit is up - not for builtin 3 signal
                                        hadlers, since they should be called
                                        from kernel space and not userspace. */
                    if ((p->signal & mask) && (*handler != 0))
                        register_handler(*handler); /* add the handler to
                                                 the stack, if it exists */


                    mask >>= 1;	/* move the mask to the next bit to check. */
                    handler--;	/* move the pointer to the next hendler */
                }
                while (mask > 0) {
                    if (p->signal & mask) {
                        if (*handler == 0) /* call the built-in handler */
                            switch(mask) {
                            case 8:
                                sigchld();
                                break;
                            case 4:
                                sigusr2();
                                break;
                            case 2:
                                sigusr1();
                                break;
                            case 1:
                                sigint();
                                break;
                            default:
                                break;
                            }
                        else
                            register_handler(*handler);
                    }
                    mask >>= 1;
                    handler--;
                }
                p->signal = 0;	/* initialize the signal data word to 0 */
            }
            /* A&T - SIGNALS end */

            p->state = RUNNING;
            swtch(&cpu->scheduler, proc->context);
            switchkvm();

            // Process is done running for now.
            // It should have changed its p->state before coming back.
            proc = 0;
        }
        release(&ptable.lock);

    }