--- config.def.h | 2 ++ surf.1 | 9 +++++++++ surf.c | 44 ++++++++++++++++++++++++++++---------------- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/config.def.h b/config.def.h index 4f6d655..5d94b40 100644 --- a/config.def.h +++ b/config.def.h _AT_@ -34,6 +34,7 @@ static int enablestyle = 1; static int loadimages = 1; static int hidebackground = 0; static int allowgeolocation = 1; +static int allownotifications = 1; static int enablednsprefetching = 0; static int enableframeflattening = 0; _AT_@ -139,6 +140,7 @@ static Key keys[] = { { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, + { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = Notifications } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } }, diff --git a/surf.1 b/surf.1 index 867783d..0cde5b7 100644 --- a/surf.1 +++ b/surf.1 _AT_@ -62,6 +62,12 @@ Disable giving the geolocation to websites. .B \-G Enable giving the geolocation to websites. .TP +.B \-t +Disable websites from showing desktop notifications +.TP +.B \-T +Enable websites to show desktop notifications +.TP .B \-i Disable Images .TP _AT_@ -242,6 +248,9 @@ caret browsing .B g G geolocation .TP +.B t T +notifications +.TP .B d D disk cache .TP diff --git a/surf.c b/surf.c index 9b4dbb9..a0da974 100644 --- a/surf.c +++ b/surf.c _AT_@ -38,6 +38,7 @@ enum { CaretBrowsing, FrameFlattening, Geolocation, + Notifications, JavaScript, LoadImages, Plugins, _AT_@ -177,7 +178,7 @@ static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h); static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h); static char winid[64]; -static char togglestats[10]; +static char togglestats[11]; static char pagestats[2]; static Atom atoms[AtomLast]; static Window embed; _AT_@ -441,13 +442,14 @@ gettogglestats(Client *c) togglestats[0] = cookiepolicy_set(cookiepolicy_get()); togglestats[1] = enablecaretbrowsing ? 'C' : 'c'; togglestats[2] = allowgeolocation ? 'G' : 'g'; - togglestats[3] = enablecache ? 'D' : 'd'; - togglestats[4] = loadimages ? 'I' : 'i'; - togglestats[5] = enablescripts ? 'S' : 's'; - togglestats[6] = enableplugins ? 'V' : 'v'; - togglestats[7] = enablestyle ? 'M' : 'm'; - togglestats[8] = enableframeflattening ? 'F' : 'f'; - togglestats[9] = '\0'; + togglestats[3] = allownotifications ? 'T' : 't'; + togglestats[4] = enablecache ? 'D' : 'd'; + togglestats[5] = loadimages ? 'I' : 'i'; + togglestats[6] = enablescripts ? 'S' : 's'; + togglestats[7] = enableplugins ? 'V' : 'v'; + togglestats[8] = enablestyle ? 'M' : 'm'; + togglestats[9] = enableframeflattening ? 'F' : 'f'; + togglestats[10] = '\0'; } void _AT_@ -587,6 +589,7 @@ newwindow(Client *c, const Arg *a, int noembed) } cmd[i++] = runinfullscreen ? "-F" : "-f"; cmd[i++] = allowgeolocation ? "-G" : "-g"; + cmd[i++] = allownotifications ? "-t" : "-T"; cmd[i++] = loadimages ? "-I" : "-i"; cmd[i++] = kioskmode ? "-K" : "-k"; cmd[i++] = enablestyle ? "-M" : "-m"; _AT_@ -1037,15 +1040,21 @@ mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers, gboolean permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c) { - if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) { - if (allowgeolocation) - webkit_permission_request_allow(r); - else - webkit_permission_request_deny(r); - return TRUE; - } + int allow; - return FALSE; + if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) + allow = allowgeolocation; + else if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(r)) + allow = allownotifications; + else + return FALSE; + + if (allow) + webkit_permission_request_allow(r); + else + webkit_permission_request_deny(r); + + return TRUE; } gboolean _AT_@ -1306,6 +1315,9 @@ toggle(Client *c, const Arg *a) case Geolocation: allowgeolocation = !allowgeolocation; break; + case Notifications: + allownotifications = !allownotifications; + break; case JavaScript: enablescripts = !enablescripts; webkit_settings_set_enable_javascript(s, enablescripts); -- 2.7.0.rc3Received on Wed Jan 20 2016 - 07:41:45 CET
This archive was generated by hypermail 2.3.0 : Wed Jan 20 2016 - 07:48:26 CET