Ensure xrdb code is compiled only on unix

This commit is contained in:
Francesco Abbate 2021-03-17 18:10:47 +01:00
parent dab39d3b5c
commit 30f9f20e23
2 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,7 @@ static double get_scale(void) {
float dpi;
SDL_GetDisplayDPI(0, NULL, &dpi, NULL);
return dpi / 96.0;
#elif __linux__
#elif __unix__
int xft_dpi = xrdb_find_dpi();
if (xft_dpi > 0) {
return xft_dpi / 96.0;

View File

@ -1,3 +1,5 @@
#ifdef __unix__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -25,16 +27,15 @@ static int xrdb_popen (int *pid_ptr) {
int fd[2];
pipe(fd);
int read_fd = fd[STDIN_FILENO];
int write_fd = fd[STDOUT_FILENO];
char *path = getenv("PATH");
int read_fd = fd[0];
int write_fd = fd[1];
int pid = fork();
if (pid == 0) {
close(read_fd);
dup2(write_fd, STDOUT_FILENO);
close(write_fd);
char *path = getenv("PATH");
char xrdb_filename[256];
while (path) {
char *xrgb_argv[3] = {"xrdb", "-query", NULL};
@ -93,6 +94,7 @@ static int xrdb_parse_for_dpi(int read_fd) {
xrdb_complete_reading(read_fd);
return dpi_read;
}
/* doesn't match: position after newline to search again */
line_start = nlptr + 1;
} else {
/* No newline found: copy the remaining part at the beginning of buf
@ -137,3 +139,5 @@ int xrdb_find_dpi() {
}
return -1;
}
#endif