565
static GnomeRROutput *
566
find_output_by_id (GnomeRROutput **haystack, guint32 id)
570
for (i = 0; haystack[i] != NULL; i++)
572
if (gnome_rr_output_get_id (haystack[i]) == id)
579
diff_outputs_and_emit_signals (ScreenInfo *old, ScreenInfo *new)
582
guint32 id_old, id_new;
583
GnomeRROutput *output_old;
584
GnomeRROutput *output_new;
586
/* have any outputs been removed or disconnected */
587
for (i = 0; old->outputs[i] != NULL; i++)
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)
593
/* output removed (and disconnected) */
594
if (gnome_rr_output_is_connected (old->outputs[i]))
596
g_signal_emit (G_OBJECT (new->screen),
597
screen_signals[SCREEN_OUTPUT_DISCONNECTED], 0,
602
if (gnome_rr_output_is_connected (old->outputs[i]) &&
603
!gnome_rr_output_is_connected (output_new))
605
/* output disconnected */
606
g_signal_emit (G_OBJECT (new->screen),
607
screen_signals[SCREEN_OUTPUT_DISCONNECTED], 0,
612
/* have any outputs been created or connected */
613
for (i = 0; new->outputs[i] != NULL; i++)
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)
620
if (gnome_rr_output_is_connected (new->outputs[i]))
622
g_signal_emit (G_OBJECT (new->screen),
623
screen_signals[SCREEN_OUTPUT_CONNECTED], 0,
628
if (!gnome_rr_output_is_connected (output_old) &&
629
gnome_rr_output_is_connected (new->outputs[i]))
631
/* output connected */
632
g_signal_emit (G_OBJECT (new->screen),
633
screen_signals[SCREEN_OUTPUT_CONNECTED], 0,
564
640
screen_update (GnomeRRScreen *screen, gboolean force_callback, gboolean needs_reprobe, GError **error)
824
903
g_cclosure_marshal_VOID__VOID,
908
* GnomeRRScreen::output-connected:
909
* @screen: the #GnomeRRScreen that emitted the signal
910
* @output: the #GnomeRROutput that was connected
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
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
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),
932
g_cclosure_marshal_VOID__POINTER,
937
* GnomeRRScreen::output-disconnected:
938
* @screen: the #GnomeRRScreen that emitted the signal
939
* @output: the #GnomeRROutput that was disconnected
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.
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
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),
960
g_cclosure_marshal_VOID__POINTER,