Ensure xrdb code is compiled only on unix
This commit is contained in:
parent
dab39d3b5c
commit
30f9f20e23
|
@ -20,7 +20,7 @@ static double get_scale(void) {
|
||||||
float dpi;
|
float dpi;
|
||||||
SDL_GetDisplayDPI(0, NULL, &dpi, NULL);
|
SDL_GetDisplayDPI(0, NULL, &dpi, NULL);
|
||||||
return dpi / 96.0;
|
return dpi / 96.0;
|
||||||
#elif __linux__
|
#elif __unix__
|
||||||
int xft_dpi = xrdb_find_dpi();
|
int xft_dpi = xrdb_find_dpi();
|
||||||
if (xft_dpi > 0) {
|
if (xft_dpi > 0) {
|
||||||
return xft_dpi / 96.0;
|
return xft_dpi / 96.0;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef __unix__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -25,16 +27,15 @@ static int xrdb_popen (int *pid_ptr) {
|
||||||
int fd[2];
|
int fd[2];
|
||||||
|
|
||||||
pipe(fd);
|
pipe(fd);
|
||||||
int read_fd = fd[STDIN_FILENO];
|
int read_fd = fd[0];
|
||||||
int write_fd = fd[STDOUT_FILENO];
|
int write_fd = fd[1];
|
||||||
|
|
||||||
char *path = getenv("PATH");
|
|
||||||
|
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
close(read_fd);
|
close(read_fd);
|
||||||
dup2(write_fd, STDOUT_FILENO);
|
dup2(write_fd, STDOUT_FILENO);
|
||||||
close(write_fd);
|
close(write_fd);
|
||||||
|
char *path = getenv("PATH");
|
||||||
char xrdb_filename[256];
|
char xrdb_filename[256];
|
||||||
while (path) {
|
while (path) {
|
||||||
char *xrgb_argv[3] = {"xrdb", "-query", NULL};
|
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);
|
xrdb_complete_reading(read_fd);
|
||||||
return dpi_read;
|
return dpi_read;
|
||||||
}
|
}
|
||||||
|
/* doesn't match: position after newline to search again */
|
||||||
line_start = nlptr + 1;
|
line_start = nlptr + 1;
|
||||||
} else {
|
} else {
|
||||||
/* No newline found: copy the remaining part at the beginning of buf
|
/* No newline found: copy the remaining part at the beginning of buf
|
||||||
|
@ -137,3 +139,5 @@ int xrdb_find_dpi() {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue