From 2b19afe66df401ae22a557b3d59b1fe470eef034 Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Sat, 11 Nov 2017 20:49:09 +0000 Subject: [PATCH] Fixed not picking up GDK_DPI_SCALE=-1 by command-line. --- gsmartcontrol/src/gsc_init.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gsmartcontrol/src/gsc_init.cpp b/gsmartcontrol/src/gsc_init.cpp index 7ea42d1..57a4e84 100644 --- a/gsmartcontrol/src/gsc_init.cpp +++ b/gsmartcontrol/src/gsc_init.cpp @@ -15,6 +15,7 @@ #include // std::printf #include #include +#include #include #include // g_, G* #include // set_application_name @@ -211,8 +212,8 @@ namespace { arg_hide_tabs(TRUE), arg_add_virtual(NULL), arg_add_device(NULL), - arg_gdk_scale(-1), - arg_gdk_dpi_scale(-1) + arg_gdk_scale(std::numeric_limits::quiet_NaN()), + arg_gdk_dpi_scale(std::numeric_limits::quiet_NaN()) { } // Note: Use GLib types here: @@ -222,8 +223,8 @@ namespace { gboolean arg_hide_tabs; ///< if true, hide additional info tabs when smart is disabled. false may help debugging. gchar** arg_add_virtual; ///< load smartctl data from these files as virtual drives gchar** arg_add_device; ///< add these device files manually - gint arg_gdk_scale; ///< The value of GDK_SCALE environment variable - gint arg_gdk_dpi_scale; ///< The value of GDK_DPI_SCALE environment variable + double arg_gdk_scale; ///< The value of GDK_SCALE environment variable + double arg_gdk_dpi_scale; ///< The value of GDK_DPI_SCALE environment variable }; @@ -249,9 +250,9 @@ namespace { " Example: --add-device /dev/sda --add-device /dev/twa0::3ware,2 --add-device '/dev/sdb::::-T permissive'", NULL }, #ifndef _WIN32 // X11-specific - { "gdk-scale", 'l', 0, G_OPTION_ARG_INT, &(args.arg_gdk_scale), + { "gdk-scale", 'l', 0, G_OPTION_ARG_DOUBLE, &(args.arg_gdk_scale), "The value of GDK_SCALE environment variable (useful when executing with pkexec)", NULL }, - { "gdk-dpi-scale", 'l', 0, G_OPTION_ARG_INT, &(args.arg_gdk_dpi_scale), + { "gdk-dpi-scale", 'l', 0, G_OPTION_ARG_DOUBLE, &(args.arg_gdk_dpi_scale), "The value of GDK_DPI_SCALE environment variable (useful when executing with pkexec)", NULL }, #endif { NULL } @@ -404,10 +405,10 @@ bool app_init_and_loop(int& argc, char**& argv) debug_out_dump("app", "LibDebug options:\n" << debug_get_cmd_args_dump()); #ifndef _WIN32 - if (args.arg_gdk_scale > 0) { + if (args.arg_gdk_scale == args.arg_gdk_scale) { // not NaN hz::env_set_value("GDK_SCALE", hz::number_to_string(args.arg_gdk_scale)); } - if (args.arg_gdk_dpi_scale > 0) { + if (args.arg_gdk_dpi_scale == args.arg_gdk_dpi_scale) { // not NaN hz::env_set_value("GDK_DPI_SCALE", hz::number_to_string(args.arg_gdk_dpi_scale)); } #endif