aboutsummaryrefslogtreecommitdiff
path: root/src/Config.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-24 03:33:13 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-24 03:33:13 +0200
commitf0f6d45cd3aa39f1eea4e8fd1518edeee50689ef (patch)
tree3a9e0d978cfe4851d884efdb069df9cb8d636f7e /src/Config.cpp
parentfdeb82815db468ac7e99e9646f57bed2bf1832de (diff)
Add scrollbar
Diffstat (limited to 'src/Config.cpp')
-rw-r--r--src/Config.cpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index c75f120..266c45c 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -15,26 +15,17 @@ namespace QuickMedia {
static int xrdb_get_dpi() {
int xft_dpi = XFT_DPI_DEFAULT;
- FILE *xrdb_query = popen("xrdb -query", "r");
+ FILE *xrdb_query = popen("xrdb -get Xft.dpi", "r");
if(!xrdb_query)
return xft_dpi;
- char line[512];
- while(fgets(line, sizeof(line), xrdb_query)) {
- int line_length = strlen(line);
- if(line_length > 0 && line[line_length - 1] == '\n') {
- line[line_length - 1] = '\0';
- line_length--;
- }
-
- if(line_length > 8 && memcmp(line, "Xft.dpi:", 8) == 0) {
- int xft_dpi_file = atoi(line + 8);
- if(xft_dpi_file > 0) {
- xft_dpi = xft_dpi_file;
- break;
- }
- }
- }
+ char line[32];
+ line[0] = '\0';
+ fread(line, 1, sizeof(line), xrdb_query);
+
+ const int xft_dpi_file = atoi(line);
+ if(xft_dpi_file > 0)
+ xft_dpi = xft_dpi_file;
pclose(xrdb_query);
return xft_dpi;
@@ -44,7 +35,7 @@ namespace QuickMedia {
if(scale_set)
return scale;
- char *gdk_scale = getenv("GDK_SCALE");
+ const char *gdk_scale = getenv("GDK_SCALE");
if(gdk_scale) {
setlocale(LC_ALL, "C"); // Sigh... stupid C
scale = atof(gdk_scale);
@@ -143,8 +134,6 @@ namespace QuickMedia {
const Json::Value &scale_json = json_root["scale"];
if(scale_json.isNumeric())
config->scale = scale_json.asDouble();
- else
- config->scale = get_ui_scale();
const Json::Value &font_scale = json_root["font_scale"];
if(font_scale.isNumeric())