예제 #1
0
static gboolean
handle_get_x11_display_number (GdmDBusDisplay        *skeleton,
                               GDBusMethodInvocation *invocation,
                               GdmDisplay            *display)
{
    int name;

    gdm_display_get_x11_display_number (display, &name, NULL);

    gdm_dbus_display_complete_get_x11_display_number (skeleton, invocation, name);

    return TRUE;
}
예제 #2
0
static void
on_display_status_changed (GdmDisplay             *display,
                           GParamSpec             *arg1,
                           GdmLocalDisplayFactory *factory)
{
        int              status;
        GdmDisplayStore *store;
        int              num;
        char            *seat_id = NULL;
        char            *session_type = NULL;
        gboolean         is_initial = TRUE;
        gboolean         is_local = TRUE;

        num = -1;
        gdm_display_get_x11_display_number (display, &num, NULL);

        store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));

        g_object_get (display,
                      "seat-id", &seat_id,
                      "is-initial", &is_initial,
                      "is-local", &is_local,
                      "session-type", &session_type,
                      NULL);

        status = gdm_display_get_status (display);

        g_debug ("GdmLocalDisplayFactory: display status changed: %d", status);
        switch (status) {
        case GDM_DISPLAY_FINISHED:
                /* remove the display number from factory->priv->used_display_numbers
                   so that it may be reused */
                if (num != -1) {
                        g_hash_table_remove (factory->priv->used_display_numbers, GUINT_TO_POINTER (num));
                }
                gdm_display_store_remove (store, display);

                /* Create a new equivalent display if it was static */
                if (is_local) {
                        /* reset num failures */
                        factory->priv->num_failures = 0;

                        create_display (factory, seat_id, session_type, is_initial);
                }
                break;
        case GDM_DISPLAY_FAILED:
                /* leave the display number in factory->priv->used_display_numbers
                   so that it doesn't get reused */
                gdm_display_store_remove (store, display);

                /* Create a new equivalent display if it was static */
                if (is_local) {

                        factory->priv->num_failures++;

                        if (factory->priv->num_failures > MAX_DISPLAY_FAILURES) {
                                /* oh shit */
                                g_warning ("GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors");
                                /* FIXME: should monitor hardware changes to
                                   try again when seats change */
                        } else {
#ifdef ENABLE_WAYLAND_SUPPORT
                                if (g_strcmp0 (session_type, "wayland") == 0) {
                                        g_free (session_type);
                                        session_type = NULL;
                                }

#endif
                                create_display (factory, seat_id, session_type, is_initial);
                        }
                }
                break;
        case GDM_DISPLAY_UNMANAGED:
                break;
        case GDM_DISPLAY_PREPARED:
                break;
        case GDM_DISPLAY_MANAGED:
                break;
        default:
                g_assert_not_reached ();
                break;
        }

        g_free (seat_id);
        g_free (session_type);
}