diff options
| author | stkhan <personal@slickd.xyz> | 2022-04-22 22:07:02 -0500 |
|---|---|---|
| committer | stkhan <personal@slickd.xyz> | 2022-04-22 22:07:02 -0500 |
| commit | 2a5251ed90e0d58d95a43308d7dc7a91b50973cd (patch) | |
| tree | 4c79aef7bdccc185e3c81f5940c2dc45c7dcc7c9 /surf/surf.c | |
| parent | 6d5f8c137608df2e459c9865efa19c72856ed6e8 (diff) | |
added search to surf
Diffstat (limited to 'surf/surf.c')
| -rw-r--r-- | surf/surf.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/surf/surf.c b/surf/surf.c index f82ca0f..579d688 100644 --- a/surf/surf.c +++ b/surf/surf.c @@ -37,7 +37,7 @@ #define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) -enum { AtomFind, AtomGo, AtomUri, AtomLast }; +enum { AtomFind, AtomSearch, AtomGo, AtomUri, AtomLast }; enum { OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, @@ -234,6 +234,7 @@ static void togglecookiepolicy(Client *c, const Arg *a); static void toggleinspector(Client *c, const Arg *a); static void toggletitle(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); @@ -338,6 +339,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); @@ -597,6 +599,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) { @@ -1344,6 +1359,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); |