X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=8f85f7ba9906885014866f4c32ffa358438e721e;hb=3e017b1a89c1e0d8cb706638d0223afcf834e70d;hp=23fd4520c9c96bf4d6d607d49a7c3b09ccbcea3b;hpb=6124176b896b528d57aeab7e0eaa46271bcb59c5;p=surf.git diff --git a/surf.c b/surf.c index 23fd452..8f85f7b 100644 --- a/surf.c +++ b/surf.c @@ -56,8 +56,8 @@ enum { }; typedef union { - gboolean b; - gint i; + int b; + int i; const void *v; } Arg; @@ -69,8 +69,7 @@ typedef struct Client { WebKitHitTestResult *mousepos; GTlsCertificateFlags tlsflags; Window xid; - gint progress; - gboolean fullscreen; + int progress, fullscreen; const char *title, *targeturi; const char *needle; struct Client *next; @@ -122,7 +121,7 @@ static void runscript(Client *c); static void evalscript(Client *c, const char *jsstr, ...); static void updatewinid(Client *c); static void handleplumb(Client *c, const char *uri); -static void newwindow(Client *c, const Arg *a, gboolean noembed); +static void newwindow(Client *c, const Arg *a, int noembed); static void spawn(Client *c, const Arg *a); static void destroyclient(Client *c); static void cleanup(void); @@ -131,7 +130,7 @@ static void cleanup(void); static WebKitWebView *newview(Client *c, WebKitWebView *rv); static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c); -static gboolean buttonreleased(GtkWidget *w, GdkEventKey *e, Client *c); +static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c); static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key, GdkModifierType mods, Client *c); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, @@ -185,7 +184,7 @@ static char togglestats[10]; static char pagestats[2]; static Atom atoms[AtomLast]; static Window embed; -static gboolean showxid = FALSE; +static int showxid; static int cookiepolicy; static Display *dpy; static Client *clients; @@ -395,9 +394,9 @@ loaduri(Client *c, const Arg *a) const char * geturi(Client *c) { - char *uri; + const char *uri; - if (!(uri = (char *)webkit_web_view_get_uri(c->view))) + if (!(uri = webkit_web_view_get_uri(c->view))) uri = "about:blank"; return uri; } @@ -407,8 +406,8 @@ setatom(Client *c, int a, const char *v) { XSync(dpy, False); XChangeProperty(dpy, c->xid, - atoms[a], XA_STRING, 8, PropModeReplace, - (unsigned char *)v, strlen(v) + 1); + atoms[a], XA_STRING, 8, PropModeReplace, + (unsigned char *)v, strlen(v) + 1); } const char * @@ -814,18 +813,17 @@ createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c) } gboolean -buttonreleased(GtkWidget *w, GdkEventKey *e, Client *c) +buttonreleased(GtkWidget *w, GdkEvent *e, Client *c) { WebKitHitTestResultContext element; - GdkEventButton *eb = (GdkEventButton*)e; int i; element = webkit_hit_test_result_get_context(c->mousepos); for (i = 0; i < LENGTH(buttons); ++i) { if (element & buttons[i].target && - eb->button == buttons[i].button && - CLEANMASK(eb->state) == CLEANMASK(buttons[i].mask) && + 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; @@ -907,7 +905,6 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c) void showview(WebKitWebView *v, Client *c) { - GdkGeometry hints = { 1, 1 }; GdkRGBA bgcolor = { 0 }; GdkWindow *gwin; @@ -918,8 +915,6 @@ showview(WebKitWebView *v, Client *c) 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)); @@ -953,6 +948,7 @@ showview(WebKitWebView *v, Client *c) GtkWidget * createwindow(Client *c) { + char *wmstr; GtkWidget *w; if (embed) { @@ -960,19 +956,14 @@ createwindow(Client *c) } 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"); + wmstr = g_path_get_basename(argv0); + gtk_window_set_wmclass(GTK_WINDOW(w), wmstr, "Surf"); + g_free(wmstr); - /* TA: 20091214: And set the role here as well -- so that - * sessions can pick this up. - */ - gtk_window_set_role(GTK_WINDOW(w), "Surf"); + wmstr = g_strdup_printf("%s[%lu]", "Surf", + webkit_web_view_get_page_id(c->view)); + gtk_window_set_role(GTK_WINDOW(w), wmstr); + g_free(wmstr); gtk_window_set_default_size(GTK_WINDOW(w), 800, 600); } @@ -1235,8 +1226,7 @@ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) void reload(Client *c, const Arg *a) { - gboolean nocache = *(gboolean *)a; - if (nocache) + if (a->b) webkit_web_view_reload_bypass_cache(c->view); else webkit_web_view_reload(c->view); @@ -1542,7 +1532,7 @@ main(int argc, char *argv[]) die("surf-"VERSION", ©2009-2015 surf engineers, " "see LICENSE for details\n"); case 'x': - showxid = TRUE; + showxid = 1; break; case 'z': zoomlevel = strtof(EARGF(usage()), NULL);