~ubuntu-branches/ubuntu/oneiric/gnome-desktop3/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-06-23 13:18:04 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110623131804-ifp9qfobvxcsbz5e
Tags: 3.1.2-0ubuntu1
* New upstream release.
* debian/control:
* debian/libgnome-desktop-3-2.install:
* debian/libgnome-desktop-3-2.symbols:
  - Bump soname in libgnome-desktop-3 package to match upstream's

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
enum {
78
78
    SCREEN_CHANGED,
 
79
    SCREEN_OUTPUT_CONNECTED,
 
80
    SCREEN_OUTPUT_DISCONNECTED,
79
81
    SCREEN_SIGNAL_LAST,
80
82
};
81
83
 
96
98
    GnomeRRMode **      modes;
97
99
    int                 n_preferred;
98
100
    guint8 *            edid_data;
99
 
    int         edid_size;
 
101
    gsize               edid_size;
100
102
    char *              connector_type;
101
103
};
102
104
 
560
562
    }
561
563
}
562
564
 
 
565
static GnomeRROutput *
 
566
find_output_by_id (GnomeRROutput **haystack, guint32 id)
 
567
{
 
568
    guint i;
 
569
 
 
570
    for (i = 0; haystack[i] != NULL; i++)
 
571
    {
 
572
        if (gnome_rr_output_get_id (haystack[i]) == id)
 
573
            return haystack[i];
 
574
    }
 
575
    return NULL;
 
576
}
 
577
 
 
578
static void
 
579
diff_outputs_and_emit_signals (ScreenInfo *old, ScreenInfo *new)
 
580
{
 
581
    guint i;
 
582
    guint32 id_old, id_new;
 
583
    GnomeRROutput *output_old;
 
584
    GnomeRROutput *output_new;
 
585
 
 
586
    /* have any outputs been removed or disconnected */
 
587
    for (i = 0; old->outputs[i] != NULL; i++)
 
588
    {
 
589
        id_old = gnome_rr_output_get_id (old->outputs[i]);
 
590
        output_new = find_output_by_id (new->outputs, id_old);
 
591
        if (output_new == NULL)
 
592
        {
 
593
            /* output removed (and disconnected) */
 
594
            if (gnome_rr_output_is_connected (old->outputs[i]))
 
595
             {
 
596
                g_signal_emit (G_OBJECT (new->screen),
 
597
                               screen_signals[SCREEN_OUTPUT_DISCONNECTED], 0,
 
598
                               old->outputs[i]);
 
599
             }
 
600
            continue;
 
601
        }
 
602
        if (gnome_rr_output_is_connected (old->outputs[i]) &&
 
603
            !gnome_rr_output_is_connected (output_new))
 
604
        {
 
605
            /* output disconnected */
 
606
            g_signal_emit (G_OBJECT (new->screen),
 
607
                           screen_signals[SCREEN_OUTPUT_DISCONNECTED], 0,
 
608
                           old->outputs[i]);
 
609
        }
 
610
    }
 
611
 
 
612
    /* have any outputs been created or connected */
 
613
    for (i = 0; new->outputs[i] != NULL; i++)
 
614
    {
 
615
        id_new = gnome_rr_output_get_id (new->outputs[i]);
 
616
        output_old = find_output_by_id (old->outputs, id_new);
 
617
        if (output_old == NULL)
 
618
        {
 
619
            /* output created */
 
620
            if (gnome_rr_output_is_connected (new->outputs[i]))
 
621
             {
 
622
                g_signal_emit (G_OBJECT (new->screen),
 
623
                               screen_signals[SCREEN_OUTPUT_CONNECTED], 0,
 
624
                               new->outputs[i]);
 
625
            }
 
626
            continue;
 
627
        }
 
628
        if (!gnome_rr_output_is_connected (output_old) &&
 
629
            gnome_rr_output_is_connected (new->outputs[i]))
 
630
        {
 
631
            /* output connected */
 
632
            g_signal_emit (G_OBJECT (new->screen),
 
633
                           screen_signals[SCREEN_OUTPUT_CONNECTED], 0,
 
634
                           new->outputs[i]);
 
635
         }
 
636
    }
 
637
}
 
638
 
