Support relative paths for surf.

Thanks Kurt Van Dijck <kurt.van.dijck@eia.be>!
This commit is contained in:
Christoph Lohmann 2013-03-14 19:14:44 +01:00
parent d02f73d990
commit a69c41ccac

8
surf.c
View file

@ -577,12 +577,13 @@ loaduri(Client *c, const Arg *arg) {
char *u, *rp; char *u, *rp;
const char *uri = (char *)arg->v; const char *uri = (char *)arg->v;
Arg a = { .b = FALSE }; Arg a = { .b = FALSE };
struct stat st;
if(strcmp(uri, "") == 0) if(strcmp(uri, "") == 0)
return; return;
/* In case it's a file path. */ /* In case it's a file path. */
if(uri[0] == '/') { if(stat(uri, &st) == 0) {
rp = realpath(uri, NULL); rp = realpath(uri, NULL);
u = g_strdup_printf("file://%s", rp); u = g_strdup_printf("file://%s", rp);
free(rp); free(rp);
@ -889,11 +890,12 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
if(ev->atom == atoms[AtomFind]) { if(ev->atom == atoms[AtomFind]) {
arg.b = TRUE; arg.b = TRUE;
find(c, &arg); find(c, &arg);
return GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
} } else if(ev->atom == atoms[AtomGo]) {
else if(ev->atom == atoms[AtomGo]) {
arg.v = getatom(c, AtomGo); arg.v = getatom(c, AtomGo);
loaduri(c, &arg); loaduri(c, &arg);
return GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
} }
} }