summaryrefslogtreecommitdiff
path: root/surf.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2019-09-30 11:20:52 +0200
committerKarel Kočí <cynerd@email.cz>2019-09-30 11:20:52 +0200
commite9bbc58fe1b54567738bc2720cd0332feb9ff3e2 (patch)
tree97f483d4912dfa1ad8adf839ba44ea4793c44ef6 /surf.c
parent15facd86d007d6295cd7a03fecfcf5cba14cd59f (diff)
downloadsurf-e9bbc58fe1b54567738bc2720cd0332feb9ff3e2.tar.gz
surf-e9bbc58fe1b54567738bc2720cd0332feb9ff3e2.tar.bz2
surf-e9bbc58fe1b54567738bc2720cd0332feb9ff3e2.zip
Add surf-pass to access user names and passwords from surf
Diffstat (limited to 'surf.c')
-rw-r--r--surf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/surf.c b/surf.c
index f553239..8a1f3d7 100644
--- a/surf.c
+++ b/surf.c
@@ -35,7 +35,7 @@
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
-enum { AtomFind, AtomGo, AtomUri, AtomLast };
+enum { AtomFind, AtomGo, AtomUri, AtomActiveValue, AtomLast };
enum {
OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
@@ -173,6 +173,7 @@ 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 activeval(Client *c, const Arg *a);
static void destroyclient(Client *c);
static void cleanup(void);
@@ -328,6 +329,7 @@ setup(void)
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
+ atoms[AtomActiveValue] = XInternAtom(dpy, "_SURF_ACTIVE_VALUE", False);
gtk_init(NULL, NULL);
@@ -1049,6 +1051,14 @@ spawn(Client *c, const Arg *a)
}
void
+activeval(Client *c, const Arg *a)
+{
+ const char *value = a->v;
+
+ evalscript(c, "document.activeElement.value = '%s';", value);
+}
+
+void
destroyclient(Client *c)
{
Client *p;
@@ -1317,6 +1327,12 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d)
loaduri(c, &a);
return GDK_FILTER_REMOVE;
+ } else if (ev->atom == atoms[AtomActiveValue]) {
+ a.v = getatom(c, AtomActiveValue);
+ if (*(char*)a.v != '\0')
+ activeval(c, &a);
+
+ return GDK_FILTER_REMOVE;
}
}
}