[gnome-panel/wip/muktupavels/hidpi: 1/4] util: add get_window_scaling_factor function




commit 37d55a71e574fdfd3e0d602bc7259eff60ae49cc
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Apr 22 19:51:57 2021 +0300

    util: add get_window_scaling_factor function

 gnome-panel/panel-util.c | 15 +++++++++++++++
 gnome-panel/panel-util.h |  2 ++
 2 files changed, 17 insertions(+)
---
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index b9fc1eaca..dfcabd35b 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -866,3 +866,18 @@ panel_util_key_event_is_popup_panel (GdkEventKey *event,
        panel_util_key_event_is_binding (event, PANEL_TYPE_TOPLEVEL, "popup-panel-menu",
                                         is_popup, is_popup_modifier);
 }
+
+int
+panel_util_get_window_scaling_factor (void)
+{
+       GValue value = G_VALUE_INIT;
+
+       g_value_init (&value, G_TYPE_INT);
+
+       if (gdk_screen_get_setting (gdk_screen_get_default (),
+                                   "gdk-window-scaling-factor",
+                                   &value))
+               return g_value_get_int (&value);
+
+       return 1;
+}
diff --git a/gnome-panel/panel-util.h b/gnome-panel/panel-util.h
index 3bdf0add1..7ca57e37a 100644
--- a/gnome-panel/panel-util.h
+++ b/gnome-panel/panel-util.h
@@ -35,6 +35,8 @@ void panel_util_key_event_is_popup_panel (GdkEventKey *event,
                                          gboolean    *is_popup,
                                          gboolean    *is_popup_modifier);
 
+int panel_util_get_window_scaling_factor (void);
+
 G_END_DECLS
 
 #endif /* PANEL_UTIL_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]