summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--surf.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/surf.c b/surf.c
index f7d9f3c..097ecc9 100644
--- a/surf.c
+++ b/surf.c
@@ -66,6 +66,7 @@ static char *progname;
static gboolean loadimage = 1, plugin = 1, script = 1;
static char *buildpath(const char *path);
+static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl);
static void cleanup(void);
static void clipboard(Client *c, const Arg *arg);
static char *copystr(char **str, const char *src);
@@ -89,7 +90,7 @@ static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
static void loaduri(Client *c, const Arg *arg);
static void navigate(Client *c, const Arg *arg);
static Client *newclient(void);
-static void newwindow(Client *c, const Arg *arg);
+static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static void print(Client *c, const Arg *arg);
@@ -141,6 +142,23 @@ buildpath(const char *path) {
return apath;
}
+static gboolean
+buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl) {
+ WebKitHitTestResultContext context;
+ WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(web, e);
+ Arg arg;
+
+ g_object_get(result, "context", &context, NULL);
+ if(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
+ if(e->button == 2) {
+ g_object_get(result, "link-uri", &arg.v, NULL);
+ newwindow(NULL, &arg, e->state & GDK_CONTROL_MASK);
+ return true;
+ }
+ }
+ return false;
+}
+
void
cleanup(void) {
while(clients)
@@ -216,7 +234,7 @@ decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r, We
if(webkit_web_navigation_action_get_reason(n) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
webkit_web_policy_decision_ignore(p);
arg.v = (void *)webkit_network_request_get_uri(r);
- newwindow(NULL, &arg);
+ newwindow(NULL, &arg, 0);
return TRUE;
}
return FALSE;
@@ -404,7 +422,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
setatom(c, AtomUri, uri);
break;
case WEBKIT_LOAD_FINISHED:
- c->progress = 0;
+ c->progress = 100;
update(c);
break;
default:
@@ -494,6 +512,7 @@ newclient(void) {
g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c);
g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
+ g_signal_connect(G_OBJECT(c->view), "button-release-event", G_CALLBACK(buttonrelease), c);
/* Indicator */
c->indicator = gtk_drawing_area_new();
@@ -568,14 +587,14 @@ newrequest(SoupSession *s, SoupMessage *msg, gpointer v) {
}
void
-newwindow(Client *c, const Arg *arg) {
+newwindow(Client *c, const Arg *arg, gboolean noembed) {
guint i = 0;
const char *cmd[10], *uri;
const Arg a = { .v = (void *)cmd };
char tmp[64];
cmd[i++] = progname;
- if(embed) {
+ if(embed && !noembed) {
cmd[i++] = "-e";
snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
cmd[i++] = tmp;
'insertions'>+28 2009-10-16improving urlbar hiding.Gravatar Enno Boland (tox) 1-5/+3 2009-10-15creating new process when opening new window if possible.Gravatar Enno Boland (tox) 1-13/+90 2009-10-14better useragent string (for google-* and stuff)Gravatar Enno Boland (tox) 1-1/+1 2009-10-14changing useragent.Gravatar Enno Boland (tox) 2-1/+2 2009-10-14uncommenting source()Gravatar Enno Boland (tox) 1-2/+2 2009-10-13removing loadfile. readding later in a simpler way.Gravatar Enno Boland (tox) 1-40/+2 2009-10-13removing debug outputGravatar Enno Boland (tox) 1-1/+0 2009-10-13fixing stupidy bug.Gravatar Enno Boland (tox) 1-1/+1 2009-10-13fixing memoryleak.Gravatar Enno Boland (tox) 1-2/+3 2009-10-13making config-files configurable in config.hGravatar Enno Boland (tox) 2-32/+46 2009-10-13small whitespacefix.Gravatar Enno Boland (tox) 1-1/+1 2009-10-07hooking onloadfunctions should be done by script.js.Gravatar Enno Boland (tox) 1-3/+0 2009-09-21commenting.Gravatar Enno Boland (tox) 1-0/+1 2009-09-21typoGravatar Enno Boland (tox) 1-2/+2 2009-09-17reformatingGravatar Enno Boland (tox) 1-2/+0 2009-09-17applied patch from arg. thanks :)Gravatar Enno Boland (tox) 2-66/+56 2009-09-16next version is 0.2Gravatar Enno Boland (tox) 1-1/+1 2009-09-16auto creation of script.jsGravatar Enno Boland (tox) 1-0/+3 2009-09-16adding user.js support.Gravatar Enno Boland (tox) 1-4/+22 2009-09-13usercss works again.Gravatar Enno Boland (tox) 1-10/+11 2009-09-11Added tag 0.1.2 for changeset bffb0c3c2341Gravatar Enno Boland (tox) 1-0/+1 2009-09-11next will be 0.1.2Gravatar Enno Boland (tox) 1-1/+1 2009-09-11Makefile fixingGravatar Enno Boland (tox) 2-2/+2 2009-09-11Adding README file.Gravatar Enno Boland (tox) 2-1/+26 2009-09-11unfocus should return false; renaming cookie-file.Gravatar Enno Boland (tox) 1-2/+2 2009-09-11surf embeds now itself into another window.Gravatar Enno Boland (tox) 1-8/+9 2009-09-10Added tag 0.1.1 for changeset 3ef997607115Gravatar Enno Boland (tox) 1-0/+1 2009-09-10bugfix releaseGravatar Enno Boland (tox) 1-1/+1 2009-09-10removing unneeded background color.Gravatar Enno Boland (tox) 1-1/+0 2009-09-10rearranging some source.Gravatar Enno Boland (tox) 1-12/+19 2009-09-10adding user stylesheets.Gravatar Enno Boland (tox) 1-10/+21 2009-09-10Added tag 0.1 for changeset 9c8ebcf54061Gravatar Enno Boland (tox) 1-0/+2 2009-09-10dist doesn't work. fixing Makefile.Gravatar Enno Boland (tox) 1-1/+1