fixing manpage
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index 66a60d0..796ee96 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -61,7 +61,7 @@ static SoupSession *session;
 static Client *clients = NULL;
 static GdkNativeWindow embed = 0;
 static gboolean showxid = FALSE;
-static Time lastxprop = 0;
+static int ignorexprop = 0;
 static char winid[64];
 static char *progname;
 static gboolean lockcookie = FALSE;
@@ -467,7 +467,19 @@ newclient(void) {
        }
        else {
                c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+               /* TA:  20091214:  Despite what the GNOME docs say, the ICCCM
+                * is always correct, so we should still call this function.
+                * But when doing so, we *must* differentiate between a
+                * WM_CLASS and a resource on the window.  By convention, the
+                * window class (WM_CLASS) is capped, while the resource is in
+                * lowercase.   Both these values come as a pair.
+                */
                gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf");
+
+               /* TA:  20091214:  And set the role here as well -- so that
+                * sessions can pick this up.
+                */
+               gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
        }
        gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
        g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
@@ -539,7 +551,6 @@ newclient(void) {
        g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
        g_free(uri);
        setatom(c, findprop, "");
-       setatom(c, uriprop, "");
 
        c->download = NULL;
        c->title = NULL;
@@ -597,8 +608,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
 
        if(((XEvent *)e)->type == PropertyNotify) {
                ev = &((XEvent *)e)->xproperty;
-               if((!lastxprop || lastxprop + 512 < ev->time)
-                               && ev->state == PropertyNewValue) {
+               if(ignorexprop)
+                       ignorexprop--;
+               else if(ev->state == PropertyNewValue) {
                        if(ev->atom == uriprop) {
                                arg.v = getatom(c, uriprop);
                                loaduri(c, &arg);
@@ -607,7 +619,6 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
                                arg.b = TRUE;
                                find(c, &arg);
                        }
-                       lastxprop = ev->time;
                        return GDK_FILTER_REMOVE;
                }
        }
@@ -674,16 +685,18 @@ scroll(Client *c, const Arg *arg) {
 
 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);
-       XSync(dpy, False);
 }
 
 void
 setup(void) {
        SoupSession *s;
        char *proxy;
+       char *new_proxy;
        SoupURI *puri;
 
        /* clean up any zombies immediately */
@@ -709,9 +722,13 @@ setup(void) {
        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, "")) {
-               puri = soup_uri_new(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();
 }