surf-zoommtghandler-2.1.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
surf-zoommtghandler-2.1.diff (2023B)
---
1 From 47c1ddc06052c5a86aaab8bc4a5a3fe59995b30b Mon Sep 17 00:00:00 2001
2 From: Lars Niesen <lars.niesen@gmx.de>
3 Date: Thu, 9 Dec 2021 14:42:13 +0100
4 Subject: [PATCH] added zoommtg scheme handler
5
6 ---
7 surf.c | 25 +++++++++++++++++++++++++
8 1 file changed, 25 insertions(+)
9
10 diff --git a/surf.c b/surf.c
11 index af0fa74..338045c 100644
12 --- a/surf.c
13 +++ b/surf.c
14 @@ -217,6 +217,8 @@ static void webprocessterminated(WebKitWebView *v,
15 static void closeview(WebKitWebView *v, Client *c);
16 static void destroywin(GtkWidget* w, Client *c);
17
18 +static void handle_zoommtg(WebKitURISchemeRequest *request);
19 +
20 /* Hotkeys */
21 static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
22 static void reload(Client *c, const Arg *a);
23 @@ -562,6 +564,7 @@ loaduri(Client *c, const Arg *a)
24 if (g_strcmp0(uri, "") == 0)
25 return;
26
27 +
28 if (g_str_has_prefix(uri, "http://") ||
29 g_str_has_prefix(uri, "https://") ||
30 g_str_has_prefix(uri, "file://") ||
31 @@ -1182,6 +1185,9 @@ newview(Client *c, WebKitWebView *rv)
32 g_signal_connect(G_OBJECT(context), "initialize-web-extensions",
33 G_CALLBACK(initwebextensions), c);
34
35 + webkit_web_context_register_uri_scheme(context, "zoommtg",
36 + (WebKitURISchemeRequestCallback)handle_zoommtg, NULL, NULL);
37 +
38 v = g_object_new(WEBKIT_TYPE_WEB_VIEW,
39 "settings", settings,
40 "user-content-manager", contentmanager,
41 @@ -1776,6 +1782,25 @@ destroywin(GtkWidget* w, Client *c)
42 gtk_main_quit();
43 }
44
45 +void
46 +handle_zoommtg(WebKitURISchemeRequest *request)
47 +{
48 + char* uri = webkit_uri_scheme_request_get_uri (request);
49 + Arg a = (Arg)PLUMB(uri);
50 + printf("handleplumb: %s",(char*)a.v);
51 + if (fork() == 0) {
52 + if (dpy)
53 + close(ConnectionNumber(dpy));
54 + close(spair[0]);
55 + close(spair[1]);
56 + setsid();
57 + execvp(((char **)a.v)[0], (char **)a.v);
58 + fprintf(stderr, "%s: execvp %s", argv0, ((char **)a.v)[0]);
59 + perror(" failed");
60 + exit(1);
61 + }
62 +}
63 +
64 void
65 pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
66 {
67 --
68 2.34.1
69