~antarus/lightdm/bug1108518

« back to all changes in this revision

Viewing changes to src/seat-xlocal.c

  • Committer: Robert Ancell
  • Date: 2012-11-28 03:59:16 UTC
  • Revision ID: robert.ancell@canonical.com-20121128035916-srery7lz21x6hqv0
Correctly work out the active display from the active VT when it exits so a greeter starts

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
static void
125
125
seat_xlocal_set_active_display (Seat *seat, Display *display)
126
126
{
127
 
    gint number = xserver_local_get_vt (XSERVER_LOCAL (XSERVER (display_get_display_server (display))));
128
 
    if (number >= 0)
129
 
        vt_set_active (number);
 
127
    gint vt = xserver_local_get_vt (XSERVER_LOCAL (display_get_display_server (display)));
 
128
    if (vt >= 0)
 
129
        vt_set_active (vt);
130
130
 
131
131
    SEAT_CLASS (seat_xlocal_parent_class)->set_active_display (seat, display);
132
132
}
133
133
 
 
134
static Display *
 
135
seat_xlocal_get_active_display (Seat *seat)
 
136
{
 
137
    gint vt;
 
138
    GList *link;
 
139
 
 
140
    vt = vt_get_active ();
 
141
    if (vt < 0)
 
142
        return NULL;
 
143
 
 
144
    for (link = seat_get_displays (seat); link; link = link->next)
 
145
    {
 
146
        Display *display = link->data;
 
147
        XServerLocal *xserver;
 
148
 
 
149
        xserver = XSERVER_LOCAL (display_get_display_server (display));
 
150
        if (xserver_local_get_vt (xserver) == vt)
 
151
            return display;
 
152
    }
 
153
 
 
154
    return NULL;
 
155
}
 
156
 
134
157
static void
135
158
seat_xlocal_run_script (Seat *seat, Display *display, Process *script)
136
159
{
147
170
}
148
171
 
149
172
static void
150
 
seat_xlocal_display_removed (Seat *seat, Display *display)
151
 
{
152
 
    if (seat_get_is_stopping (seat))
153
 
        return;
154
 
 
155
 
    /* If this is the only display and it failed to start then stop this seat */
156
 
    if (g_list_length (seat_get_displays (seat)) == 0 && !display_get_is_ready (display))
157
 
    {
158
 
        g_debug ("Stopping X local seat, failed to start a display");
159
 
        seat_stop (seat);
160
 
        return;
161
 
    }
162
 
 
163
 
    /* Show a new greeter */  
164
 
    if (display == seat_get_active_display (seat))
165
 
    {
166
 
        g_debug ("Active display stopped, switching to greeter");
167
 
        seat_switch_to_greeter (seat);
168
 
    }
169
 
}
170
 
 
171
 
static void
172
173
seat_xlocal_init (SeatXLocal *seat)
173
174
{
174
175
}
182
183
    seat_class->create_display_server = seat_xlocal_create_display_server;
183
184
    seat_class->create_session = seat_xlocal_create_session;
184
185
    seat_class->set_active_display = seat_xlocal_set_active_display;
 
186
    seat_class->get_active_display = seat_xlocal_get_active_display;
185
187
    seat_class->run_script = seat_xlocal_run_script;
186
 
    seat_class->display_removed = seat_xlocal_display_removed;
187
188
}