shithub: npe

Download patch

ref: aa5a3c93fd362849de33c1802a53c333e81a5acb
parent: 567a3d7ff04f271acccf1c3e92c888c70bdbe3bb
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 17 03:33:59 EDT 2021

sdl2: SDL_OpenURL

--- a/include/npe/SDL2/SDL.h
+++ b/include/npe/SDL2/SDL.h
@@ -120,6 +120,7 @@
 int SDL_SaveBMP(SDL_Surface *s, const char *file);
 void SDL_ClearError(void);
 int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
+int SDL_OpenURL(char *url);
 
 enum {
 	AUDIO_S16,
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -5,6 +5,7 @@
 #include <memdraw.h>
 #include <mouse.h>
 #include <cursor.h>
+#include <plumb.h>
 #include <SDL2/SDL.h>
 
 typedef struct Audiodev Audiodev;
@@ -1253,6 +1254,28 @@
 SDL_GetTicks(void)
 {
 	return npe_nanosec()/1000000ULL;
+}
+
+int
+SDL_OpenURL(char *url)
+{
+	char tmp[PATH_MAX];
+	Plumbmsg m;
+	int f, r;
+
+	if((f = plumbopen("send", OWRITE|OCEXEC)) < 0)
+		return -1;
+
+	memset(&m, 0, sizeof(m));
+	m.src = argv0;
+	m.wdir = getwd(tmp, sizeof(tmp));
+	m.type = "text";
+	m.data = url;
+	m.ndata = -1;
+	r = plumbsend(f, &m);
+	close(f);
+
+	return r;
 }
 
 SDL_bool