surf

surf browser, a WebKit2GTK based browser
Log | Files | Refs | README | LICENSE

commit a908f51779947a1b5854feadb15e3eb8e1919822
parent 8de4119da73c58f265547f1b6f3e117859189a67
Author: Quentin Rameau <quinq@fifth.space>
Date:   Tue,  5 Jan 2016 13:50:24 +0100

Run user scripts at an adequate moment

Do not wait for the load to be completed to run scripts, the recommended
timing is when the window object is cleared.

Diffstat:
surf.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/surf.c b/surf.c @@ -164,6 +164,7 @@ static const char *getcert(const char *uri); static void setcert(Client *c, const char *file); static const char *getstyle(const char *uri); static void setstyle(Client *c, const char *file); +static Client *getpageclient(const int pageid); static void runscript(Client *c); static void evalscript(Client *c, const char *jsstr, ...); static void updatewinid(Client *c); @@ -177,6 +178,7 @@ static void cleanup(void); /* GTK/WebKit */ static WebKitWebView *newview(Client *c, WebKitWebView *rv); static void initwebextensions(WebKitWebContext *wc, Client *c); +static gboolean readpipe(GIOChannel *s, GIOCondition ioc, gpointer u); static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c); static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c); @@ -914,6 +916,18 @@ setstyle(Client *c, const char *file) g_free(style); } +Client * +getpageclient(const int pageid) +{ + Client *c; + + for (c = clients; c; c = c->next) { + if (c->pageid == pageid) + break; + } + return c; +} + void runscript(Client *c) { @@ -1183,6 +1197,7 @@ readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused) char msg[BUFSIZ]; gsize msgsz; GError *gerr = NULL; + Client *c; if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != G_IO_STATUS_NORMAL) { @@ -1493,7 +1508,6 @@ loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) evalscript(c, "document.documentElement.style.overflow = '%s'", enablescrollbars ? "auto" : "hidden"); */ - runscript(c); break; } updatetitle(c);