diff options
Diffstat (limited to 'surf.c')
-rw-r--r-- | surf.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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; } } } |