+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)
+{
+ switch (e->type) {
+ case GDK_LEAVE_NOTIFY:
+ c->targeturi = NULL;
+ updatetitle(c);
+ break;
+ case GDK_WINDOW_STATE: /* fallthrough */
+ if (e->window_state.changed_mask ==
+ GDK_WINDOW_STATE_FULLSCREEN) {
+ c->fullscreen = e->window_state.new_window_state &
+ GDK_WINDOW_STATE_FULLSCREEN;
+ break;
+ }
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+showview(WebKitWebView *v, Client *c)
+{
+ GdkGeometry hints = { 1, 1 };
+ GdkRGBA bgcolor = { 0 };
+ GdkWindow *gwin;
+
+ c->finder = webkit_web_view_get_find_controller(c->view);
+ if (enableinspector)
+ c->inspector = webkit_web_view_get_inspector(c->view);
+
+ c->win = createwindow(c);
+
+ gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view));
+ gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_show_all(c->win);
+ gtk_widget_grab_focus(GTK_WIDGET(c->view));
+
+ gwin = gtk_widget_get_window(GTK_WIDGET(c->win));
+ c->xid = gdk_x11_window_get_xid(gwin);
+ updatewinid(c);
+ if (showxid) {
+ gdk_display_sync(gtk_widget_get_display(c->win));
+ puts(winid);
+ }
+
+ if (hidebackground)
+ webkit_web_view_set_background_color(c->view, &bgcolor);
+
+ if (!kioskmode) {
+ addaccelgroup(c);
+ gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK);
+ gdk_window_add_filter(gwin, processx, c);
+ }
+
+ if (runinfullscreen)
+ togglefullscreen(c, NULL);
+
+ if (zoomlevel != 1.0)
+ webkit_web_view_set_zoom_level(c->view, zoomlevel);
+
+ setatom(c, AtomFind, "");
+ setatom(c, AtomUri, "about:blank");
+}
+
+GtkWidget *
+createwindow(Client *c)
+{
+ GtkWidget *w;
+
+ if (embed) {
+ w = gtk_plug_new(embed);
+ } else {
+ w = 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(w), "surf", "Surf");
+
+ /* TA: 20091214: And set the role here as well -- so that
+ * sessions can pick this up.
+ */
+ gtk_window_set_role(GTK_WINDOW(w), "Surf");