added click link => new tab

This commit is contained in:
WanderingPenwing 2024-08-04 13:58:03 +02:00
parent 698660bc83
commit 14bbe5734b

10
surf.c
View file

@ -292,6 +292,7 @@ static void insert(Client *c, const Arg *a);
/* Buttons */ /* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h); static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clicknewtab(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h); static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h);
static void switch_tab(Client *c, const Arg *a); static void switch_tab(Client *c, const Arg *a);
@ -375,7 +376,7 @@ void free_tab(Tab *tab) {
// Function to add a tab to the clients tab list // Function to add a tab to the clients tab list
void add_tab(Client *client, const gchar *uri) { void add_tab(Client *client, const gchar *uri) {
Tab *tab = g_malloc(sizeof(Tab)); Tab *tab = g_malloc(sizeof(Tab));
tab->title = g_strdup("untitled"); tab->title = g_strdup(uri);
tab->uri = g_strdup(uri); tab->uri = g_strdup(uri);
tab->suspended = false; tab->suspended = false;
client->tabs = g_list_append(client->tabs, tab); client->tabs = g_list_append(client->tabs, tab);
@ -2317,6 +2318,13 @@ clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h)
newwindow(c, &arg, a->i); newwindow(c, &arg, a->i);
} }
void
clicknewtab(Client *c, const Arg *a, WebKitHitTestResult *h)
{
gchar *uri = webkit_hit_test_result_get_link_uri(h);
add_tab(c, uri);
}
void void
clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h) clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h)
{ {