};
typedef union {
- gboolean b;
- gint i;
+ int b;
+ int i;
const void *v;
} Arg;
WebKitHitTestResult *mousepos;
GTlsCertificateFlags tlsflags;
Window xid;
- gint progress;
- gboolean fullscreen;
+ int progress, fullscreen;
const char *title, *targeturi;
const char *needle;
struct Client *next;
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);
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,
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;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
- exit(EXIT_FAILURE);
+ exit(1);
}
void
{
if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("Can't install SIGCHLD handler");
- while (0 < waitpid(-1, NULL, WNOHANG));
+ while (waitpid(-1, NULL, WNOHANG) > 0)
+ ;
}
char *
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;
}
{
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 *
}
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;
void
showview(WebKitWebView *v, Client *c)
{
- GdkGeometry hints = { 1, 1 };
GdkRGBA bgcolor = { 0 };
GdkWindow *gwin;
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));
GtkWidget *
createwindow(Client *c)
{
+ char *wmstr;
GtkWidget *w;
if (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");
+ 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);
}
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
{
Arg a = {.v = text };
- if (!text)
+ if (text)
loaduri((Client *) d, &a);
}
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);
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);
gtk_main();
cleanup();
- return EXIT_SUCCESS;
+ return 0;
}