+GtkWidget *
+createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c)
+{
+ Client *n;
+
+ switch (webkit_navigation_action_get_navigation_type(a)) {
+ case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */
+ /*
+ * popup windows of type “other” are almost always triggered
+ * by user gesture, so inverse the logic here
+ */
+/* instead of this, compare destination uri to mouse-over uri for validating window */
+ if (webkit_navigation_action_is_user_gesture(a))
+ return NULL;
+ case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */
+ case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */
+ case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */
+ case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */
+ case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED:
+ n = newclient(c);
+ break;
+ default:
+ return NULL;
+ }
+
+ return GTK_WIDGET(n->view);
+}
+
+gboolean
+buttonreleased(GtkWidget *w, GdkEvent *e, Client *c)
+{
+ WebKitHitTestResultContext element;
+ int i;
+
+ element = webkit_hit_test_result_get_context(c->mousepos);
+
+ for (i = 0; i < LENGTH(buttons); ++i) {
+ if (element & buttons[i].target &&
+ e->button.button == buttons[i].button &&
+ CLEANMASK(e->button.state) == CLEANMASK(buttons[i].mask) &&
+ buttons[i].func) {
+ buttons[i].func(c, &buttons[i].arg, c->mousepos);
+ return buttons[i].stopevent;
+ }
+ }
+
+ return FALSE;
+}
+
+GdkFilterReturn
+processx(GdkXEvent *e, GdkEvent *event, gpointer d)
+{
+ Client *c = (Client *)d;
+ XPropertyEvent *ev;
+ Arg a;
+
+ if (((XEvent *)e)->type == PropertyNotify) {
+ ev = &((XEvent *)e)->xproperty;
+ if (ev->state == PropertyNewValue) {
+ if (ev->atom == atoms[AtomFind]) {
+ find(c, NULL);
+
+ return GDK_FILTER_REMOVE;
+ } else if (ev->atom == atoms[AtomGo]) {
+ a.v = getatom(c, AtomGo);
+ loaduri(c, &a);
+
+ return GDK_FILTER_REMOVE;
+ }
+ }
+ }
+ return GDK_FILTER_CONTINUE;
+}
+
+gboolean
+winevent(GtkWidget *w, GdkEvent *e, Client *c)
+{
+ int i;
+
+ switch (e->type) {
+ case GDK_ENTER_NOTIFY:
+ c->overtitle = c->targeturi;
+ updatetitle(c);
+ break;
+ case GDK_KEY_PRESS:
+ if (!kioskmode) {
+ for (i = 0; i < LENGTH(keys); ++i) {
+ if (gdk_keyval_to_lower(e->key.keyval) ==
+ keys[i].keyval &&
+ CLEANMASK(e->key.state) == keys[i].mod &&
+ keys[i].func) {
+ updatewinid(c);
+ keys[i].func(c, &(keys[i].arg));
+ return TRUE;
+ }
+ }
+ }
+ case GDK_LEAVE_NOTIFY:
+ c->overtitle = NULL;
+ updatetitle(c);
+ break;
+ case GDK_WINDOW_STATE:
+ if (e->window_state.changed_mask ==
+ GDK_WINDOW_STATE_FULLSCREEN)
+ c->fullscreen = e->window_state.new_window_state &
+ GDK_WINDOW_STATE_FULLSCREEN;
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+