disable/toggle scrollbars
* add flag to main * add flag to manual * add signal handler to block default scrollbar policy * add toggle of scrollbars (hacky - but no reload) with a twitch * add key map to manual * add commandline flag to children surfers * update TODO * sort stuff alphabetically for the style inquisition Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
69004b2ff6
commit
fe3bd631d4
2
TODO.md
2
TODO.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* suckless adblocking
|
* suckless adblocking
|
||||||
* integrate the WebKitWebInspector API
|
* integrate the WebKitWebInspector API
|
||||||
* make scrollbars a switch and allow them to be disabled
|
* replace twitch() with proper gtk calls to make scrollbars reappear
|
||||||
* replace webkit with something sane
|
* replace webkit with something sane
|
||||||
* add video player options
|
* add video player options
|
||||||
* play in plugin
|
* play in plugin
|
||||||
|
|
|
@ -10,6 +10,7 @@ static char *cafile = "/etc/ssl/certs/ca-certificates.crt";
|
||||||
static char *strictssl = FALSE; /* Refuse untrusted SSL connections */
|
static char *strictssl = FALSE; /* Refuse untrusted SSL connections */
|
||||||
|
|
||||||
/* Webkit default features */
|
/* Webkit default features */
|
||||||
|
static Bool enablescrollbars = TRUE;
|
||||||
static Bool enablespatialbrowsing = TRUE;
|
static Bool enablespatialbrowsing = TRUE;
|
||||||
static Bool enableplugins = TRUE;
|
static Bool enableplugins = TRUE;
|
||||||
static Bool enablescripts = TRUE;
|
static Bool enablescripts = TRUE;
|
||||||
|
@ -84,5 +85,6 @@ static Key keys[] = {
|
||||||
{ MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } },
|
{ MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } },
|
||||||
{ MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } },
|
{ MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } },
|
||||||
{ MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle,{ 0 } },
|
{ MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle,{ 0 } },
|
||||||
|
{ MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars,{ 0 } },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
12
surf.1
12
surf.1
|
@ -3,7 +3,7 @@
|
||||||
surf \- simple webkit-based browser
|
surf \- simple webkit-based browser
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B surf
|
.B surf
|
||||||
.RB [-ipnsvx]
|
.RB [-bipnsvx]
|
||||||
.RB [-c\ cookiefile]
|
.RB [-c\ cookiefile]
|
||||||
.RB [-e\ xid]
|
.RB [-e\ xid]
|
||||||
.RB [-r\ scriptfile]
|
.RB [-r\ scriptfile]
|
||||||
|
@ -17,6 +17,9 @@ which makes it possible to embed it in another application. Furthermore,
|
||||||
one can point surf to another URI by setting its XProperties.
|
one can point surf to another URI by setting its XProperties.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
.B \-b
|
||||||
|
Disable Scrollbars
|
||||||
|
.TP
|
||||||
.B \-c cookiefile
|
.B \-c cookiefile
|
||||||
Specify the
|
Specify the
|
||||||
.I cookiefile
|
.I cookiefile
|
||||||
|
@ -127,8 +130,8 @@ Copies current URI to primary selection.
|
||||||
.B Ctrl\-o
|
.B Ctrl\-o
|
||||||
Show the sourcecode of the current page.
|
Show the sourcecode of the current page.
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl\-Shift\-o
|
.B Ctrl\-Shift\-b
|
||||||
Open the Web Inspector (Developer Tools) window for the current page.
|
Toggle scrollbars
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl\-Shift\-c
|
.B Ctrl\-Shift\-c
|
||||||
Toggle caret browsing.
|
Toggle caret browsing.
|
||||||
|
@ -141,6 +144,9 @@ Toggle if the
|
||||||
.I stylefile
|
.I stylefile
|
||||||
file should be loaded.
|
file should be loaded.
|
||||||
.TP
|
.TP
|
||||||
|
.B Ctrl\-Shift\-o
|
||||||
|
Open the Web Inspector (Developer Tools) window for the current page.
|
||||||
|
.TP
|
||||||
.B Ctrl\-Shift\-s
|
.B Ctrl\-Shift\-s
|
||||||
Toggle script execution.
|
Toggle script execution.
|
||||||
.TP
|
.TP
|
||||||
|
|
79
surf.c
79
surf.c
|
@ -153,6 +153,7 @@ static void stop(Client *c, const Arg *arg);
|
||||||
static void titlechange(WebKitWebView *v, WebKitWebFrame *frame,
|
static void titlechange(WebKitWebView *v, WebKitWebFrame *frame,
|
||||||
const char *title, Client *c);
|
const char *title, Client *c);
|
||||||
static void toggle(Client *c, const Arg *arg);
|
static void toggle(Client *c, const Arg *arg);
|
||||||
|
static void togglescrollbars(Client *c, const Arg *arg);
|
||||||
static void togglestyle(Client *c, const Arg *arg);
|
static void togglestyle(Client *c, const Arg *arg);
|
||||||
static void update(Client *c);
|
static void update(Client *c);
|
||||||
static void updatewinid(Client *c);
|
static void updatewinid(Client *c);
|
||||||
|
@ -654,13 +655,9 @@ newclient(void) {
|
||||||
c->vbox = gtk_vbox_new(FALSE, 0);
|
c->vbox = gtk_vbox_new(FALSE, 0);
|
||||||
gtk_paned_pack1(GTK_PANED(c->pane), c->vbox, TRUE, TRUE);
|
gtk_paned_pack1(GTK_PANED(c->pane), c->vbox, TRUE, TRUE);
|
||||||
|
|
||||||
/* Scrolled Window */
|
|
||||||
c->scroll = gtk_scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
|
|
||||||
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
|
||||||
|
|
||||||
/* Webview */
|
/* Webview */
|
||||||
c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
|
c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(c->view),
|
g_signal_connect(G_OBJECT(c->view),
|
||||||
"title-changed",
|
"title-changed",
|
||||||
G_CALLBACK(titlechange), c);
|
G_CALLBACK(titlechange), c);
|
||||||
|
@ -698,6 +695,21 @@ newclient(void) {
|
||||||
"resource-request-starting",
|
"resource-request-starting",
|
||||||
G_CALLBACK(beforerequest), c);
|
G_CALLBACK(beforerequest), c);
|
||||||
|
|
||||||
|
/* Scrolled Window */
|
||||||
|
c->scroll = gtk_scrolled_window_new(NULL, NULL);
|
||||||
|
|
||||||
|
frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(c->view));
|
||||||
|
g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed",
|
||||||
|
G_CALLBACK(gtk_true), NULL);
|
||||||
|
|
||||||
|
if(!enablescrollbars) {
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
|
||||||
|
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||||
|
} else {
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
|
||||||
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
}
|
||||||
|
|
||||||
/* Arranging */
|
/* Arranging */
|
||||||
gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
|
gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
|
||||||
gtk_container_add(GTK_CONTAINER(c->win), c->pane);
|
gtk_container_add(GTK_CONTAINER(c->win), c->pane);
|
||||||
|
@ -718,8 +730,8 @@ newclient(void) {
|
||||||
gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
|
gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
|
||||||
webkit_web_view_set_full_content_zoom(c->view, TRUE);
|
webkit_web_view_set_full_content_zoom(c->view, TRUE);
|
||||||
|
|
||||||
frame = webkit_web_view_get_main_frame(c->view);
|
|
||||||
runscript(frame);
|
runscript(frame);
|
||||||
|
|
||||||
settings = webkit_web_view_get_settings(c->view);
|
settings = webkit_web_view_get_settings(c->view);
|
||||||
if(!(ua = getenv("SURF_USERAGENT")))
|
if(!(ua = getenv("SURF_USERAGENT")))
|
||||||
ua = useragent;
|
ua = useragent;
|
||||||
|
@ -778,22 +790,24 @@ newclient(void) {
|
||||||
static void
|
static void
|
||||||
newwindow(Client *c, const Arg *arg, gboolean noembed) {
|
newwindow(Client *c, const Arg *arg, gboolean noembed) {
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
const char *cmd[10], *uri;
|
const char *cmd[11], *uri;
|
||||||
const Arg a = { .v = (void *)cmd };
|
const Arg a = { .v = (void *)cmd };
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
|
|
||||||
cmd[i++] = argv0;
|
cmd[i++] = argv0;
|
||||||
|
if(!enablescrollbars)
|
||||||
|
cmd[i++] = "-b";
|
||||||
if(embed && !noembed) {
|
if(embed && !noembed) {
|
||||||
cmd[i++] = "-e";
|
cmd[i++] = "-e";
|
||||||
snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
|
snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
|
||||||
cmd[i++] = tmp;
|
cmd[i++] = tmp;
|
||||||
}
|
}
|
||||||
if(!enablescripts)
|
|
||||||
cmd[i++] = "-s";
|
|
||||||
if(!enableplugins)
|
|
||||||
cmd[i++] = "-p";
|
|
||||||
if(!loadimages)
|
if(!loadimages)
|
||||||
cmd[i++] = "-i";
|
cmd[i++] = "-i";
|
||||||
|
if(!enableplugins)
|
||||||
|
cmd[i++] = "-p";
|
||||||
|
if(!enablescripts)
|
||||||
|
cmd[i++] = "-s";
|
||||||
if(showxid)
|
if(showxid)
|
||||||
cmd[i++] = "-x";
|
cmd[i++] = "-x";
|
||||||
cmd[i++] = "--";
|
cmd[i++] = "--";
|
||||||
|
@ -1047,6 +1061,44 @@ toggle(Client *c, const Arg *arg) {
|
||||||
reload(c,&a);
|
reload(c,&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
twitch(Client *c, const Arg *arg) {
|
||||||
|
GtkAdjustment *a;
|
||||||
|
gdouble v;
|
||||||
|
|
||||||
|
a = gtk_scrolled_window_get_vadjustment(
|
||||||
|
GTK_SCROLLED_WINDOW(c->scroll));
|
||||||
|
|
||||||
|
v = gtk_adjustment_get_value(a);
|
||||||
|
|
||||||
|
v += arg->i;
|
||||||
|
|
||||||
|
v = MAX(v, 0.0);
|
||||||
|
v = MIN(v, gtk_adjustment_get_upper(a) -
|
||||||
|
gtk_adjustment_get_page_size(a));
|
||||||
|
gtk_adjustment_set_value(a, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togglescrollbars(Client *c, const Arg *arg) {
|
||||||
|
GtkPolicyType vspolicy;
|
||||||
|
Arg a;
|
||||||
|
|
||||||
|
gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(c->scroll), NULL, &vspolicy);
|
||||||
|
|
||||||
|
if(vspolicy == GTK_POLICY_AUTOMATIC) {
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
|
||||||
|
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||||
|
} else {
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
|
||||||
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
a.i = +1;
|
||||||
|
twitch(c, &a);
|
||||||
|
a.i = -1;
|
||||||
|
twitch(c, &a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
togglestyle(Client *c, const Arg *arg) {
|
togglestyle(Client *c, const Arg *arg) {
|
||||||
WebKitWebSettings *settings;
|
WebKitWebSettings *settings;
|
||||||
|
@ -1128,7 +1180,7 @@ updatewinid(Client *c) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void) {
|
usage(void) {
|
||||||
die("usage: %s [-inpsvx] [-c cookiefile] [-e xid] [-r scriptfile]"
|
die("usage: %s [-binpsvx] [-c cookiefile] [-e xid] [-r scriptfile]"
|
||||||
" [-t stylefile] [-u useragent] [uri]\n", basename(argv0));
|
" [-t stylefile] [-u useragent] [uri]\n", basename(argv0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,6 +1214,9 @@ main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* command line args */
|
/* command line args */
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
|
case 'b':
|
||||||
|
enablescrollbars = 0;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
cookiefile = EARGF(usage());
|
cookiefile = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue