summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-02-19 14:18:43 -0600
committerFederico Mena Quintero <federico@novell.com>2010-02-19 15:13:25 -0600
commit6f57fded4ab4a409795c8d97f998dbefe8998db9 (patch)
tree2b864d5684e01a3532e056ff25317e1c95d4409c
parent8eb0886312751054e2e6d9b10eedbb0ddf180deb (diff)
downloadgnome-desktop-6f57fded4ab4a409795c8d97f998dbefe8998db9.tar.gz
Add gnome_rr_output_get_connector_type()
We will need this to identify a laptop's built-in LCD robustly when RANDR 1.3 is present. Signed-off-by: Federico Mena Quintero <federico@novell.com>
-rw-r--r--libgnome-desktop/gnome-rr-private.h2
-rw-r--r--libgnome-desktop/gnome-rr.c53
-rw-r--r--libgnome-desktop/libgnomeui/gnome-rr.h3
3 files changed, 57 insertions, 1 deletions
diff --git a/libgnome-desktop/gnome-rr-private.h b/libgnome-desktop/gnome-rr-private.h
index c968291d..15ba4a24 100644
--- a/libgnome-desktop/gnome-rr-private.h
+++ b/libgnome-desktop/gnome-rr-private.h
@@ -38,6 +38,8 @@ struct GnomeRRScreen
GnomeRRScreenChanged callback;
gpointer data;
+
+ Atom connector_type_atom;
};
#endif
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index 6f23fbbb..7888db83 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -54,6 +54,7 @@ struct GnomeRROutput
GnomeRRMode ** modes;
int n_preferred;
guint8 * edid_data;
+ char * connector_type;
};
struct GnomeRROutputWrap
@@ -623,6 +624,7 @@ gnome_rr_screen_new (GdkScreen *gdk_screen,
screen->xroot = gdk_x11_drawable_get_xid (screen->gdk_root);
screen->xdisplay = dpy;
screen->xscreen = gdk_x11_screen_get_xscreen (screen->gdk_screen);
+ screen->connector_type_atom = XInternAtom (dpy, "ConnectorType", FALSE);
screen->callback = callback;
screen->data = data;
@@ -904,6 +906,44 @@ read_edid_data (GnomeRROutput *output)
return NULL;
}
+static char *
+get_connector_type_string (GnomeRROutput *output)
+{
+ char *result;
+ unsigned char *prop;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+ Atom actual_type;
+ Atom connector_type;
+ char *connector_type_str;
+
+ result = NULL;
+
+ if (XRRGetOutputProperty (DISPLAY (output), output->id, output->info->screen->connector_type_atom,
+ 0, 100, False, False,
+ AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop) != Success)
+ return NULL;
+
+ if (!(actual_type == XA_ATOM && actual_format == 32 && nitems == 1))
+ goto out;
+
+ connector_type = *((Atom *) prop);
+
+ connector_type_str = XGetAtomName (DISPLAY (output), connector_type);
+ if (connector_type_str) {
+ result = g_strdup (connector_type_str); /* so the caller can g_free() it */
+ XFree (connector_type_str);
+ }
+
+ XFree (prop);
+
+out:
+
+ return result;
+}
+
static gboolean
output_initialize (GnomeRROutput *output, XRRScreenResources *res, GError **error)
{
@@ -931,7 +971,8 @@ output_initialize (GnomeRROutput *output, XRRScreenResources *res, GError **erro
output->width_mm = info->mm_width;
output->height_mm = info->mm_height;
output->connected = (info->connection == RR_Connected);
-
+ output->connector_type = get_connector_type_string (output);
+
/* Possible crtcs */
a = g_ptr_array_new ();
@@ -987,6 +1028,7 @@ output_free (GnomeRROutput *output)
g_free (output->possible_crtcs);
g_free (output->edid_data);
g_free (output->name);
+ g_free (output->connector_type);
g_free (output);
}
@@ -1034,6 +1076,15 @@ gnome_rr_output_get_crtc (GnomeRROutput *output)
return output->current_crtc;
}
+/* Returns NULL if the ConnectorType property is not available */
+const char *
+gnome_rr_output_get_connector_type (GnomeRROutput *output)
+{
+ g_return_val_if_fail (output != NULL, NULL);
+
+ return output->connector_type;
+}
+
GnomeRRMode *
gnome_rr_output_get_current_mode (GnomeRROutput *output)
{
diff --git a/libgnome-desktop/libgnomeui/gnome-rr.h b/libgnome-desktop/libgnomeui/gnome-rr.h
index c43bd8fa..c67a94f9 100644
--- a/libgnome-desktop/libgnomeui/gnome-rr.h
+++ b/libgnome-desktop/libgnomeui/gnome-rr.h
@@ -63,6 +63,8 @@ typedef enum {
GNOME_RR_ERROR_NO_MATCHING_CONFIG, /* none of the saved configurations matched the current configuration */
} GnomeRRError;
+#define GNOME_RR_CONNECTOR_TYPE_PANEL "Panel" /* This is a laptop's built-in LCD */
+
/* GnomeRRScreen */
GnomeRRScreen * gnome_rr_screen_new (GdkScreen *screen,
GnomeRRScreenChanged callback,
@@ -109,6 +111,7 @@ const guint8 * gnome_rr_output_get_edid_data (GnomeRROutput *outpu
GnomeRRCrtc ** gnome_rr_output_get_possible_crtcs (GnomeRROutput *output);
GnomeRRMode * gnome_rr_output_get_current_mode (GnomeRROutput *output);
GnomeRRCrtc * gnome_rr_output_get_crtc (GnomeRROutput *output);
+const char * gnome_rr_output_get_connector_type (GnomeRROutput *output);
void gnome_rr_output_get_position (GnomeRROutput *output,
int *x,
int *y);