diff options
author | Rui Matos <tiagomatos@gmail.com> | 2015-04-21 17:41:46 +0200 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2016-05-13 18:35:43 +0200 |
commit | 5ab8507ed33e0e22582d76c63807f49d68d96f4b (patch) | |
tree | 7eb55fb3307c442316becada21889c193afbadb0 | |
parent | 50ca7c5a40e832a9ae1ef69961476189c0ceb21f (diff) | |
download | gnome-desktop-5ab8507ed33e0e22582d76c63807f49d68d96f4b.tar.gz |
rr: Add API to know if a GnomeRRMode is interlaced
This includes a change in the DBus API which now includes the mode
flags.
https://bugzilla.gnome.org/show_bug.cgi?id=763833
-rw-r--r-- | libgnome-desktop/gnome-rr-debug.c | 35 | ||||
-rw-r--r-- | libgnome-desktop/gnome-rr.c | 16 | ||||
-rw-r--r-- | libgnome-desktop/gnome-rr.h | 1 | ||||
-rw-r--r-- | libgnome-desktop/meta-xrandr-shared.h | 2 | ||||
-rw-r--r-- | libgnome-desktop/xrandr.xml | 3 |
5 files changed, 43 insertions, 14 deletions
diff --git a/libgnome-desktop/gnome-rr-debug.c b/libgnome-desktop/gnome-rr-debug.c index d7cdc256..af578829 100644 --- a/libgnome-desktop/gnome-rr-debug.c +++ b/libgnome-desktop/gnome-rr-debug.c @@ -24,6 +24,30 @@ #include <gtk/gtk.h> #include <libgnome-desktop/gnome-rr.h> +static void +print_modes (GnomeRROutput *output) +{ + guint i; + GnomeRRMode **modes; + + g_print ("\tmodes:\n"); + modes = gnome_rr_output_list_modes (output); + if (modes[0] == NULL) { + g_print ("\t\tno modes available\n"); + return; + } + + for (i = 0; modes[i] != NULL; i++) { + g_print("\t\t"); + g_print("id: %u", gnome_rr_mode_get_id (modes[i])); + g_print(", %ux%u%s", gnome_rr_mode_get_width (modes[i]), gnome_rr_mode_get_height (modes[i]), + gnome_rr_mode_get_is_interlaced (modes[i]) ? "i" : ""); + g_print(" (%i Hz)", gnome_rr_mode_get_freq (modes[i])); + g_print("%s", gnome_rr_mode_get_is_tiled (modes[i]) ? " (tiled)" : ""); + g_print("\n"); + } +} + static const char * dpms_mode_to_str (GnomeRRDpmsMode mode) { @@ -49,8 +73,7 @@ print_output (GnomeRROutput *output, const char *message) gsize len = 0; const guint8 *result = NULL; int width_mm, height_mm; - GnomeRRMode **modes; - int i; + g_print ("[%s]", gnome_rr_output_get_name (output)); if (message) g_print (" (%s)", message); @@ -82,13 +105,7 @@ print_output (GnomeRROutput *output, const char *message) g_free (serial); } - modes = gnome_rr_output_list_modes (output); - for (i = 0; modes[i] != NULL; ++i) { - g_print ("\t mode: %dx%d%s\n", - gnome_rr_mode_get_width (modes[i]), - gnome_rr_mode_get_height (modes[i]), - gnome_rr_mode_get_is_tiled (modes[i]) ? " (tiled)" : ""); - } + print_modes (output); g_print ("\n"); } diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c index 51034c9c..16670ddc 100644 --- a/libgnome-desktop/gnome-rr.c +++ b/libgnome-desktop/gnome-rr.c @@ -37,6 +37,8 @@ #include "gnome-rr-private.h" +/* From xf86drmMode.h: it's ABI so it won't change */ +#define DRM_MODE_FLAG_INTERLACE (1<<4) enum { SCREEN_PROP_0, @@ -113,6 +115,7 @@ struct GnomeRRMode int height; int freq; /* in mHz */ gboolean tiled; + guint32 flags; }; /* GnomeRRCrtc */ @@ -482,7 +485,7 @@ fill_screen_info_from_resources (ScreenInfo *info, GnomeRRMode *mode; g_variant_get_child (modes, i, META_MONITOR_MODE_STRUCT, &id, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); mode = mode_new (info, id); g_ptr_array_add (a, mode); @@ -2068,15 +2071,22 @@ gnome_rr_mode_get_is_tiled (GnomeRRMode *mode) return mode->tiled; } +gboolean +gnome_rr_mode_get_is_interlaced (GnomeRRMode *mode) +{ + g_return_val_if_fail (mode != NULL, 0); + return (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0; +} + static void mode_initialize (GnomeRRMode *mode, GVariant *info) { gdouble frequency; - g_variant_get (info, "(uxuud)", + g_variant_get (info, META_MONITOR_MODE_STRUCT, &mode->id, &mode->winsys_id, &mode->width, &mode->height, - &frequency); + &frequency, &mode->flags); mode->freq = frequency * 1000; } diff --git a/libgnome-desktop/gnome-rr.h b/libgnome-desktop/gnome-rr.h index e640023e..4c7cf80c 100644 --- a/libgnome-desktop/gnome-rr.h +++ b/libgnome-desktop/gnome-rr.h @@ -184,6 +184,7 @@ guint gnome_rr_mode_get_height (GnomeRRMode *mode) int gnome_rr_mode_get_freq (GnomeRRMode *mode); double gnome_rr_mode_get_freq_f (GnomeRRMode *mode); gboolean gnome_rr_mode_get_is_tiled (GnomeRRMode *mode); +gboolean gnome_rr_mode_get_is_interlaced (GnomeRRMode *mode); /* GnomeRRCrtc */ guint32 gnome_rr_crtc_get_id (GnomeRRCrtc *crtc); diff --git a/libgnome-desktop/meta-xrandr-shared.h b/libgnome-desktop/meta-xrandr-shared.h index 8e9ff9cd..6c460b8a 100644 --- a/libgnome-desktop/meta-xrandr-shared.h +++ b/libgnome-desktop/meta-xrandr-shared.h @@ -37,5 +37,5 @@ typedef enum { #define META_OUTPUT_STRUCT "(uxiausauau@a{sv})" #define META_CRTC_STRUCT "(uxiiiiiuau@a{sv})" -#define META_MONITOR_MODE_STRUCT "(uxuud)" +#define META_MONITOR_MODE_STRUCT "(uxuudu)" #endif diff --git a/libgnome-desktop/xrandr.xml b/libgnome-desktop/xrandr.xml index 06449c36..16ef01ec 100644 --- a/libgnome-desktop/xrandr.xml +++ b/libgnome-desktop/xrandr.xml @@ -115,6 +115,7 @@ * x winsys_id: the low-level ID of this mode * u width, height: the resolution * d frequency: refresh rate + * u flags: mode flags as defined in xf86drmMode.h and randr.h Output and modes are read-only objects (except for output properties), they can change only in accordance to HW changes (such as hotplugging @@ -133,7 +134,7 @@ <arg name="serial" direction="out" type="u" /> <arg name="crtcs" direction="out" type="a(uxiiiiiuaua{sv})" /> <arg name="outputs" direction="out" type="a(uxiausauaua{sv})" /> - <arg name="modes" direction="out" type="a(uxuud)" /> + <arg name="modes" direction="out" type="a(uxuudu)" /> <arg name="max_screen_width" direction="out" type="i" /> <arg name="max_screen_height" direction="out" type="i" /> </method> |