Only in surf-0.3.w32/: .config.mk.swp Only in surf-0.3.w32/: config.h diff -ru surf-0.3/config.mk surf-0.3.w32/config.mk --- surf-0.3/config.mk 2009-10-30 12:41:02 +0000 +++ surf-0.3.w32/config.mk 2010-04-23 15:37:04 +0100 @@ -13,7 +13,7 @@ # includes and libs INCS = -I. -I/usr/include ${GTKINC} -LIBS = -L/usr/lib -lc ${GTKLIB} -lgthread-2.0 +LIBS = -L/usr/lib ${GTKLIB} -lgthread-2.0 # flags CPPFLAGS = -DVERSION=\"${VERSION}\" @@ -25,4 +25,4 @@ #LDFLAGS = ${LIBS} # compiler and linker -CC = cc +CC = gcc diff -ru surf-0.3/surf.c surf-0.3.w32/surf.c --- surf-0.3/surf.c 2009-10-30 12:41:02 +0000 +++ surf-0.3.w32/surf.c 2010-04-23 15:37:04 +0100 @@ -2,17 +2,11 @@ * * To understand surf, start reading main(). */ -#include -#include -#include #include -#include #include #include #include #include -#include -#include #include #include #include @@ -54,15 +48,11 @@ const Arg arg; } Key; -static Display *dpy; -static Atom uriprop, findprop; static SoupCookieJar *cookies; static SoupSession *session; static Client *clients = NULL; static GdkNativeWindow embed = 0; static gboolean showxid = FALSE; -static int ignorexprop = 0; -static char winid[64]; static char *progname; static gboolean lockcookie = FALSE; @@ -82,7 +72,6 @@ static void drawindicator(Client *c); static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c); static void find(Client *c, const Arg *arg); -static const char *getatom(Client *c, Atom a); static char *geturi(Client *c); static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c); static void itemclick(GtkMenuItem *mi, Client *c); @@ -96,17 +85,13 @@ static void newwindow(Client *c, const Arg *arg); static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); static void print(Client *c, const Arg *arg); -static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); static void progresschange(WebKitWebView *v, gint p, Client *c); static void reload(Client *c, const Arg *arg); static void reloadcookies(); static void resize(GtkWidget *w, GtkAllocation *a, Client *c); static void scroll(Client *c, const Arg *arg); -static void setatom(Client *c, Atom a, const char *v); static void setup(void); -static void sigchld(int unused); static void source(Client *c, const Arg *arg); -static void spawn(Client *c, const Arg *arg); static void stop(Client *c, const Arg *arg); static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c); static void update(Client *c); @@ -290,17 +275,13 @@ void drawindicator(Client *c) { gint width; - const char *uri; GtkWidget *w; GdkGC *gc; GdkColor fg; - uri = getatom(c, uriprop); w = c->indicator; width = c->progress * w->allocation.width / 100; gc = gdk_gc_new(w->window); - gdk_color_parse(strstr(uri, "https://") == uri ? - progress_trust : progress, &fg); gdk_gc_set_rgb_fg_color(gc, &fg); gdk_draw_rectangle(w->window, w->style->bg_gc[GTK_WIDGET_STATE(w)], @@ -318,30 +299,6 @@ void find(Client *c, const Arg *arg) { - const char *s; - - s = getatom(c, findprop); - gboolean forward = *(gboolean *)arg; - webkit_web_view_search_text(c->view, s, FALSE, forward, TRUE); -} - -const char * -getatom(Client *c, Atom a) { - static char buf[BUFSIZ]; - Atom adummy; - int idummy; - unsigned long ldummy; - unsigned char *p = NULL; - - XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), - a, 0L, BUFSIZ, False, XA_STRING, - &adummy, &idummy, &ldummy, &ldummy, &p); - if(p) - strncpy(buf, (char *)p, LENGTH(buf)-1); - else - buf[0] = '\0'; - XFree(p); - return buf; } char * @@ -421,7 +378,6 @@ void loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c) { - setatom(c, uriprop, geturi(c)); } void @@ -529,24 +485,17 @@ gtk_widget_show(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); - gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c); webkit_web_view_set_full_content_zoom(c->view, TRUE); settings = webkit_web_view_get_settings(c->view); g_object_set(G_OBJECT(settings), "user-agent", useragent, NULL); uri = g_strconcat("file://", stylefile, NULL); g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL); g_free(uri); - setatom(c, findprop, ""); c->download = NULL; 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); - } return c; } @@ -554,7 +503,6 @@ newwindow(Client *c, const Arg *arg) { guint i = 0; const char *cmd[7], *uri; - const Arg a = { .v = (void *)cmd }; char tmp[64]; cmd[i++] = progname; @@ -571,7 +519,6 @@ if(uri) cmd[i++] = uri; cmd[i++] = NULL; - spawn(NULL, &a); } void @@ -586,31 +533,6 @@ webkit_web_frame_print(webkit_web_view_get_main_frame(c->view)); } -GdkFilterReturn -processx(GdkXEvent *e, GdkEvent *event, gpointer d) { - Client *c = (Client *)d; - XPropertyEvent *ev; - Arg arg; - - if(((XEvent *)e)->type == PropertyNotify) { - ev = &((XEvent *)e)->xproperty; - if(ignorexprop) - ignorexprop--; - else if(ev->state == PropertyNewValue) { - if(ev->atom == uriprop) { - arg.v = getatom(c, uriprop); - loaduri(c, &arg); - } - else if(ev->atom == findprop) { - arg.b = TRUE; - find(c, &arg); - } - return GDK_FILTER_REMOVE; - } - } - return GDK_FILTER_CONTINUE; -} - void progresschange(WebKitWebView *v, gint p, Client *c) { c->progress = p; @@ -669,29 +591,17 @@ gtk_adjustment_set_value(a, v); } -void -setatom(Client *c, Atom a, const char *v) { - XSync(dpy, False); - ignorexprop++; - XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), a, - XA_STRING, 8, PropModeReplace, (unsigned char *)v, - strlen(v) + 1); -} void setup(void) { SoupSession *s; /* 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); @@ -708,13 +618,6 @@ } void -sigchld(int unused) { - if(signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); - while(0 < waitpid(-1, NULL, WNOHANG)); -} - -void source(Client *c, const Arg *arg) { Arg a = { .b = FALSE }; gboolean s; @@ -725,19 +628,6 @@ } void -spawn(Client *c, const Arg *arg) { - if(fork() == 0) { - if(dpy) - close(ConnectionNumber(dpy)); - setsid(); - execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "surf: execvp %s", ((char **)arg->v)[0]); - perror(" failed"); - exit(0); - } -} - -void stop(Client *c, const Arg *arg) { if(c->download) webkit_download_cancel(c->download); @@ -780,8 +670,6 @@ void updatewinid(Client *c) { - snprintf(winid, LENGTH(winid), "%u", - (int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); } void @@ -826,10 +714,6 @@ if(!strcmp(argv[i], "-x")) showxid = TRUE; else if(!strcmp(argv[i], "-e")) { - if(++i < argc) - embed = atoi(argv[i]); - else - usage(); } else if(!strcmp(argv[i], "--")) { i++; Only in surf-0.3.w32/: surf.exe