Add support for desktop portal capture (-w portal)

This commit is contained in:
dec05eba
2024-07-15 18:57:33 +02:00
parent c447a9a35f
commit 048b8d21ec
21 changed files with 2272 additions and 150 deletions

View File

@@ -1,13 +1,19 @@
#include "../include/utils.h"
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <xf86drmMode.h>
#include <xf86drm.h>
#include <stdlib.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xrandr.h>
double clock_get_monotonic_seconds(void) {
struct timespec ts;
@@ -480,3 +486,35 @@ bool gsr_card_path_get_render_path(const char *card_path, char *render_path) {
close(fd);
return false;
}
int create_directory_recursive(char *path) {
int path_len = strlen(path);
char *p = path;
char *end = path + path_len;
for(;;) {
char *slash_p = strchr(p, '/');
// Skips first '/', we don't want to try and create the root directory
if(slash_p == path) {
++p;
continue;
}
if(!slash_p)
slash_p = end;
char prev_char = *slash_p;
*slash_p = '\0';
int err = mkdir(path, S_IRWXU);
*slash_p = prev_char;
if(err == -1 && errno != EEXIST)
return err;
if(slash_p == end)
break;
else
p = slash_p + 1;
}
return 0;
}