xfree86: Only switch to original VT if it is active.
If the X server is terminated while its VT is not active, it should
not change the current VT.
v2: Query current state in xf86CloseConsole using VT_GETSTATE instead of
    keeping track in xf86VTEnter/xf86VTLeave/etc.
			
			
This commit is contained in:
		
							parent
							
								
									7c25439f0d
								
							
						
					
					
						commit
						ff91c696ff
					
				| 
						 | 
				
			
			@ -299,6 +299,7 @@ void
 | 
			
		|||
xf86CloseConsole(void)
 | 
			
		||||
{
 | 
			
		||||
    struct vt_mode VT;
 | 
			
		||||
    struct vt_stat vts;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    if (xf86Info.ShareVTs) {
 | 
			
		||||
| 
						 | 
				
			
			@ -336,10 +337,19 @@ xf86CloseConsole(void)
 | 
			
		|||
 | 
			
		||||
    if (xf86Info.autoVTSwitch) {
 | 
			
		||||
        /*
 | 
			
		||||
         * Perform a switch back to the active VT when we were started
 | 
			
		||||
        * Perform a switch back to the active VT when we were started if our
 | 
			
		||||
        * vt is active now.
 | 
			
		||||
        */
 | 
			
		||||
        if (activeVT >= 0) {
 | 
			
		||||
            SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts));
 | 
			
		||||
            if (ret < 0) {
 | 
			
		||||
                xf86Msg(X_WARNING, "xf86OpenConsole: VT_GETSTATE failed: %s\n",
 | 
			
		||||
                        strerror(errno));
 | 
			
		||||
            } else {
 | 
			
		||||
                if (vts.v_active == xf86Info.vtno) {
 | 
			
		||||
                    switch_to(activeVT, "xf86CloseConsole");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            activeVT = -1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue