[mutter] display: Add meta_display_get_monitor_scale
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] display: Add meta_display_get_monitor_scale
- Date: Fri, 1 Mar 2019 18:06:30 +0000 (UTC)
commit 7442de81bb082801a517a25078113c793a910947
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Tue Aug 1 20:38:41 2017 +0200
display: Add meta_display_get_monitor_scale
This will return the monitor scaling for the requested logical screen
https://bugzilla.gnome.org/show_bug.cgi?id=765011
src/core/display.c | 31 +++++++++++++++++++++++++++++++
src/meta/display.h | 4 ++++
2 files changed, 35 insertions(+)
---
diff --git a/src/core/display.c b/src/core/display.c
index c1dbe8834..eb976e055 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -3513,6 +3513,37 @@ meta_display_get_monitor_geometry (MetaDisplay *display,
*geometry = logical_monitor->rect;
}
+/**
+ * meta_display_get_monitor_scale:
+ * @display: a #MetaDisplay
+ * @monitor: the monitor number
+ *
+ * Gets the monitor scaling value for the given @monitor.
+ *
+ * Return value: the monitor scaling value
+ */
+float
+meta_display_get_monitor_scale (MetaDisplay *display,
+ int monitor)
+{
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
+ MetaLogicalMonitor *logical_monitor;
+#ifndef G_DISABLE_CHECKS
+ int n_logical_monitors =
+ meta_monitor_manager_get_num_logical_monitors (monitor_manager);
+#endif
+
+ g_return_val_if_fail (META_IS_DISPLAY (display), 1.0f);
+ g_return_val_if_fail (monitor >= 0 && monitor < n_logical_monitors, 1.0f);
+
+ logical_monitor =
+ meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
+ monitor);
+ return logical_monitor->scale;
+}
+
/**
* meta_display_get_monitor_in_fullscreen:
* @display: a #MetaDisplay
diff --git a/src/meta/display.h b/src/meta/display.h
index d58150f26..170392048 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -246,6 +246,10 @@ void meta_display_get_monitor_geometry (MetaDisplay *display,
int monitor,
MetaRectangle *geometry);
+META_EXPORT
+float meta_display_get_monitor_scale (MetaDisplay *display,
+ int monitor);
+
META_EXPORT
gboolean meta_display_get_monitor_in_fullscreen (MetaDisplay *display,
int monitor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]