preparing sourcecode feature coming with webkit-1.1.14.
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index 3b09f06..c0debf0 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -17,6 +17,7 @@
 #include <glib/gstdio.h>
 
 #define LENGTH(x) (sizeof x / sizeof x[0])
+#define CLEANMASK(mask)         (mask & ~(GDK_MOD2_MASK))
 
 Display *dpy;
 Atom urlprop;
@@ -103,6 +104,7 @@ static void setup();
 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame,
                const gchar* title, Client *c);
 static void searchtext(Client *c, const Arg *arg);
+static void source(Client *c, const Arg *arg);
 static void showsearch(Client *c, const Arg *arg);
 static void showurl(Client *c, const Arg *arg);
 static void stop(Client *c, const Arg *arg);
@@ -276,7 +278,8 @@ keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
                focus = BROWSER;
        for(i = 0; i < LENGTH(keys); i++) {
                if(focus & keys[i].focus && ev->keyval == keys[i].keyval &&
-                               (ev->state == keys[i].mod || ev->state & keys[i].mod)
+                               (CLEANMASK(ev->state) == keys[i].mod ||
+                                CLEANMASK(ev->state) & keys[i].mod)
                                && keys[i].func) {
                        keys[i].func(c, &(keys[i].arg));
                        processed = TRUE;
@@ -442,8 +445,11 @@ newclient(void) {
        c->title = NULL;
        c->next = clients;
        clients = c;
-       if(showxid)
+       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;
 }
 
@@ -542,6 +548,16 @@ showsearch(Client *c, const Arg *arg) {
        gtk_widget_grab_focus(c->searchbar);
 }
 
+void
+source(Client *c, const Arg *arg) {
+       Arg a = { .b = FALSE };
+       /*gboolean s;
+
+       s = webkit_web_view_get_view_source_mode(c->view);
+       webkit_web_view_set_view_source_mode(c->view, c->source);*/
+       reload(c, &a);
+}
+
 void
 searchtext(Client *c, const Arg *arg) {
        gboolean forward = *(gboolean *)arg;
@@ -654,8 +670,6 @@ int main(int argc, char *argv[]) {
 
        /* make dirs */
        home = g_get_home_dir();
-       filename = g_build_filename(home, ".surf", NULL);
-       g_mkdir_with_parents(filename, 0711);
        filename = g_build_filename(home, ".surf", "dl", NULL);
        g_mkdir_with_parents(filename, 0755);