563
639
static gboolean
564
640
screen_update (GnomeRRScreen *screen, gboolean force_callback, gboolean needs_reprobe, GError **error)
565
641
{
577
653
            changed = TRUE;
578
654
#endif
579
655
 
 
656
    /* work out if any outputs have changed connected state */
 
657
    diff_outputs_and_emit_signals (screen->priv->info, info);
 
658
 
580
659
    screen_info_free (screen->priv->info);
581
660
        
582
661
    screen->priv->info = info;
824
903
            g_cclosure_marshal_VOID__VOID,
825
904
            G_TYPE_NONE,
826
905
            0);
 
906
 
 
907
    /**
 
908
     * GnomeRRScreen::output-connected:
 
909
     * @screen: the #GnomeRRScreen that emitted the signal
 
910
     * @output: the #GnomeRROutput that was connected
 
911
     *
 
912
     * This signal is emitted when a display device is connected to a
 
913
     * port, or a port is hotplugged with an active output. The latter
 
914
     * can happen if a laptop is docked, and the dock provides a new
 
915
     * active output.
 
916
     *
 
917
     * The @output value is not a #GObject. The returned @output value can
 
918
     * only assume to be valid during the emission of the signal (i.e. within
 
919
     * your signal handler only), as it may change later when the @screen
 
920
     * is modified due to an event from the X server, or due to another
 
921
     * place in the application modifying the @screen and the @output.
 
922
     * Therefore, deal with changes to the @output right in your signal
 
923
     * handler, instead of keeping the @output reference for an async or
 
924
     * idle function.
 
925
     **/
 
926
    screen_signals[SCREEN_OUTPUT_CONNECTED] = g_signal_new("output-connected",
 
927
            G_TYPE_FROM_CLASS (gobject_class),
 
928
            G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
 
929
            G_STRUCT_OFFSET (GnomeRRScreenClass, output_connected),
 
930
            NULL,
 
931
            NULL,
 
932
            g_cclosure_marshal_VOID__POINTER,
 
933
            G_TYPE_NONE,
 
934
            1, G_TYPE_POINTER);
 
935
 
 
936
    /**
 
937
     * GnomeRRScreen::output-disconnected:
 
938
     * @screen: the #GnomeRRScreen that emitted the signal
 
939
     * @output: the #GnomeRROutput that was disconnected
 
940
     *
 
941
     * This signal is emitted when a display device is disconnected from
 
942
     * a port, or a port output is hot-unplugged. The latter can happen
 
943
     * if a laptop is undocked, and the dock provided the output.
 
944
     *
 
945
     * The @output value is not a #GObject. The returned @output value can
 
946
     * only assume to be valid during the emission of the signal (i.e. within
 
947
     * your signal handler only), as it may change later when the @screen
 
948
     * is modified due to an event from the X server, or due to another
 
949
     * place in the application modifying the @screen and the @output.
 
950
     * Therefore, deal with changes to the @output right in your signal
 
951
     * handler, instead of keeping the @output reference for an async or
 
952
     * idle function.
 
953
     **/
 
954
    screen_signals[SCREEN_OUTPUT_DISCONNECTED] = g_signal_new("output-disconnected",
 
955
            G_TYPE_FROM_CLASS (gobject_class),
 
956
            G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
 
957
            G_STRUCT_OFFSET (GnomeRRScreenClass, output_disconnected),
 
958
            NULL,
 
959
            NULL,
 
960
            g_cclosure_marshal_VOID__POINTER,
 
961
            G_TYPE_NONE,
 
962
            1, G_TYPE_POINTER);
827
963
}
828
964
 
829
965
void
1159
1295
get_property (Display *dpy,
1160
1296
              RROutput output,
1161
1297
              Atom atom,
1162
 
              int *len)
 
1298
              gsize *len)
1163
1299
{
1164
1300
#ifdef HAVE_RANDR
1165
1301
    unsigned char *prop;
1194
1330
}
1195
1331
 
1196
1332
static guint8 *
1197
 
read_edid_data (GnomeRROutput *output, int *len)
 
1333
read_edid_data (GnomeRROutput *output, gsize *len)
1198
1334
{
1199
1335
    Atom edid_atom;
1200
1336
    guint8 *result;
1408
1544
}
1409
1545
 
1410
1546
const guint8 *
1411
 
gnome_rr_output_get_edid_data (GnomeRROutput *output)
 
1547
gnome_rr_output_get_edid_data (GnomeRROutput *output, gsize *size)
1412
1548
{
1413
1549
    g_return_val_if_fail (output != NULL, NULL);
1414
 
    
 
1550
    if (size)
 
1551
        *size = output->edid_size;
1415
1552
    return output->edid_data;
1416
1553
}
1417
1554