aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-04 02:31:10 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-04 02:31:10 +0200
commitfa815c3eee27cdae69b2e765b03de62a13f6379d (patch)
tree4244ae7b62e2c94d749f0b199dd620bdd251dad0 /src/Utils.cpp
parentdd4573e05cdfa2d9b99ef7a49c99e27c201da3e9 (diff)
Make font sizes customizable with a config file, see example-config.json. Remove environment variables
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp80
1 files changed, 0 insertions, 80 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 3919bec..fec8bb9 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -5,91 +5,11 @@
#include <locale.h>
namespace QuickMedia {
- static float scale = 1.0f;
- static bool scale_set = false;
- static float font_scale = 1.0f;
- static bool font_scale_set = false;
static bool qm_enable_touch = false;
static bool qm_enable_touch_set = false;
static bool wayland_display_set = false;
static const char *wayland_display = nullptr;
- static const int XFT_DPI_DEFAULT = 96;
- // Returns 96 on error
- static int xrdb_get_dpi() {
- int xft_dpi = XFT_DPI_DEFAULT;
-
- FILE *xrdb_query = popen("xrdb -query", "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;
- }
- }
- }
-
- pclose(xrdb_query);
- return xft_dpi;
- }
-
- float get_ui_scale() {
- if(scale_set)
- return scale;
-
- setlocale(LC_ALL, "C"); // Sigh... stupid C
- char *qm_scale = getenv("QM_SCALE");
- if(qm_scale) {
- scale = atof(qm_scale);
- if(scale < 0.0001f)
- scale = 1.0f;
-
- scale_set = true;
- return scale;
- }
-
- char *gdk_scale = getenv("GDK_SCALE");
- if(gdk_scale) {
- scale = atof(gdk_scale);
- if(scale < 0.0001f)
- scale = 1.0f;
- } else {
- scale = (float)xrdb_get_dpi() / (float)XFT_DPI_DEFAULT;
- }
-
- scale_set = true;
- return scale;
- }
-
- float get_font_scale() {
- if(font_scale_set)
- return font_scale;
-
- char *qm_font_scale = getenv("QM_FONT_SCALE");
- if(qm_font_scale) {
- setlocale(LC_ALL, "C"); // Sigh... stupid C
- font_scale = atof(qm_font_scale);
- if(font_scale < 0.0001f)
- font_scale = 1.0f;
- } else {
- font_scale = 1.0f;
- }
-
- font_scale_set = true;
- return font_scale;
- }
-
void show_virtual_keyboard() {
if(!is_touch_enabled())
return;