summaryrefslogtreecommitdiff
path: root/surf.c
diff options
context:
space:
mode:
Diffstat (limited to 'surf.c')
-rw-r--r--surf.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/surf.c b/surf.c
index f8c8dec..43e2021 100644
--- a/surf.c
+++ b/surf.c
@@ -38,7 +38,7 @@
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
-enum { AtomFind, AtomGo, AtomUri, AtomUTF8, AtomLast };
+enum { AtomFind, AtomSearch, AtomGo, AtomUri, AtomUTF8, AtomLast };
enum {
OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
@@ -239,6 +239,7 @@ static void togglefullscreen(Client *c, const Arg *a);
static void togglecookiepolicy(Client *c, const Arg *a);
static void toggleinspector(Client *c, const Arg *a);
static void find(Client *c, const Arg *a);
+static void search(Client *c, const Arg *a);
/* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
@@ -344,6 +345,7 @@ setup(void)
/* atoms */
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
+ atoms[AtomSearch] = XInternAtom(dpy, "_SURF_SEARCH", False);
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
atoms[AtomUTF8] = XInternAtom(dpy, "UTF8_STRING", False);
@@ -602,6 +604,19 @@ loaduri(Client *c, const Arg *a)
g_free(url);
}
+void
+search(Client *c, const Arg *a)
+{
+ Arg arg;
+ char *url;
+
+ url = g_strdup_printf(searchurl, a->v);
+ arg.v = url;
+ loaduri(c, &arg);
+
+ g_free(url);
+}
+
const char *
geturi(Client *c)
{
@@ -1333,6 +1348,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d)
find(c, NULL);
return GDK_FILTER_REMOVE;
+ } else if (ev->atom == atoms[AtomSearch]) {
+ a.v = getatom(c, AtomSearch);
+ search(c, &a);
} else if (ev->atom == atoms[AtomGo]) {
a.v = getatom(c, AtomGo);
loaduri(c, &a);