~ubuntu-branches/ubuntu/vivid/gnome-desktop3/vivid-proposed

« back to all changes in this revision

Viewing changes to libgnome-desktop/gnome-rr-debug.c

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2013-05-28 09:10:46 UTC
  • mfrom: (1.6.1) (21.1.10 experimental)
  • Revision ID: package-import@ubuntu.com-20130528091046-b0oc28za9l97fgq1
Tags: 3.8.2-0ubuntu1
* New upstream release
* Sync with Debian (LP: #1184812) Remaining changes:
  - debian/patches:
    + 04_compute_average_color.patch: Compute the avergage color in
      gnome-desktop itself, not in unity to fix some races (LP #963140)
    + tweak_color_computation.patch, Patch from Gord, no patch header,
      no bug link.
    + git_revert_draw_background.patch
    + ubuntu_language.patch, Ported relevant bits from g-c-c 
      52_region_language.patch, as required for gnome 3.8 region panel
    + ubuntu_language_list_from_SUPPORTED.patch,
      adds api to get list of available languages from SUPPORTED file.
      To be used by gnome 3.8 region panel language installation.
  - debian/control.in:
    + Don't break gnome-shell << 3.7.90
    + Use source:Version for gnome-desktop3-data Depend
    + Add epoch to gnome-desktop3-data's Breaks/Replaces, as our old
      gnome-desktop source package introduced an epoch. This needs to be
      kept until after 14.04 LTS.
 - Install helper tools into a versioned directory (by overriding
   libexecdir). They could alternatively be installed in a separate package
* Dropped changes:
  - 02_refuse_to_break_GL_compositors.patch:
    + Doesn't appear to be needed any more
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Copyright (C) 2012 Richard Hughes <richard@hughsie.com>
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 *
 
19
 */
 
20
 
 
21
#define GNOME_DESKTOP_USE_UNSTABLE_API
 
22
 
 
23
#include <gdk/gdkx.h>
 
24
#include <glib.h>
 
25
#include <gtk/gtk.h>
 
26
#include <libgnome-desktop/gnome-rr.h>
 
27
#include <X11/extensions/Xrandr.h>
 
28
#include <X11/Xatom.h>
 
29
 
 
30
/**
 
31
 * get_property:
 
32
 **/
 
33
static guint8 *
 
34
get_property (Display *dpy,
 
35
              RROutput output,
 
36
              Atom atom,
 
37
              gsize *len)
 
38
{
 
39
        unsigned char *prop;
 
40
        int actual_format;
 
41
        unsigned long nitems, bytes_after;
 
42
        Atom actual_type;
 
43
        guint8 *result = NULL;
 
44
 
 
45
        XRRGetOutputProperty (dpy, output, atom,
 
46
                              0, 100, False, False,
 
47
                              AnyPropertyType,
 
48
                              &actual_type, &actual_format,
 
49
                              &nitems, &bytes_after, &prop);
 
50
 
 
51
        if (actual_type == XA_INTEGER && actual_format == 8) {
 
52
                result = g_memdup (prop, nitems);
 
53
                if (len)
 
54
                        *len = nitems;
 
55
        }
 
56
        XFree (prop);
 
57
        return result;
 
58
}
 
59
 
 
60
/**
 
61
 * main:
 
62
 **/
 
63
int
 
64
main (int argc, char *argv[])
 
65
{
 
66
        Atom edid_atom;
 
67
        Display *display;
 
68
        GError *error = NULL;
 
69
        GnomeRROutput **outputs;
 
70
        GnomeRRScreen *screen;
 
71
        gsize len = 0;
 
72
        guint8 *result = NULL;
 
73
        guint i;
 
74
 
 
75
        gtk_init (&argc, &argv);
 
76
        screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
 
77
        if (screen == NULL) {
 
78
                g_warning ("failed to get screen: %s", error->message);
 
79
                g_error_free (error);
 
80
                goto out;
 
81
        }
 
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]));
 
90
 
 
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]),
 
95
                                       edid_atom,
 
96
                                       &len);
 
97
                if (result != NULL) {
 
98
                        g_print ("\tedid: %" G_GSIZE_FORMAT " bytes [%i:%i:%i:%i]\n",
 
99
                                 len, result[0], result[1],
 
100
                                 result[2], result[3]);
 
101
                        g_free (result);
 
102
                }
 
103
 
 
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]),
 
108
                                       edid_atom,
 
109
                                       &len);
 
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]);
 
114
                        g_free (result);
 
115
                }
 
116
        }
 
117
out:
 
118
        g_object_unref (screen);
 
119
        return 0;
 
120
}