+void
+newwindow(Client *c, const Arg *arg, gboolean noembed) {
+ guint i = 0;
+ const char *cmd[10], *uri;
+ const Arg a = { .v = (void *)cmd };
+ char tmp[64];
+
+ cmd[i++] = progname;
+ if(embed && !noembed) {
+ cmd[i++] = "-e";
+ snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
+ cmd[i++] = tmp;
+ }
+ if(!script)
+ cmd[i++] = "-s";
+ if(!plugin)
+ cmd[i++] = "-p";
+ if(!loadimage)
+ cmd[i++] = "-i";
+ if(showxid)
+ cmd[i++] = "-x";
+ cmd[i++] = "--";
+ uri = arg->v ? (char *)arg->v : c->linkhover;
+ if(uri)
+ cmd[i++] = uri;
+ cmd[i++] = NULL;
+ spawn(NULL, &a);
+}
+
+static void
+populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c) {
+ GList *items = gtk_container_get_children(GTK_CONTAINER(menu));
+
+ for(GList *l = items; l; l = l->next) {
+ g_signal_connect(l->data, "activate", G_CALLBACK(popupactivate), c);
+ }
+
+ g_list_free(items);
+}
+
+static void
+popupactivate(GtkMenuItem *menu, Client *c) {
+ /*
+ * context-menu-action-2000 open link
+ * context-menu-action-1 open link in window
+ * context-menu-action-2 download linked file
+ * context-menu-action-3 copy link location
+ * context-menu-action-13 reload
+ * context-menu-action-10 back
+ * context-menu-action-11 forward
+ * context-menu-action-12 stop
+ */
+
+ GtkAction *a = NULL;
+ const char *name;
+ GtkClipboard *prisel;
+
+ a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(menu));
+ if(a == NULL)
+ return;
+
+ name = gtk_action_get_name(a);
+ if(!g_strcmp0(name, "context-menu-action-3")) {
+ prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text(prisel, c->linkhover, -1);
+ }
+}
+
+void
+pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
+ Arg arg = {.v = text };
+ if(text != NULL)
+ loaduri((Client *) d, &arg);
+}
+
+void
+print(Client *c, const Arg *arg) {
+ 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(ev->state == PropertyNewValue) {
+ if(ev->atom == atoms[AtomFind]) {
+ arg.b = TRUE;
+ find(c, &arg);
+ return GDK_FILTER_REMOVE;
+ }
+ else if(ev->atom == atoms[AtomGo]) {
+ arg.v = getatom(c, AtomGo);
+ loaduri(c, &arg);
+ return GDK_FILTER_REMOVE;
+ }
+ }
+ }
+ return GDK_FILTER_CONTINUE;
+}
+
+void
+progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
+ c->progress = webkit_web_view_get_progress(c->view) * 100;
+ update(c);
+}
+
+void
+reload(Client *c, const Arg *arg) {
+ gboolean nocache = *(gboolean *)arg;
+ if(nocache)
+ webkit_web_view_reload_bypass_cache(c->view);
+ else
+ webkit_web_view_reload(c->view);
+}
+
+void
+scroll_h(Client *c, const Arg *arg) {
+ scroll(gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(c->scroll)), arg);
+}
+
+void
+scroll_v(Client *c, const Arg *arg) {
+ scroll(gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(c->scroll)), arg);
+}
+
+void
+scroll(GtkAdjustment *a, const Arg *arg) {
+ gdouble v;
+
+ v = gtk_adjustment_get_value(a);
+ switch (arg->i){
+ case +10000:
+ case -10000:
+ v += gtk_adjustment_get_page_increment(a) *
+ (arg->i / 10000);
+ break;
+ case +20000:
+ case -20000:
+ default:
+ v += gtk_adjustment_get_step_increment(a) * arg->i;
+ }
+
+ v = MAX(v, 0.0);
+ v = MIN(v, gtk_adjustment_get_upper(a) -
+ gtk_adjustment_get_page_size(a));
+ gtk_adjustment_set_value(a, v);
+}
+
+void
+setatom(Client *c, int a, const char *v) {
+ XSync(dpy, False);
+ XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), atoms[a],
+ XA_STRING, 8, PropModeReplace, (unsigned char *)v,
+ strlen(v) + 1);
+}
+
+void
+setup(void) {
+ char *proxy;
+ char *new_proxy;
+ SoupURI *puri;
+ SoupSession *s;