add Modal patch
This commit is contained in:
parent
2819ae6327
commit
83d9d07b96
|
@ -0,0 +1,225 @@
|
|||
/* modifier 0 means no modifier */
|
||||
static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
|
||||
static char *fulluseragent = ""; /* Or override the whole user agent string */
|
||||
static char *scriptfile = "~/.surf/script.js";
|
||||
static char *styledir = "~/.surf/styles/";
|
||||
static char *certdir = "~/.surf/certificates/";
|
||||
static char *cachedir = "~/.surf/cache/";
|
||||
static char *cookiefile = "~/.surf/cookies.txt";
|
||||
static char **plugindirs = (char*[]){
|
||||
"~/.surf/plugins/",
|
||||
LIBPREFIX "/mozilla/plugins/",
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Regular expressions to match URLs that should not be loaded */
|
||||
char *filter_patterns[] = {
|
||||
#include "filters_compiled"
|
||||
};
|
||||
/* Define this for verbose filtering */
|
||||
// #define FILTER_VERBOSE
|
||||
|
||||
/* Webkit default features */
|
||||
/* Highest priority value will be used.
|
||||
* Default parameters are priority 0
|
||||
* Per-uri parameters are priority 1
|
||||
* Command parameters are priority 2
|
||||
*/
|
||||
static Parameter defconfig[ParameterLast] = {
|
||||
/* parameter Arg value priority */
|
||||
[AcceleratedCanvas] = { { .i = 1 }, },
|
||||
[AccessMicrophone] = { { .i = 0 }, },
|
||||
[AccessWebcam] = { { .i = 0 }, },
|
||||
[Certificate] = { { .i = 0 }, },
|
||||
[CaretBrowsing] = { { .i = 0 }, },
|
||||
[CookiePolicies] = { { .v = "@Aa" }, },
|
||||
[DefaultCharset] = { { .v = "UTF-8" }, },
|
||||
[DiskCache] = { { .i = 1 }, },
|
||||
[DNSPrefetch] = { { .i = 0 }, },
|
||||
[Ephemeral] = { { .i = 0 }, },
|
||||
[FileURLsCrossAccess] = { { .i = 0 }, },
|
||||
[FontSize] = { { .i = 12 }, },
|
||||
[FrameFlattening] = { { .i = 0 }, },
|
||||
[Geolocation] = { { .i = 0 }, },
|
||||
[HideBackground] = { { .i = 0 }, },
|
||||
[Inspector] = { { .i = 0 }, },
|
||||
[Java] = { { .i = 1 }, },
|
||||
[JavaScript] = { { .i = 1 }, },
|
||||
[KioskMode] = { { .i = 0 }, },
|
||||
[LoadImages] = { { .i = 1 }, },
|
||||
[MediaManualPlay] = { { .i = 1 }, },
|
||||
[Plugins] = { { .i = 1 }, },
|
||||
[PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
|
||||
[RunInFullscreen] = { { .i = 0 }, },
|
||||
[ScrollBars] = { { .i = 1 }, },
|
||||
[ShowIndicators] = { { .i = 1 }, },
|
||||
[SiteQuirks] = { { .i = 1 }, },
|
||||
[SmoothScrolling] = { { .i = 0 }, },
|
||||
[SpellChecking] = { { .i = 0 }, },
|
||||
[SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, },
|
||||
[StrictTLS] = { { .i = 1 }, },
|
||||
[Style] = { { .i = 1 }, },
|
||||
[WebGL] = { { .i = 0 }, },
|
||||
[ZoomLevel] = { { .f = 1.0 }, },
|
||||
};
|
||||
|
||||
static UriParameters uriparams[] = {
|
||||
{ "(://|\\.)suckless\\.org(/|$)", {
|
||||
[JavaScript] = { { .i = 0 }, 1 },
|
||||
[Plugins] = { { .i = 0 }, 1 },
|
||||
}, },
|
||||
};
|
||||
|
||||
/* default window size: width, height */
|
||||
static int winsize[] = { 800, 600 };
|
||||
|
||||
static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
||||
WEBKIT_FIND_OPTIONS_WRAP_AROUND;
|
||||
|
||||
#define PROMPT_GO "Go:"
|
||||
#define PROMPT_FIND "Find:"
|
||||
|
||||
/* SETPROP(readprop, setprop, prompt)*/
|
||||
#define SETPROP(r, s, p) { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
|
||||
"| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
|
||||
"| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
/* DOWNLOAD(URI, referer) */
|
||||
#define DOWNLOAD(u, r) { \
|
||||
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
|
||||
"curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
|
||||
" -e \"$3\" \"$4\"; read", \
|
||||
"surf-download", useragent, cookiefile, r, u, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
/* PLUMB(URI) */
|
||||
/* This called when some URI which does not begin with "about:",
|
||||
* "http://" or "https://" should be opened.
|
||||
*/
|
||||
#define PLUMB(u) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"xdg-open \"$0\"", u, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
/* VIDEOPLAY(URI) */
|
||||
#define VIDEOPLAY(u) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"mpv --really-quiet \"$0\"", u, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BM_ADD(r) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"surf-add $(xprop -id $0 $1) ",\
|
||||
winid, r, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BOOKMASK(r, s, p) { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"xprop -id $1 -f $3 8s -set $3 \"$(surf-bookmark $1)\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
/* VIDEOPLAY(URI) */
|
||||
#define DEL(r) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"surf-del $1", \
|
||||
"surf-setprop", winid, r, NULL, NULL, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
/* styles */
|
||||
/*
|
||||
* The iteration will stop at the first match, beginning at the beginning of
|
||||
* the list.
|
||||
*/
|
||||
static SiteSpecific styles[] = {
|
||||
/* regexp file in $styledir */
|
||||
{ ".*", "default.css" },
|
||||
};
|
||||
|
||||
/* certificates */
|
||||
/*
|
||||
* Provide custom certificate for urls
|
||||
*/
|
||||
static SiteSpecific certs[] = {
|
||||
/* regexp file in $certdir */
|
||||
{ "://suckless\\.org/", "suckless.org.crt" },
|
||||
};
|
||||
|
||||
#define URL(r, s, p) { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"xprop -id $1 -f $3 8s -set $3 \"$(surf-search $1)\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MODKEY GDK_CONTROL_MASK
|
||||
|
||||
/* hotkeys */
|
||||
/*
|
||||
* If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
|
||||
* edit the CLEANMASK() macro.
|
||||
*/
|
||||
static Key keys[] = {
|
||||
/* modifier keyval function arg */
|
||||
{ MODKEY, GDK_KEY_g, spawn, URL("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
{ MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ MODKEY, GDK_KEY_D, spawn, BOOKMASK("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
{ MODKEY|GDK_SHIFT_MASK, D, spawn, BM_ADD("_SURF_URI") },
|
||||
{ 0, GDK_KEY_F3, spawn, DEL("_SURF_URI") },
|
||||
|
||||
{ MODKEY, GDK_KEY_c, stop, { 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_r, reload, { .i = 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
|
||||
/* vertical and horizontal scrolling, in viewport percentage */
|
||||
{ MODKEY, GDK_KEY_k, scrollv, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_j, scrollv, { .i = -10 } },
|
||||
{ MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
{ MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
{ MODKEY, GDK_KEY_h, scrollh, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_l, scrollh, { .i = -10 } },
|
||||
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
{ MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
{ MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_c, clipboard, { .i = 1 } },
|
||||
{ MODKEY, GDK_KEY_v, clipboard, { .i = 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, find, { .i = -1 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
|
||||
|
||||
{ 0, GDK_KEY_F11, togglefullscreen, { 0 } },
|
||||
{ 0, GDK_KEY_F12, toggleinspector, { 0 } },
|
||||
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
|
||||
static Button buttons[] = {
|
||||
/* target event mask button function argument stop event */
|
||||
{ OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
|
||||
{ OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
|
||||
{ OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
|
||||
{ OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
|
||||
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
|
||||
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
|
||||
};
|
52
config.def.h
52
config.def.h
|
@ -143,41 +143,43 @@ static SiteSpecific certs[] = {
|
|||
*/
|
||||
static Key keys[] = {
|
||||
/* modifier keyval function arg */
|
||||
{ MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
{ MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ 0, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
|
||||
{ 0, GDK_KEY_Escape, stop, { 0 } },
|
||||
{ MODKEY, GDK_KEY_c, stop, { 0 } },
|
||||
{ 0, GDK_KEY_i, insert, { .i = 1 } },
|
||||
{ 0, GDK_KEY_Escape, insert, { .i = 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
|
||||
{ MODKEY, GDK_KEY_r, reload, { .i = 0 } },
|
||||
{ 0, GDK_KEY_c, stop, { 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
{ MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
{ MODKEY, GDK_KEY_r, reload, { .i = 1 } },
|
||||
{ 0, GDK_KEY_r, reload, { .i = 0 } },
|
||||
|
||||
{ 0, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
{ 0, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
|
||||
/* vertical and horizontal scrolling, in viewport percentage */
|
||||
{ MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
|
||||
{ MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
{ MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
{ MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
|
||||
{ 0, GDK_KEY_j, scrollv, { .i = +10 } },
|
||||
{ 0, GDK_KEY_k, scrollv, { .i = -10 } },
|
||||
{ 0, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
{ 0, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
{ 0, GDK_KEY_i, scrollh, { .i = +10 } },
|
||||
{ 0, GDK_KEY_u, scrollh, { .i = -10 } },
|
||||
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
{ MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
{ MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
{ 0, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
{ 0, GDK_KEY_equal, zoom, { .i = 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
{ MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
{ 0, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
{ 0, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_n, find, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
{ 0, GDK_KEY_n, find, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
|
||||
|
|
|
@ -12,6 +12,13 @@ static char **plugindirs = (char*[]){
|
|||
NULL
|
||||
};
|
||||
|
||||
/* Regular expressions to match URLs that should not be loaded */
|
||||
char *filter_patterns[] = {
|
||||
#include "filters_compiled"
|
||||
};
|
||||
/* Define this for verbose filtering */
|
||||
// #define FILTER_VERBOSE
|
||||
|
||||
/* Webkit default features */
|
||||
/* Highest priority value will be used.
|
||||
* Default parameters are priority 0
|
||||
|
|
51
config.h
51
config.h
|
@ -172,43 +172,45 @@ static SiteSpecific certs[] = {
|
|||
static Key keys[] = {
|
||||
/* modifier keyval function arg */
|
||||
{ MODKEY, GDK_KEY_g, spawn, URL("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
{ MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
{ MODKEY, GDK_KEY_q, spawn, BOOKMASK("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
{ 0, GDK_KEY_F2, spawn, BM_ADD("_SURF_URI") },
|
||||
{ 0, GDK_KEY_F3, spawn, DEL("_SURF_URI") },
|
||||
{ 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
|
||||
{ 0, GDK_KEY_Escape, stop, { 0 } },
|
||||
{ MODKEY, GDK_KEY_c, stop, { 0 } },
|
||||
{ 0, GDK_KEY_i, insert, { .i = 1 } },
|
||||
{ 0, GDK_KEY_Escape, insert, { .i = 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
|
||||
{ MODKEY, GDK_KEY_r, reload, { .i = 0 } },
|
||||
{ 0, GDK_KEY_c, stop, { 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
{ MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
{ MODKEY, GDK_KEY_r, reload, { .i = 1 } },
|
||||
{ 0, GDK_KEY_r, reload, { .i = 0 } },
|
||||
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
|
||||
/* vertical and horizontal scrolling, in viewport percentage */
|
||||
{ MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
|
||||
{ MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
{ MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
{ MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
|
||||
{ MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
|
||||
{ 0, GDK_KEY_j, scrollv, { .i = -10 } },
|
||||
{ 0, GDK_KEY_k, scrollv, { .i = +10 } },
|
||||
{ 0, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
{ 0, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
{ 0, GDK_KEY_h, scrollh, { .i = +10 } },
|
||||
{ 0, GDK_KEY_l, scrollh, { .i = -10 } },
|
||||
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
{ MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
{ MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
{ 0, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
{ 0, GDK_KEY_equal, zoom, { .i = 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
{ MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
{ 0, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
{ 0, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
|
||||
{ MODKEY, GDK_KEY_n, find, { .i = +1 } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
{ 0, GDK_KEY_n, find, { .i = +1 } },
|
||||
{ 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
|
||||
|
@ -224,6 +226,7 @@ static Key keys[] = {
|
|||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
|
||||
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
From 74a98d9600c50d50b9323cf8e459c88eb15da557 Mon Sep 17 00:00:00 2001
|
||||
From: efe <efe@efe.kim>
|
||||
Date: Sat, 9 Feb 2019 13:16:51 -0500
|
||||
Subject: [PATCH] Modal behaviour, 'i' to insert 'Esc' to get to the normal
|
||||
mode
|
||||
|
||||
---
|
||||
config.def.h | 53 +++++++++++++++++++++++++++-------------------------
|
||||
surf.c | 14 +++++++++++++-
|
||||
2 files changed, 41 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 34265f6..8b7d5a2 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -130,41 +130,44 @@ static SiteSpecific certs[] = {
|
||||
*/
|
||||
static Key keys[] = {
|
||||
/* modifier keyval function arg */
|
||||
- { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
- { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
- { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
+ { 0, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
|
||||
+ { 0, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
+ { 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
|
||||
|
||||
- { 0, GDK_KEY_Escape, stop, { 0 } },
|
||||
- { MODKEY, GDK_KEY_c, stop, { 0 } },
|
||||
+ { 0, GDK_KEY_i, insert, { .i = 1 } },
|
||||
+ { 0, GDK_KEY_Escape, insert, { .i = 0 } },
|
||||
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
|
||||
- { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
|
||||
+ { 0, GDK_KEY_c, stop, { 0 } },
|
||||
|
||||
- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
+ { MODKEY, GDK_KEY_r, reload, { .i = 1 } },
|
||||
+ { 0, GDK_KEY_r, reload, { .i = 0 } },
|
||||
+
|
||||
+ { 0, GDK_KEY_l, navigate, { .i = +1 } },
|
||||
+ { 0, GDK_KEY_h, navigate, { .i = -1 } },
|
||||
|
||||
/* vertical and horizontal scrolling, in viewport percentage */
|
||||
- { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
|
||||
- { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
|
||||
- { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
- { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
- { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
|
||||
- { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
|
||||
+ { 0, GDK_KEY_j, scrollv, { .i = +10 } },
|
||||
+ { 0, GDK_KEY_k, scrollv, { .i = -10 } },
|
||||
+ { 0, GDK_KEY_space, scrollv, { .i = +50 } },
|
||||
+ { 0, GDK_KEY_b, scrollv, { .i = -50 } },
|
||||
+ { 0, GDK_KEY_i, scrollh, { .i = +10 } },
|
||||
+ { 0, GDK_KEY_u, scrollh, { .i = -10 } },
|
||||
|
||||
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
- { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
- { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
|
||||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
|
||||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
|
||||
+ { 0, GDK_KEY_minus, zoom, { .i = -1 } },
|
||||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } },
|
||||
+ { 0, GDK_KEY_equal, zoom, { .i = 0 } },
|
||||
|
||||
- { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
- { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
+ { 0, GDK_KEY_p, clipboard, { .i = 1 } },
|
||||
+ { 0, GDK_KEY_y, clipboard, { .i = 0 } },
|
||||
|
||||
- { MODKEY, GDK_KEY_n, find, { .i = +1 } },
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
+ { 0, GDK_KEY_n, find, { .i = +1 } },
|
||||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
|
||||
|
||||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
|
||||
+ { MODKEY, GDK_KEY_p, print, { 0 } },
|
||||
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
|
||||
|
||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
|
||||
diff --git a/surf.c b/surf.c
|
||||
index 2b54e3c..f4cbe68 100644
|
||||
--- a/surf.c
|
||||
+++ b/surf.c
|
||||
@@ -175,6 +175,7 @@ static void spawn(Client *c, const Arg *a);
|
||||
static void msgext(Client *c, char type, const Arg *a);
|
||||
static void destroyclient(Client *c);
|
||||
static void cleanup(void);
|
||||
+static int insertmode = 0;
|
||||
|
||||
/* GTK/WebKit */
|
||||
static WebKitWebView *newview(Client *c, WebKitWebView *rv);
|
||||
@@ -231,6 +232,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 insert(Client *c, const Arg *a);
|
||||
|
||||
/* Buttons */
|
||||
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
|
||||
@@ -1333,7 +1335,11 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
|
||||
updatetitle(c);
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
- if (!curconfig[KioskMode].val.i) {
|
||||
+ if (!curconfig[KioskMode].val.i &&
|
||||
+ !insertmode ||
|
||||
+ CLEANMASK(e->key.state) == (MODKEY|GDK_SHIFT_MASK) ||
|
||||
+ CLEANMASK(e->key.state) == (MODKEY) ||
|
||||
+ gdk_keyval_to_lower(e->key.keyval) == (GDK_KEY_Escape)) {
|
||||
for (i = 0; i < LENGTH(keys); ++i) {
|
||||
if (gdk_keyval_to_lower(e->key.keyval) ==
|
||||
keys[i].keyval &&
|
||||
@@ -1947,6 +1953,12 @@ find(Client *c, const Arg *a)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+insert(Client *c, const Arg *a)
|
||||
+{
|
||||
+ insertmode = (a->i);
|
||||
+}
|
||||
+
|
||||
void
|
||||
clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h)
|
||||
{
|
||||
--
|
||||
2.20.1
|
||||
|
14
surf.c
14
surf.c
|
@ -238,6 +238,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 insert(Client *c, const Arg *a);
|
||||
|
||||
/* Buttons */
|
||||
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
|
||||
|
@ -258,6 +259,7 @@ static char *stylefile;
|
|||
static const char *useragent;
|
||||
static Parameter *curconfig;
|
||||
static int modparams[ParameterLast];
|
||||
static int insertmode = 0;
|
||||
static int spair[2];
|
||||
char *argv0;
|
||||
regex_t *filter_expressions;
|
||||
|
@ -1364,7 +1366,11 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
|
|||
updatetitle(c);
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
if (!curconfig[KioskMode].val.i) {
|
||||
if (!curconfig[KioskMode].val.i &&
|
||||
!insertmode ||
|
||||
CLEANMASK(e->key.state) == (MODKEY|GDK_SHIFT_MASK) ||
|
||||
CLEANMASK(e->key.state) == (MODKEY) ||
|
||||
gdk_keyval_to_lower(e->key.keyval) == (GDK_KEY_Escape)) {
|
||||
for (i = 0; i < LENGTH(keys); ++i) {
|
||||
if (gdk_keyval_to_lower(e->key.keyval) ==
|
||||
keys[i].keyval &&
|
||||
|
@ -2030,6 +2036,12 @@ find(Client *c, const Arg *a)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
insert(Client *c, const Arg *a)
|
||||
{
|
||||
insertmode = (a->i);
|
||||
}
|
||||
|
||||
void
|
||||
clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h)
|
||||
{
|
||||
|
|
53
surf.c.orig
53
surf.c.orig
|
@ -17,6 +17,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
@ -179,6 +180,8 @@ static void spawn(Client *c, const Arg *a);
|
|||
static void msgext(Client *c, char type, const Arg *a);
|
||||
static void destroyclient(Client *c);
|
||||
static void cleanup(void);
|
||||
static bool filter_init(void);
|
||||
static bool filter_request(const gchar *uri);
|
||||
|
||||
/* GTK/WebKit */
|
||||
static WebKitWebView *newview(Client *c, WebKitWebView *rv);
|
||||
|
@ -257,6 +260,7 @@ static Parameter *curconfig;
|
|||
static int modparams[ParameterLast];
|
||||
static int spair[2];
|
||||
char *argv0;
|
||||
regex_t *filter_expressions;
|
||||
|
||||
static ParamName loadtransient[] = {
|
||||
Certificate,
|
||||
|
@ -1711,7 +1715,7 @@ decideresource(WebKitPolicyDecision *d, Client *c)
|
|||
webkit_response_policy_decision_get_response(r);
|
||||
const gchar *uri = webkit_uri_response_get_uri(res);
|
||||
|
||||
if (g_str_has_suffix(uri, "/favicon.ico")) {
|
||||
if(filter_request(uri)){
|
||||
webkit_policy_decision_ignore(d);
|
||||
return;
|
||||
}
|
||||
|
@ -1871,6 +1875,49 @@ zoom(Client *c, const Arg *a)
|
|||
curconfig[ZoomLevel].val.f = webkit_web_view_get_zoom_level(c->view);
|
||||
}
|
||||
|
||||
static bool
|
||||
filter_init(void) {
|
||||
bool errors = false;
|
||||
char *errorbuf;
|
||||
|
||||
errorbuf = malloc(sizeof(char) * BUFSIZ);
|
||||
filter_expressions = malloc(sizeof(regex_t) * LENGTH(filter_patterns));
|
||||
|
||||
for (off_t idx = 0; idx < LENGTH(filter_patterns); idx++) {
|
||||
char *pat = filter_patterns[idx];
|
||||
int err = regcomp(&filter_expressions[idx], pat,
|
||||
REG_EXTENDED | REG_ICASE | REG_NOSUB);
|
||||
if (err != 0) {
|
||||
/* regerror always ends messages with 0x00 */
|
||||
(void) regerror(err, &filter_expressions[idx], errorbuf, BUFSIZ);
|
||||
fprintf(stderr, "Failed to compile \"%s\": %s\n", pat, errorbuf);
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
|
||||
free(errorbuf);
|
||||
return !errors;
|
||||
}
|
||||
|
||||
static bool
|
||||
filter_request(const gchar *uri) {
|
||||
if (!strcmp(uri, "about:blank"))
|
||||
return false;
|
||||
for (off_t idx = 0; idx < LENGTH(filter_patterns); idx++) {
|
||||
if (regexec(&filter_expressions[idx], uri, 0, NULL, 0) == REG_NOMATCH) {
|
||||
continue;
|
||||
}
|
||||
#ifdef FILTER_VERBOSE
|
||||
fprintf(stderr, "filtering \"%s\"\n", uri);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#ifdef FILTER_VERBOSE
|
||||
fprintf(stderr, "not filtering \"%s\"\n", uri);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
msgext(Client *c, char type, const Arg *a)
|
||||
{
|
||||
|
@ -1977,6 +2024,10 @@ find(Client *c, const Arg *a)
|
|||
if (strcmp(s, "") == 0)
|
||||
webkit_find_controller_search_finish(c->finder);
|
||||
}
|
||||
|
||||
if (!filter_init()) {
|
||||
die("Failed to compile one or more filter expressions\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
32
surf.c.rej
32
surf.c.rej
|
@ -1,28 +1,10 @@
|
|||
--- surf.c
|
||||
+++ surf.c
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <webkit/webkit.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <JavaScriptCore/JavaScript.h>
|
||||
+#include <regex.h>
|
||||
#include <sys/file.h>
|
||||
#include <libgen.h>
|
||||
#include <stdarg.h>
|
||||
@@ -120,6 +122,8 @@ static void destroyclient(Client *c);
|
||||
static void destroywin(GtkWidget* w, Client *c);
|
||||
static void die(const char *errstr, ...);
|
||||
static void eval(Client *c, const Arg *arg);
|
||||
+static bool filter_init(void);
|
||||
+static bool filter_request(const gchar *uri);
|
||||
static void find(Client *c, const Arg *arg);
|
||||
static void fullscreen(Client *c, const Arg *arg);
|
||||
static void geopolicyrequested(WebKitWebView *v, WebKitWebFrame *f,
|
||||
@@ -201,7 +205,7 @@ beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
|
||||
gpointer d) {
|
||||
const gchar *uri = webkit_network_request_get_uri(req);
|
||||
|
||||
- if(g_str_has_suffix(uri, "/favicon.ico"))
|
||||
+ if(filter_request(uri))
|
||||
webkit_network_request_set_uri(req, "about:blank");
|
||||
}
|
||||
@@ -175,6 +175,7 @@ static void spawn(Client *c, const Arg *a);
|
||||
static void msgext(Client *c, char type, const Arg *a);
|
||||
static void destroyclient(Client *c);
|
||||
static void cleanup(void);
|
||||
+static int insertmode = 0;
|
||||
|
||||
/* GTK/WebKit */
|
||||
static WebKitWebView *newview(Client *c, WebKitWebView *rv);
|
||||
|
|
Loading…
Reference in New Issue