sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

surf-2.0-notifications.diff (3032B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 6d3135e..2b3a14f 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -22,6 +22,7 @@ static Parameter defconfig[ParameterLast] = {
      6  	SETB(KioskMode,          0),
      7  	SETB(LoadImages,         1),
      8  	SETB(MediaManualPlay,    0),
      9 +	SETB(Notifications,      0),
     10  	SETB(Plugins,            1),
     11  	SETV(PreferredLanguages, ((char *[]){ NULL })),
     12  	SETB(RunInFullscreen,    0),
     13 @@ -148,6 +149,7 @@ static Key keys[] = {
     14  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
     15  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
     16  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
     17 +	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_l,      toggle,     { .i = Notifications } },
     18  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_v,      toggle,     { .i = Plugins } },
     19  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      toggle,     { .i = ScrollBars } },
     20  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
     21 diff --git a/surf.c b/surf.c
     22 index 93a1629..d47dc60 100644
     23 --- a/surf.c
     24 +++ b/surf.c
     25 @@ -72,6 +72,7 @@ typedef enum {
     26  	KioskMode,
     27  	LoadImages,
     28  	MediaManualPlay,
     29 +	Notifications,
     30  	Plugins,
     31  	PreferredLanguages,
     32  	RunInFullscreen,
     33 @@ -568,7 +569,8 @@ gettogglestats(Client *c)
     34  	togglestats[6] = curconfig[Plugins].val.b ?         'V' : 'v';
     35  	togglestats[7] = curconfig[Style].val.b ?           'M' : 'm';
     36  	togglestats[8] = curconfig[FrameFlattening].val.b ? 'F' : 'f';
     37 -	togglestats[9] = '\0';
     38 +	togglestats[9] = curconfig[Notifications].val.b ?   'L' : 'l';
     39 +	togglestats[10] = '\0';
     40  }
     41  
     42  void
     43 @@ -681,6 +683,9 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
     44  	case MediaManualPlay:
     45  		webkit_settings_set_media_playback_requires_user_gesture(s, a->b);
     46  		break;
     47 +	case Notifications:
     48 +		refresh = 0;
     49 +		return;
     50  	case Plugins:
     51  		webkit_settings_set_enable_plugins(s, a->b);
     52  		break;
     53 @@ -834,6 +839,7 @@ newwindow(Client *c, const Arg *a, int noembed)
     54  	cmd[i++] = curconfig[Geolocation].val.b ?     "-G" : "-g" ;
     55  	cmd[i++] = curconfig[LoadImages].val.b ?      "-I" : "-i" ;
     56  	cmd[i++] = curconfig[KioskMode].val.b ?       "-K" : "-k" ;
     57 +	cmd[i++] = curconfig[Notifications].val.b ?   "-L" : "-l" ;
     58  	cmd[i++] = curconfig[Style].val.b ?           "-M" : "-m" ;
     59  	cmd[i++] = curconfig[Inspector].val.b ?       "-N" : "-n" ;
     60  	cmd[i++] = curconfig[Plugins].val.b ?         "-P" : "-p" ;
     61 @@ -1301,6 +1307,14 @@ permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c)
     62  		return TRUE;
     63  	}
     64  
     65 +	if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(r)) {
     66 +		if (curconfig[Notifications].val.b)
     67 +			webkit_permission_request_allow(r);
     68 +		else
     69 +			webkit_permission_request_deny(r);
     70 +		return TRUE;
     71 +	}
     72 +
     73  	return FALSE;
     74  }
     75  
     76 @@ -1703,6 +1717,12 @@ main(int argc, char *argv[])
     77  	case 'K':
     78  		defconfig CSETB(KioskMode, 1);
     79  		break;
     80 +	case 'l':
     81 +		defconfig CSETB(Notifications, 0);
     82 +		break;
     83 +	case 'L':
     84 +		defconfig CSETB(Notifications, 1);
     85 +		break;
     86  	case 'm':
     87  		defconfig CSETB(Style, 0);
     88  		break;