Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdding middle-click behaviour to open a tab when embedded or a window when not…
git clone git://src.adamsgaard.dk/surf
Log
Files
Refs
README
LICENSE
---
commit 2e92060efcb672e44dfd3424a9dadffcdf9aa770
parent 23def74c9814c1db25081965febd8424c3207e2c
Author: Christoph Lohmann <[email protected]>
Date: Sat, 13 Oct 2012 07:16:08 +0200
Adding middle-click behaviour to open a tab when embedded or a window when
not. Thanks to Carlos Pita <[email protected]>!
Diffstat:
M surf.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/surf.c b/surf.c
t@@ -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);
t@@ -89,7 +90,7 @@ static void loadstatuschange(WebKitWebView *view, GParamSpec…
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);
t@@ -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,…
+ 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)
t@@ -216,7 +234,7 @@ decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKi…
if(webkit_web_navigation_action_get_reason(n) == WEBKIT_WEB_NAVIGATION…
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;
t@@ -404,7 +422,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, C…
setatom(c, AtomUri, uri);
break;
case WEBKIT_LOAD_FINISHED:
- c->progress = 0;
+ c->progress = 100;
update(c);
break;
default:
t@@ -494,6 +512,7 @@ newclient(void) {
g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(…
g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(pro…
g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(i…
+ g_signal_connect(G_OBJECT(c->view), "button-release-event", G_CALLBACK…
/* Indicator */
c->indicator = gtk_drawing_area_new();
t@@ -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;
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.