1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2012 Richard Hughes <richard@hughsie.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#define GNOME_DESKTOP_USE_UNSTABLE_API
26
#include <libgnome-desktop/gnome-rr.h>
27
#include <X11/extensions/Xrandr.h>
28
#include <X11/Xatom.h>
34
get_property (Display *dpy,
41
unsigned long nitems, bytes_after;
43
guint8 *result = NULL;
45
XRRGetOutputProperty (dpy, output, atom,
48
&actual_type, &actual_format,
49
&nitems, &bytes_after, &prop);
51
if (actual_type == XA_INTEGER && actual_format == 8) {
52
result = g_memdup (prop, nitems);
64
main (int argc, char *argv[])
69
GnomeRROutput **outputs;
70
GnomeRRScreen *screen;
72
guint8 *result = NULL;
75
gtk_init (&argc, &argv);
76
screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
78
g_warning ("failed to get screen: %s", error->message);
82
display = GDK_SCREEN_XDISPLAY (gdk_screen_get_default ());
83
outputs = gnome_rr_screen_list_outputs (screen);
84
for (i = 0; outputs[i] != NULL; i++) {
85
g_print ("[%s]\n", gnome_rr_output_get_name (outputs[i]));
86
g_print ("\tconnected: %i\n", gnome_rr_output_is_connected (outputs[i]));
87
g_print ("\tlaptop: %i\n", gnome_rr_output_is_laptop (outputs[i]));
88
g_print ("\tprimary: %i\n", gnome_rr_output_get_is_primary (outputs[i]));
89
g_print ("\tid: %i\n", gnome_rr_output_get_id (outputs[i]));
91
/* get EDID (first try) */
92
edid_atom = XInternAtom (display, "EDID", FALSE);
93
result = get_property (display,
94
gnome_rr_output_get_id (outputs[i]),
98
g_print ("\tedid: %" G_GSIZE_FORMAT " bytes [%i:%i:%i:%i]\n",
99
len, result[0], result[1],
100
result[2], result[3]);
104
/* get EDID (second try) */
105
edid_atom = XInternAtom (display, "EDID_DATA", FALSE);
106
result = get_property (display,
107
gnome_rr_output_get_id (outputs[i]),
110
if (result != NULL) {
111
g_print ("\tedid2: %" G_GSIZE_FORMAT " bytes [%i:%i:%i:%i]\n",
112
len, result[0], result[1],
113
result[2], result[3]);
118
g_object_unref (screen);