From d6954e15417da723c7938bf11e328dacdfefdc26 Mon Sep 17 00:00:00 2001 From: Eddie Thieda Date: Mon, 18 Jun 2018 06:13:16 -0400 Subject: Fixed wording in FAQ.md --- FAQ.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FAQ.md b/FAQ.md index 0a71e41..48e6097 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,10 +1,10 @@ # Frequently Asked Questions -## Surf is starting up slowly. What might happen? +## Surf is starting up slowly. What might be causing this? -The first suspect for such a behaviour is the plugin handling. Run surf -on the commandline and see if there are errors because of »nspluginwrap‐ -per« or failed RPCs to them. If that is true, go to ~/.mozilla/plugins -and try removing stale links to plugins not on your system anymore. This +The first suspect for such behaviour is the plugin handling. Run surf on +the commandline and see if there are errors because of “nspluginwrapper” +or failed RPCs to them. If that is true, go to ~/.mozilla/plugins and +try removing stale links to plugins not on your system anymore. This will stop surf from trying to load them. -- cgit v1.2.3 From befe481a9b970cf2bc90ca671e1df1d1082ac41e Mon Sep 17 00:00:00 2001 From: nzl Date: Thu, 15 Mar 2018 03:46:52 +0800 Subject: Allow tilde expansion in loaduri also fixed a bug that ~foo/ was expanded to /home/fo/o/ --- surf.c | 63 ++++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/surf.c b/surf.c index a5cc5a7..ae2bc81 100644 --- a/surf.c +++ b/surf.c @@ -146,6 +146,7 @@ static void sigchld(int unused); static void sighup(int unused); static char *buildfile(const char *path); static char *buildpath(const char *path); +static char *untildepath(const char *path); static const char *getuserhomedir(const char *user); static const char *getcurrentuserhomedir(void); static Client *newclient(Client *c); @@ -470,26 +471,12 @@ getcurrentuserhomedir(void) char * buildpath(const char *path) { - char *apath, *name, *p, *fpath; - const char *homedir; - - if (path[0] == '~') { - if (path[1] == '/' || path[1] == '\0') { - p = (char *)&path[1]; - homedir = getcurrentuserhomedir(); - } else { - if ((p = strchr(path, '/'))) - name = g_strndup(&path[1], --p - path); - else - name = g_strdup(&path[1]); + char *apath, *fpath; - homedir = getuserhomedir(name); - g_free(name); - } - apath = g_build_filename(homedir, p, NULL); - } else { + if (path[0] == '~') + apath = untildepath(path); + else apath = g_strdup(path); - } /* creating directory */ if (g_mkdir_with_parents(apath, 0700) < 0) @@ -501,6 +488,28 @@ buildpath(const char *path) return fpath; } +char * +untildepath(const char *path) +{ + char *apath, *name, *p; + const char *homedir; + + if (path[1] == '/' || path[1] == '\0') { + p = (char *)&path[1]; + homedir = getcurrentuserhomedir(); + } else { + if ((p = strchr(path, '/'))) + name = g_strndup(&path[1], p - (path + 1)); + else + name = g_strdup(&path[1]); + + homedir = getuserhomedir(name); + g_free(name); + } + apath = g_build_filename(homedir, p, NULL); + return apath; +} + Client * newclient(Client *rc) { @@ -522,7 +531,7 @@ void loaduri(Client *c, const Arg *a) { struct stat st; - char *url, *path; + char *url, *path, *apath; const char *uri = a->v; if (g_strcmp0(uri, "") == 0) @@ -533,11 +542,19 @@ loaduri(Client *c, const Arg *a) g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) { url = g_strdup(uri); - } else if (!stat(uri, &st) && (path = realpath(uri, NULL))) { - url = g_strdup_printf("file://%s", path); - free(path); } else { - url = g_strdup_printf("http://%s", uri); + if (uri[0] == '~') + apath = untildepath(uri); + else + apath = (char *)uri; + if (!stat(apath, &st) && (path = realpath(apath, NULL))) { + url = g_strdup_printf("file://%s", path); + free(path); + } else { + url = g_strdup_printf("http://%s", uri); + } + if (apath != uri) + free(apath); } setatom(c, AtomUri, url); -- cgit v1.2.3 From c60523a702fbc77899457243f1a85e4990adfb97 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Fri, 16 Mar 2018 12:44:04 +0100 Subject: Exit more gracefully on web process crash. --- surf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/surf.c b/surf.c index ae2bc81..eab314a 100644 --- a/surf.c +++ b/surf.c @@ -206,6 +206,9 @@ static void downloadstarted(WebKitWebContext *wc, WebKitDownload *d, Client *c); static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c); static void download(Client *c, WebKitURIResponse *r); +static void webprocessterminated(WebKitWebView *v, + WebKitWebProcessTerminationReason r, + Client *c); static void closeview(WebKitWebView *v, Client *c); static void destroywin(GtkWidget* w, Client *c); @@ -1187,6 +1190,8 @@ newview(Client *c, WebKitWebView *rv) G_CALLBACK(permissionrequested), c); g_signal_connect(G_OBJECT(v), "ready-to-show", G_CALLBACK(showview), c); + g_signal_connect(G_OBJECT(v), "web-process-terminated", + G_CALLBACK(webprocessterminated), c); return v; } @@ -1691,6 +1696,15 @@ download(Client *c, WebKitURIResponse *r) spawn(c, &a); } +void +webprocessterminated(WebKitWebView *v, WebKitWebProcessTerminationReason r, + Client *c) +{ + fprintf(stderr, "web process terminated: %s\n", + r == WEBKIT_WEB_PROCESS_CRASHED ? "crashed" : "no memory"); + closeview(v, c); +} + void closeview(WebKitWebView *v, Client *c) { -- cgit v1.2.3 From 0bd553a078cc8ec1d197fd7af96b07b1921049e2 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Sun, 25 Mar 2018 12:07:41 +0200 Subject: Request cookiemanager only once at creation --- surf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/surf.c b/surf.c index eab314a..6950dc5 100644 --- a/surf.c +++ b/surf.c @@ -1079,6 +1079,7 @@ newview(Client *c, WebKitWebView *rv) WebKitSettings *settings; WebKitUserContentManager *contentmanager; WebKitWebContext *context; + WebKitCookieManager *cookiemanager; /* Webview */ if (rv) { @@ -1125,6 +1126,8 @@ newview(Client *c, WebKitWebView *rv) "base-data-directory", cachedir, NULL)); + cookiemanager = webkit_web_context_get_cookie_manager(context); + /* rendering process model, can be a shared unique one * or one for each view */ webkit_web_context_set_process_model(context, @@ -1139,12 +1142,10 @@ newview(Client *c, WebKitWebView *rv) WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); /* Currently only works with text file to be compatible with curl */ - webkit_cookie_manager_set_persistent_storage( - webkit_web_context_get_cookie_manager(context), cookiefile, - WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); + webkit_cookie_manager_set_persistent_storage(cookiemanager, + cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); /* cookie policy */ - webkit_cookie_manager_set_accept_policy( - webkit_web_context_get_cookie_manager(context), + webkit_cookie_manager_set_accept_policy(cookiemanager, cookiepolicy_get()); /* languages */ webkit_web_context_set_preferred_languages(context, -- cgit v1.2.3 From 1bd6d201020f67160872c28534edff532b5198b9 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 23 Nov 2015 22:12:00 +0100 Subject: ext: first commit for surf lib --- Makefile | 54 +++++++++++++++++++++++++++++++++++++++++++----------- config.mk | 12 +++++++++--- libsurf-webext.c | 7 +++++++ 3 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 libsurf-webext.c diff --git a/Makefile b/Makefile index d32d330..e1e7e1f 100644 --- a/Makefile +++ b/Makefile @@ -6,30 +6,49 @@ include config.mk SRC = surf.c OBJ = $(SRC:.c=.o) +LIBSRC = libsurf-webext.c +LIBOBJ = $(LIBSRC:.c=.lo) -all: options surf +all: options libsurf-webext.la surf options: @echo surf build options: - @echo "CFLAGS = $(SURF_CFLAGS)" - @echo "LDFLAGS = $(SURF_LDFLAGS)" - @echo "CC = $(CC)" + @echo "CFLAGS = $(SURFCFLAGS)" + @echo "LDFLAGS = $(SURFLDFLAGS)" + @echo "CC = $(CC)" + @echo "LIBCFLAGS = $(LIBCFLAGS)" + @echo "LIBLDFLAGS = $(LIBLDFLAGS)" + @echo "LIBTOOL = $(LIBTOOL)" .c.o: @echo CC -c $< - @$(CC) $(SURF_CFLAGS) -c $< + @$(CC) $(SURFCFLAGS) -c $< + +.c.lo: + @echo libtool compile $< + @$(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $< $(OBJ): config.h config.mk +$(LIBOBJ): config.mk config.h: @echo creating $@ from config.def.h @cp config.def.h $@ +libsurf-webext.la: $(LIBOBJ) + @echo libtool link $@ + @$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \ + $(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX) + surf: $(OBJ) @echo CC -o $@ - @$(CC) $(SURF_CFLAGS) -o $@ $(OBJ) $(SURF_LDFLAGS) + @$(CC) $(SURFCFLAGS) -o $@ $(OBJ) $(SURFLDFLAGS) + +clean-lib: + @echo cleaning library + @rm -rf libsurf-webext.la .libs $(LIBOBJ) $(LIBOBJ:.lo=.o) -clean: +clean: clean-lib @echo cleaning @rm -f surf $(OBJ) @@ -42,12 +61,18 @@ dist: distclean @mkdir -p surf-$(VERSION) @cp -R LICENSE Makefile config.mk config.def.h README \ surf-open.sh arg.h TODO.md surf.png \ - surf.1 $(SRC) surf-$(VERSION) + surf.1 $(SRC) $(LIBSRC) surf-$(VERSION) @tar -cf surf-$(VERSION).tar surf-$(VERSION) @gzip surf-$(VERSION).tar @rm -rf surf-$(VERSION) -install: all +install-lib: libsurf-webext.la + @echo installing library file to $(DESTDIR)$(LIBPREFIX) + @mkdir -p $(DESTDIR)$(LIBPREFIX) + @$(LIBTOOL) --mode install install -c libsurf-webext.la \ + $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la + +install: all install-lib @echo installing executable file to $(DESTDIR)$(PREFIX)/bin @mkdir -p $(DESTDIR)$(PREFIX)/bin @cp -f surf $(DESTDIR)$(PREFIX)/bin @@ -57,10 +82,17 @@ install: all @sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 @chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 -uninstall: +uninstall-lib: + @echo removing library file from $(DESTDIR)$(LIBPREFIX) + @$(LIBTOOL) --mode uninstall rm -f \ + $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la + @- rm -df $(DESTDIR)$(LIBPREFIX) + +uninstall: uninstall-lib @echo removing executable file from $(DESTDIR)$(PREFIX)/bin @rm -f $(DESTDIR)$(PREFIX)/bin/surf @echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1 @rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 -.PHONY: all options clean dist install uninstall +.SUFFIXES: .la .lo .o .c +.PHONY: all options clean-dist clean dist install-lib install uninstall-lib uninstall diff --git a/config.mk b/config.mk index 7972bb6..8d96b29 100644 --- a/config.mk +++ b/config.mk @@ -13,16 +13,21 @@ X11LIB = /usr/X11R6/lib GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0` +WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0` +WEBEXTLIB = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0` # includes and libs INCS = -I$(X11INC) $(GTKINC) LIBS = -L$(X11LIB) -lX11 $(GTKLIB) -lgthread-2.0 # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -DWEBEXTDIR=\"${LIBPREFIX}\" \ +CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBPREFIX)\" \ -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -SURF_CFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) -SURF_LDFLAGS = $(LIBS) $(LDFLAGS) +SURFCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) +SURFLDFLAGS = $(LIBS) $(LDFLAGS) +LIBCPPFLAGS = -DWEBEXTDIR=\"$(LIBPREFIX)\" +LIBCFLAGS = $(WEBEXTINC) $(LIBCPPFLAGS) $(CFLAGS) +LIBLDFLAGS = $(WEBEXTLIB) $(LDFLAGS) # Solaris #CFLAGS = -fast $(INCS) -DVERSION=\"$(VERSION)\" @@ -30,3 +35,4 @@ SURF_LDFLAGS = $(LIBS) $(LDFLAGS) # compiler and linker #CC = c99 +LIBTOOL = libtool --quiet diff --git a/libsurf-webext.c b/libsurf-webext.c new file mode 100644 index 0000000..a3bcb3f --- /dev/null +++ b/libsurf-webext.c @@ -0,0 +1,7 @@ +#include + +G_MODULE_EXPORT void +webkit_web_extension_initialize(WebKitWebExtension *e) +{ + return; +} -- cgit v1.2.3 From 7ea0c2f7f8c5cc4616d8dc0676f7b4b59351667b Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 7 Dec 2015 15:50:00 +0100 Subject: Communicate with webextension via a pipe --- Makefile | 2 +- config.def.h | 16 +++---- libsurf-webext.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- surf.c | 114 ++++++++++++++++++++++++++++++++++--------------- 4 files changed, 213 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index e1e7e1f..9aace4f 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ options: @$(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $< $(OBJ): config.h config.mk -$(LIBOBJ): config.mk +$(LIBOBJ): config.h config.mk config.h: @echo creating $@ from config.def.h diff --git a/config.def.h b/config.def.h index 6748f8a..8cdc397 100644 --- a/config.def.h +++ b/config.def.h @@ -143,15 +143,13 @@ static Key keys[] = { { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, - /* Currently we have to use scrolling steps that WebKit2GTK+ gives us - * d: step down, u: step up, r: step right, l:step left - * D: page down, U: page up */ - { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } }, - { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } }, - { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } }, - { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } }, - { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } }, - { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } }, + /* vertical and horizontal scrolling, in viewport percentage */ + { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } }, + { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } }, + { MODKEY, GDK_KEY_b, scrollv, { .i = +50 } }, + { MODKEY, GDK_KEY_space, scrollv, { .i = -50 } }, + { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } }, + { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, diff --git a/libsurf-webext.c b/libsurf-webext.c index a3bcb3f..6c3deb7 100644 --- a/libsurf-webext.c +++ b/libsurf-webext.c @@ -1,7 +1,131 @@ +#include +#include +#include +#include + +#include #include +#include +#include + +#define LENGTH(x) (sizeof(x) / sizeof(x[0])) + +#define MSGBUFSZ 32 + +typedef struct Page { + guint64 id; + WebKitWebPage *webpage; + WebKitDOMDOMWindow *view; + struct Page *next; +} Page; + +static int pipein, pipeout; +static Page *pages; + +Page * +newpage(WebKitWebPage *page) +{ + Page *p; + + if (!(p = calloc(1, sizeof(Page)))) + die("Cannot malloc!\n"); + + p->next = pages; + pages = p; + + p->id = webkit_web_page_get_id(page); + p->webpage = page; + + return p; +} + +static void +msgsurf(Page *p, const char *s) +{ + char msg[MSGBUFSZ]; + int ret; + + msg[0] = p ? p->id : 0; + ret = snprintf(&msg[1], sizeof(msg) - 1, "%s", s); + if (ret >= sizeof(msg)) { + fprintf(stderr, "webext: message too long: %d\n", ret); + return; + } + + if (pipeout) { + if (write(pipeout, msg, sizeof(msg)) < 0) + fprintf(stderr, "webext: error sending: %s\n", msg); + } +} + +static gboolean +readpipe(GIOChannel *s, GIOCondition c, gpointer unused) +{ + char msg[MSGBUFSZ]; + gsize msgsz; + GError *gerr = NULL; + glong wh, ww; + Page *p; + + if (g_io_channel_read_chars(s, msg, LENGTH(msg), &msgsz, &gerr) != + G_IO_STATUS_NORMAL) { + fprintf(stderr, "webext: error reading pipe: %s\n", + gerr->message); + g_error_free(gerr); + return TRUE; + } + msg[msgsz] = '\0'; + + for (p = pages; p; p = p->next) { + if (p->id == msg[0]) + break; + } + if (!p || !p->view) + return TRUE; + + switch (msg[1]) { + case 'h': + ww = webkit_dom_dom_window_get_inner_width(p->view); + webkit_dom_dom_window_scroll_by(p->view, + (ww / 100) * msg[2], 0); + break; + case 'v': + wh = webkit_dom_dom_window_get_inner_height(p->view); + webkit_dom_dom_window_scroll_by(p->view, + 0, (wh / 100) * msg[2]); + break; + } + + return TRUE; +} + +static void +documentloaded(WebKitWebPage *wp, Page *p) +{ + p->view = webkit_dom_document_get_default_view( + webkit_web_page_get_dom_document(wp)); +} + +static void +webpagecreated(WebKitWebExtension *e, WebKitWebPage *wp, gpointer unused) +{ + Page *p = newpage(wp); + + g_signal_connect(wp, "document-loaded", G_CALLBACK(documentloaded), p); +} G_MODULE_EXPORT void -webkit_web_extension_initialize(WebKitWebExtension *e) +webkit_web_extension_initialize_with_user_data(WebKitWebExtension *e, GVariant *gv) { - return; + GIOChannel *gchanpipe; + + g_signal_connect(e, "page-created", G_CALLBACK(webpagecreated), NULL); + + g_variant_get(gv, "(ii)", &pipein, &pipeout); + msgsurf(NULL, "i"); + + gchanpipe = g_io_channel_unix_new(pipein); + g_io_channel_set_encoding(gchanpipe, NULL, NULL); + g_io_channel_set_close_on_unref(gchanpipe, TRUE); + g_io_add_watch(gchanpipe, G_IO_IN, readpipe, NULL); } diff --git a/surf.c b/surf.c index 6950dc5..25940f9 100644 --- a/surf.c +++ b/surf.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -28,11 +27,13 @@ #include #include #include +#include #include "arg.h" #define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) +#define MSGBUFSZ 32 enum { AtomFind, AtomGo, AtomUri, AtomLast }; @@ -104,6 +105,7 @@ typedef struct Client { GTlsCertificate *cert, *failedcert; GTlsCertificateFlags tlserr; Window xid; + unsigned long pageid; int progress, fullscreen, https, insecure, errorpage; const char *title, *overtitle, *targeturi; const char *needle; @@ -171,6 +173,7 @@ static void updatewinid(Client *c); static void handleplumb(Client *c, const char *uri); static void newwindow(Client *c, const Arg *a, int noembed); static void spawn(Client *c, const Arg *a); +static void msgext(Client *c, char type, const Arg *a); static void destroyclient(Client *c); static void cleanup(void); @@ -183,6 +186,7 @@ static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); static gboolean winevent(GtkWidget *w, GdkEvent *e, Client *c); +static gboolean readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused); static void showview(WebKitWebView *v, Client *c); static GtkWidget *createwindow(Client *c); static gboolean loadfailedtls(WebKitWebView *v, gchar *uri, @@ -219,7 +223,8 @@ static void print(Client *c, const Arg *a); static void showcert(Client *c, const Arg *a); static void clipboard(Client *c, const Arg *a); static void zoom(Client *c, const Arg *a); -static void scroll(Client *c, const Arg *a); +static void scrollv(Client *c, const Arg *a); +static void scrollh(Client *c, const Arg *a); static void navigate(Client *c, const Arg *a); static void stop(Client *c, const Arg *a); static void toggle(Client *c, const Arg *a); @@ -247,6 +252,7 @@ static char *stylefile; static const char *useragent; static Parameter *curconfig; static int modparams[ParameterLast]; +static int pipein[2], pipeout[2]; char *argv0; static ParamName loadtransient[] = { @@ -318,6 +324,7 @@ die(const char *errstr, ...) void setup(void) { + GIOChannel *gchanin; GdkDisplay *gdpy; int i, j; @@ -348,6 +355,16 @@ setup(void) gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); + if (pipe(pipeout) < 0 || pipe(pipein) < 0) { + fputs("Unable to create pipes\n", stderr); + } else { + gchanin = g_io_channel_unix_new(pipein[0]); + g_io_channel_set_encoding(gchanin, NULL, NULL); + g_io_channel_set_close_on_unref(gchanin, TRUE); + g_io_add_watch(gchanin, G_IO_IN, readpipe, NULL); + } + + for (i = 0; i < LENGTH(certs); ++i) { if (!regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) { certs[i].file = g_strconcat(certdir, "/", certs[i].file, @@ -1033,6 +1050,8 @@ spawn(Client *c, const Arg *a) if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); + close(pipein[0]); + close(pipeout[1]); setsid(); execvp(((char **)a->v)[0], (char **)a->v); fprintf(stderr, "%s: execvp %s", argv0, ((char **)a->v)[0]); @@ -1065,6 +1084,9 @@ cleanup(void) { while (clients) destroyclient(clients); + + close(pipein[0]); + close(pipeout[1]); g_free(cookiefile); g_free(scriptfile); g_free(stylefile); @@ -1077,14 +1099,13 @@ newview(Client *c, WebKitWebView *rv) { WebKitWebView *v; WebKitSettings *settings; - WebKitUserContentManager *contentmanager; WebKitWebContext *context; WebKitCookieManager *cookiemanager; + WebKitUserContentManager *contentmanager; /* Webview */ if (rv) { - v = WEBKIT_WEB_VIEW( - webkit_web_view_new_with_related_view(rv)); + v = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(rv)); } else { settings = webkit_settings_new_with_settings( "allow-file-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i, @@ -1197,9 +1218,43 @@ newview(Client *c, WebKitWebView *rv) return v; } +static gboolean +readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused) +{ + char msg[MSGBUFSZ]; + gsize msgsz; + GError *gerr = NULL; + + if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != + G_IO_STATUS_NORMAL) { + fprintf(stderr, "surf: error reading pipe: %s\n", + gerr->message); + g_error_free(gerr); + return TRUE; + } + msg[msgsz] = '\0'; + + switch (msg[1]) { + case 'i': + close(pipein[1]); + close(pipeout[0]); + break; + } + + return TRUE; +} + void initwebextensions(WebKitWebContext *wc, Client *c) { + GVariant *gv; + + if (!pipeout[0] || !pipein[1]) + return; + + gv = g_variant_new("(ii)", pipeout[0], pipein[1]); + + webkit_web_context_set_web_extensions_initialization_user_data(wc, gv); webkit_web_context_set_web_extensions_directory(wc, WEBEXTDIR); } @@ -1326,6 +1381,7 @@ showview(WebKitWebView *v, Client *c) c->finder = webkit_web_view_get_find_controller(c->view); c->inspector = webkit_web_view_get_inspector(c->view); + c->pageid = webkit_web_view_get_page_id(c->view); c->win = createwindow(c); gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view)); @@ -1375,8 +1431,7 @@ createwindow(Client *c) gtk_window_set_wmclass(GTK_WINDOW(w), wmstr, "Surf"); g_free(wmstr); - wmstr = g_strdup_printf("%s[%lu]", "Surf", - webkit_web_view_get_page_id(c->view)); + wmstr = g_strdup_printf("%s[%lu]", "Surf", c->pageid); gtk_window_set_role(GTK_WINDOW(w), wmstr); g_free(wmstr); @@ -1797,38 +1852,27 @@ zoom(Client *c, const Arg *a) curconfig[ZoomLevel].val.f = webkit_web_view_get_zoom_level(c->view); } -void -scroll(Client *c, const Arg *a) +static void +msgext(Client *c, char type, const Arg *a) { - GdkEvent *ev = gdk_event_new(GDK_KEY_PRESS); + char msg[MSGBUFSZ] = { c->pageid, type, a->i, '\0' }; - gdk_event_set_device(ev, gdkkb); - ev->key.window = gtk_widget_get_window(GTK_WIDGET(c->win)); - ev->key.state = GDK_CONTROL_MASK; - ev->key.time = GDK_CURRENT_TIME; - - switch (a->i) { - case 'd': - ev->key.keyval = GDK_KEY_Down; - break; - case 'D': - ev->key.keyval = GDK_KEY_Page_Down; - break; - case 'l': - ev->key.keyval = GDK_KEY_Left; - break; - case 'r': - ev->key.keyval = GDK_KEY_Right; - break; - case 'U': - ev->key.keyval = GDK_KEY_Page_Up; - break; - case 'u': - ev->key.keyval = GDK_KEY_Up; - break; + if (pipeout[1]) { + if (write(pipeout[1], msg, sizeof(msg)) < 0) + fprintf(stderr, "surf: error sending: %s\n", msg); } +} + +void +scrollv(Client *c, const Arg *a) +{ + msgext(c, 'v', a); +} - gdk_event_put(ev); +void +scrollh(Client *c, const Arg *a) +{ + msgext(c, 'h', a); } void -- cgit v1.2.3 From 1901359efa10fe2e18794df34fc33b81da03a6f5 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 4 Jan 2016 16:09:12 +0100 Subject: Add a file for shared functions New common.[hc] files where shared functions between surf and webkitextension will be put. First addition is die(). --- Makefile | 6 +++--- common.c | 15 +++++++++++++++ common.h | 3 +++ libsurf-webext.c | 4 ++-- surf.c | 14 +------------- 5 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 common.c create mode 100644 common.h diff --git a/Makefile b/Makefile index 9aace4f..0385a50 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ include config.mk -SRC = surf.c +SRC = surf.c common.c OBJ = $(SRC:.c=.o) -LIBSRC = libsurf-webext.c +LIBSRC = libsurf-webext.c common.c LIBOBJ = $(LIBSRC:.c=.lo) all: options libsurf-webext.la surf @@ -38,7 +38,7 @@ config.h: libsurf-webext.la: $(LIBOBJ) @echo libtool link $@ @$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \ - $(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX) + $(LIBOBJ) $(LIB) -rpath $(DESTDIR)$(LIBPREFIX) surf: $(OBJ) @echo CC -o $@ diff --git a/common.c b/common.c new file mode 100644 index 0000000..42662ed --- /dev/null +++ b/common.c @@ -0,0 +1,15 @@ +#include +#include +#include + +void +die(const char *errstr, ...) +{ + va_list ap; + + va_start(ap, errstr); + vfprintf(stderr, errstr, ap); + va_end(ap); + exit(1); +} + diff --git a/common.h b/common.h new file mode 100644 index 0000000..527c4f7 --- /dev/null +++ b/common.h @@ -0,0 +1,3 @@ +#define MSGBUFSZ 32 + +void die(char *, ...); diff --git a/libsurf-webext.c b/libsurf-webext.c index 6c3deb7..4270b47 100644 --- a/libsurf-webext.c +++ b/libsurf-webext.c @@ -8,9 +8,9 @@ #include #include -#define LENGTH(x) (sizeof(x) / sizeof(x[0])) +#include "common.h" -#define MSGBUFSZ 32 +#define LENGTH(x) (sizeof(x) / sizeof(x[0])) typedef struct Page { guint64 id; diff --git a/surf.c b/surf.c index 25940f9..d48fbc9 100644 --- a/surf.c +++ b/surf.c @@ -30,10 +30,10 @@ #include #include "arg.h" +#include "common.h" #define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) -#define MSGBUFSZ 32 enum { AtomFind, AtomGo, AtomUri, AtomLast }; @@ -142,7 +142,6 @@ typedef struct { /* Surf */ static void usage(void); -static void die(const char *errstr, ...); static void setup(void); static void sigchld(int unused); static void sighup(int unused); @@ -310,17 +309,6 @@ usage(void) "[-r scriptfile] [-u useragent] [-z zoomlevel] [uri]\n"); } -void -die(const char *errstr, ...) -{ - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(1); -} - void setup(void) { -- cgit v1.2.3 From 660413256f4c1cc916e6f96b9156a4f5a85dfcc4 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 12 Jun 2017 18:19:58 +0200 Subject: ext: get the right DOM on msg When navigating history, the document-loaded signal isn't triggered and we can't directly get back the previous webview, so we have no other choice than to look it up everytime a new message is received. --- libsurf-webext.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/libsurf-webext.c b/libsurf-webext.c index 4270b47..684d4a5 100644 --- a/libsurf-webext.c +++ b/libsurf-webext.c @@ -15,7 +15,6 @@ typedef struct Page { guint64 id; WebKitWebPage *webpage; - WebKitDOMDOMWindow *view; struct Page *next; } Page; @@ -63,6 +62,7 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused) { char msg[MSGBUFSZ]; gsize msgsz; + WebKitDOMDOMWindow *view; GError *gerr = NULL; glong wh, ww; Page *p; @@ -80,18 +80,19 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused) if (p->id == msg[0]) break; } - if (!p || !p->view) + if (!p || !(view = webkit_dom_document_get_default_view( + webkit_web_page_get_dom_document(p->webpage)))) return TRUE; switch (msg[1]) { case 'h': - ww = webkit_dom_dom_window_get_inner_width(p->view); - webkit_dom_dom_window_scroll_by(p->view, + ww = webkit_dom_dom_window_get_inner_width(view); + webkit_dom_dom_window_scroll_by(view, (ww / 100) * msg[2], 0); break; case 'v': - wh = webkit_dom_dom_window_get_inner_height(p->view); - webkit_dom_dom_window_scroll_by(p->view, + wh = webkit_dom_dom_window_get_inner_height(view); + webkit_dom_dom_window_scroll_by(view, 0, (wh / 100) * msg[2]); break; } @@ -99,19 +100,10 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused) return TRUE; } -static void -documentloaded(WebKitWebPage *wp, Page *p) -{ - p->view = webkit_dom_document_get_default_view( - webkit_web_page_get_dom_document(wp)); -} - static void webpagecreated(WebKitWebExtension *e, WebKitWebPage *wp, gpointer unused) { Page *p = newpage(wp); - - g_signal_connect(wp, "document-loaded", G_CALLBACK(documentloaded), p); } G_MODULE_EXPORT void -- cgit v1.2.3 From e7c629b258653a5237ca72cf2087a391e55829f1 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 8 Oct 2018 12:34:47 +0200 Subject: Unobfuscate Makefile --- Makefile | 65 +++++++++++++++++++++++++--------------------------------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 0385a50..72df488 100644 --- a/Makefile +++ b/Makefile @@ -21,78 +21,63 @@ options: @echo "LIBTOOL = $(LIBTOOL)" .c.o: - @echo CC -c $< - @$(CC) $(SURFCFLAGS) -c $< + $(CC) $(SURFCFLAGS) -c $< .c.lo: - @echo libtool compile $< - @$(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $< + $(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $< $(OBJ): config.h config.mk $(LIBOBJ): config.h config.mk config.h: - @echo creating $@ from config.def.h - @cp config.def.h $@ + cp config.def.h $@ libsurf-webext.la: $(LIBOBJ) - @echo libtool link $@ - @$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \ + $(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \ $(LIBOBJ) $(LIB) -rpath $(DESTDIR)$(LIBPREFIX) surf: $(OBJ) - @echo CC -o $@ - @$(CC) $(SURFCFLAGS) -o $@ $(OBJ) $(SURFLDFLAGS) + $(CC) $(SURFCFLAGS) -o $@ $(OBJ) $(SURFLDFLAGS) clean-lib: - @echo cleaning library - @rm -rf libsurf-webext.la .libs $(LIBOBJ) $(LIBOBJ:.lo=.o) + rm -rf libsurf-webext.la .libs $(LIBOBJ) $(LIBOBJ:.lo=.o) clean: clean-lib - @echo cleaning - @rm -f surf $(OBJ) + rm -f surf $(OBJ) distclean: clean - @echo cleaning dist - @rm -f config.h surf-$(VERSION).tar.gz + rm -f config.h surf-$(VERSION).tar.gz dist: distclean - @echo creating dist tarball - @mkdir -p surf-$(VERSION) - @cp -R LICENSE Makefile config.mk config.def.h README \ + mkdir -p surf-$(VERSION) + cp -R LICENSE Makefile config.mk config.def.h README \ surf-open.sh arg.h TODO.md surf.png \ surf.1 $(SRC) $(LIBSRC) surf-$(VERSION) - @tar -cf surf-$(VERSION).tar surf-$(VERSION) - @gzip surf-$(VERSION).tar - @rm -rf surf-$(VERSION) + tar -cf surf-$(VERSION).tar surf-$(VERSION) + gzip surf-$(VERSION).tar + rm -rf surf-$(VERSION) install-lib: libsurf-webext.la - @echo installing library file to $(DESTDIR)$(LIBPREFIX) - @mkdir -p $(DESTDIR)$(LIBPREFIX) - @$(LIBTOOL) --mode install install -c libsurf-webext.la \ + mkdir -p $(DESTDIR)$(LIBPREFIX) + $(LIBTOOL) --mode install install -c libsurf-webext.la \ $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la install: all install-lib - @echo installing executable file to $(DESTDIR)$(PREFIX)/bin - @mkdir -p $(DESTDIR)$(PREFIX)/bin - @cp -f surf $(DESTDIR)$(PREFIX)/bin - @chmod 755 $(DESTDIR)$(PREFIX)/bin/surf - @echo installing manual page to $(DESTDIR)$(MANPREFIX)/man1 - @mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - @sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 - @chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f surf $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/surf + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 + chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 uninstall-lib: - @echo removing library file from $(DESTDIR)$(LIBPREFIX) - @$(LIBTOOL) --mode uninstall rm -f \ + $(LIBTOOL) --mode uninstall rm -f \ $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la - @- rm -df $(DESTDIR)$(LIBPREFIX) + - rm -df $(DESTDIR)$(LIBPREFIX) uninstall: uninstall-lib - @echo removing executable file from $(DESTDIR)$(PREFIX)/bin - @rm -f $(DESTDIR)$(PREFIX)/bin/surf - @echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1 - @rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 + rm -f $(DESTDIR)$(PREFIX)/bin/surf + rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 .SUFFIXES: .la .lo .o .c .PHONY: all options clean-dist clean dist install-lib install uninstall-lib uninstall -- cgit v1.2.3 From 3321c42d36ce79ebecd8b2ea7e93ca2e5c2ff98d Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 8 Oct 2018 13:47:25 +0200 Subject: Remove libtool depencency, reorganise Makefile We don't need libtool anymore, just build the library directly. This lets us simplify the Makefile too. --- Makefile | 65 ++++++++++++++++++++++++++------------------------------------- config.mk | 21 +++++++-------------- 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index 72df488..3b601ff 100644 --- a/Makefile +++ b/Makefile @@ -6,44 +6,38 @@ include config.mk SRC = surf.c common.c OBJ = $(SRC:.c=.o) -LIBSRC = libsurf-webext.c common.c -LIBOBJ = $(LIBSRC:.c=.lo) +WEBEXTSRC = libsurf-webext.c +WEBEXTOBJ = $(WEBEXTSRC:.c=.o) -all: options libsurf-webext.la surf +all: options libsurf-webext.so surf options: @echo surf build options: - @echo "CFLAGS = $(SURFCFLAGS)" - @echo "LDFLAGS = $(SURFLDFLAGS)" - @echo "CC = $(CC)" - @echo "LIBCFLAGS = $(LIBCFLAGS)" - @echo "LIBLDFLAGS = $(LIBLDFLAGS)" - @echo "LIBTOOL = $(LIBTOOL)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(SURFCFLAGS) $(CFLAGS)" + @echo "WEBEXTCFLAGS = $(WEBEXTCFLAGS) $(CFLAGS)" + @echo "LDFLAGS = $(LDFLAGS)" .c.o: - $(CC) $(SURFCFLAGS) -c $< + $(CC) $(SURFCFLAGS) $(CFLAGS) -c $< -.c.lo: - $(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $< +config.h: + cp config.def.h $@ $(OBJ): config.h config.mk -$(LIBOBJ): config.h config.mk -config.h: - cp config.def.h $@ +$(WEBEXTOBJ): config.h config.mk + $(CC) $(WEBEXTCFLAGS) $(CFLAGS) -c $(WEBEXTSRC) -libsurf-webext.la: $(LIBOBJ) - $(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \ - $(LIBOBJ) $(LIB) -rpath $(DESTDIR)$(LIBPREFIX) +libsurf-webext.so: $(WEBEXTOBJ) + $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $< $(WEBEXTLIBS) -lc surf: $(OBJ) - $(CC) $(SURFCFLAGS) -o $@ $(OBJ) $(SURFLDFLAGS) + $(CC) $(SURFLDLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) -clean-lib: - rm -rf libsurf-webext.la .libs $(LIBOBJ) $(LIBOBJ:.lo=.o) - -clean: clean-lib +clean: rm -f surf $(OBJ) + rm -f libsurf-webext.so $(WEBEXTOBJ) distclean: clean rm -f config.h surf-$(VERSION).tar.gz @@ -52,32 +46,27 @@ dist: distclean mkdir -p surf-$(VERSION) cp -R LICENSE Makefile config.mk config.def.h README \ surf-open.sh arg.h TODO.md surf.png \ - surf.1 $(SRC) $(LIBSRC) surf-$(VERSION) + surf.1 $(SRC) $(WEBEXTSRC) surf-$(VERSION) tar -cf surf-$(VERSION).tar surf-$(VERSION) gzip surf-$(VERSION).tar rm -rf surf-$(VERSION) -install-lib: libsurf-webext.la - mkdir -p $(DESTDIR)$(LIBPREFIX) - $(LIBTOOL) --mode install install -c libsurf-webext.la \ - $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la - -install: all install-lib +install: all mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f surf $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/surf + mkdir -p $(DESTDIR)$(WEBEXTDIR) + cp -f libsurf-webext.so $(DESTDIR)$(WEBEXTDIR) + chmod 644 $(DESTDIR)$(PREFIX)/bin/surf mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 -uninstall-lib: - $(LIBTOOL) --mode uninstall rm -f \ - $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la - - rm -df $(DESTDIR)$(LIBPREFIX) - -uninstall: uninstall-lib +uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/surf rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 + rm -f $(DESTDIR)$(WEBEXTDIR)/libsurf-webext.so + - rmdir $(DESTDIR)$(WEBEXTDIR) -.SUFFIXES: .la .lo .o .c -.PHONY: all options clean-dist clean dist install-lib install uninstall-lib uninstall +.SUFFIXES: .so .o .c +.PHONY: all options clean-dist clean dist install uninstall diff --git a/config.mk b/config.mk index 8d96b29..2cb1bd4 100644 --- a/config.mk +++ b/config.mk @@ -6,7 +6,8 @@ VERSION = 2.0 # paths PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man -LIBPREFIX = $(PREFIX)/lib/surf +LIBPREFIX = $(PREFIX)/lib +LIBDIR = $(LIBPREFIX)/surf X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib @@ -14,25 +15,17 @@ X11LIB = /usr/X11R6/lib GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0` WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -WEBEXTLIB = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0` +WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0` # includes and libs INCS = -I$(X11INC) $(GTKINC) LIBS = -L$(X11LIB) -lX11 $(GTKLIB) -lgthread-2.0 # flags -CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBPREFIX)\" \ +CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBDIR)\" \ -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -SURFCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) -SURFLDFLAGS = $(LIBS) $(LDFLAGS) -LIBCPPFLAGS = -DWEBEXTDIR=\"$(LIBPREFIX)\" -LIBCFLAGS = $(WEBEXTINC) $(LIBCPPFLAGS) $(CFLAGS) -LIBLDFLAGS = $(WEBEXTLIB) $(LDFLAGS) +SURFCFLAGS = $(INCS) $(CPPFLAGS) +WEBEXTCFLAGS = -fPIC $(WEBEXTINC) -# Solaris -#CFLAGS = -fast $(INCS) -DVERSION=\"$(VERSION)\" -#LDFLAGS = $(LIBS) - -# compiler and linker +# compiler #CC = c99 -LIBTOOL = libtool --quiet -- cgit v1.2.3 From 47e39851ca12749d24c66f948054c42289756ca7 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 8 Oct 2018 14:11:24 +0200 Subject: Fix webext directory in Makefile --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3b601ff..6a4906e 100644 --- a/Makefile +++ b/Makefile @@ -55,9 +55,9 @@ install: all mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f surf $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/surf - mkdir -p $(DESTDIR)$(WEBEXTDIR) - cp -f libsurf-webext.so $(DESTDIR)$(WEBEXTDIR) - chmod 644 $(DESTDIR)$(PREFIX)/bin/surf + mkdir -p $(DESTDIR)$(LIBDIR) + cp -f libsurf-webext.so $(DESTDIR)$(LIBDIR) + chmod 644 $(DESTDIR)$(LIBDIR)/bin/libsurf-webext.so mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 @@ -65,8 +65,8 @@ install: all uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/surf rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 - rm -f $(DESTDIR)$(WEBEXTDIR)/libsurf-webext.so - - rmdir $(DESTDIR)$(WEBEXTDIR) + rm -f $(DESTDIR)$(LIBDIR)/libsurf-webext.so + - rmdir $(DESTDIR)$(LIBDIR) .SUFFIXES: .so .o .c .PHONY: all options clean-dist clean dist install uninstall -- cgit v1.2.3 From 4e7371317c7cb4ed3c4c6bd9b66b45c37018f52f Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 8 Oct 2018 14:23:51 +0200 Subject: Fix, again, webext directory in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6a4906e..10505f3 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ install: all chmod 755 $(DESTDIR)$(PREFIX)/bin/surf mkdir -p $(DESTDIR)$(LIBDIR) cp -f libsurf-webext.so $(DESTDIR)$(LIBDIR) - chmod 644 $(DESTDIR)$(LIBDIR)/bin/libsurf-webext.so + chmod 644 $(DESTDIR)$(LIBDIR)/libsurf-webext.so mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 -- cgit v1.2.3 From 16beb6f8acd5e589be11168ab6c1944c4411052e Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Tue, 9 Oct 2018 12:26:32 +0200 Subject: Makefile: fix dependencies --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 10505f3..cdbd8ad 100644 --- a/Makefile +++ b/Makefile @@ -24,9 +24,9 @@ options: config.h: cp config.def.h $@ -$(OBJ): config.h config.mk +$(OBJ): config.h common.h config.mk -$(WEBEXTOBJ): config.h config.mk +$(WEBEXTOBJ): $(WEBEXTSRC) config.h common.h config.mk $(CC) $(WEBEXTCFLAGS) $(CFLAGS) -c $(WEBEXTSRC) libsurf-webext.so: $(WEBEXTOBJ) -- cgit v1.2.3 From 2b71a22755bae132a639fe10475a0d42e582d244 Mon Sep 17 00:00:00 2001 From: Leonardo Taccari Date: Tue, 9 Oct 2018 21:30:52 +0200 Subject: Use pkg-config for X11{INC,LIB} --- config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.mk b/config.mk index 2cb1bd4..fa22f30 100644 --- a/config.mk +++ b/config.mk @@ -9,8 +9,8 @@ MANPREFIX = $(PREFIX)/share/man LIBPREFIX = $(PREFIX)/lib LIBDIR = $(LIBPREFIX)/surf -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib +X11INC = `pkg-config --cflags x11` +X11LIB = `pkg-config --libs x11` GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0` @@ -18,8 +18,8 @@ WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0` WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0` # includes and libs -INCS = -I$(X11INC) $(GTKINC) -LIBS = -L$(X11LIB) -lX11 $(GTKLIB) -lgthread-2.0 +INCS = $(X11INC) $(GTKINC) +LIBS = $(X11LIB) $(GTKLIB) -lgthread-2.0 # flags CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBDIR)\" \ -- cgit v1.2.3