# \[PATCH\] fbcon needs to save/restore the screeninfo for vc switches

**URL:** <https://discourse.libsdl.org/t/patch-fbcon-needs-to-save-restore-the-screeninfo-for-vc-switches/12786>\
**Category:** SDL Development\
**Created:** [November 28, 2005, 8:16am UTC](https://discourse.libsdl.org/t/patch-fbcon-needs-to-save-restore-the-screeninfo-for-vc-switches/12786 "2005-11-28T08:16:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_Oldeman](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/f6c823/32.png) [@Bart\_Oldeman](https://discourse.libsdl.org/u/Bart_Oldeman)\
**Post date:** [November 28, 2005, 8:16am UTC](https://discourse.libsdl.org/t/patch-fbcon-needs-to-save-restore-the-screeninfo-for-vc-switches/12786/1 "2005-11-28T08:16:12Z")

</div>

Hi,

I observed that the original resolution is lost when I flip consoles back  
and forth using the alt-fn keys. This is using Linux kernel 2.6.14,  
radeonfb. The patch below fixes this. Perhaps this isn’t meant to be  
used, and it’s a kernel bug, but then it just works around a kernel bug 😉

By the way, does anyone why SDL freezes the application when switched away  
using fbcon? It could catch a signal for flipping back, and provide a  
fake frame buffer at a fixed position so that the application can work in  
the background.

Using ctrl-alt-fn for flipping instead of alt-fn may help a few games that  
actually use that key combination. Would such a patch be accepted, or  
should something like that be configurable (environment variable?)

Bart

Index: src/video/fbcon/SDL\_fbevents.c===================================================================  
RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/fbcon/SDL\_fbevents.c,v  
retrieving revision 1.14  
diff -u -r1.14 SDL\_fbevents.c  
— src/video/fbcon/SDL\_fbevents.c 4 Jan 2005 19:04:14 -0000 1.14  
+++ src/video/fbcon/SDL\_fbevents.c 28 Nov 2005 08:13:44 -0000  
@@ -834,6 +834,7 @@  
\*/  
static void switch\_vt(\_THIS, unsigned short which)  
{

- struct fb\_var\_screeninfo vinfo;  
struct vt\_stat vtstate;  
unsigned short v\_active;  
SDL\_Surface \*screen;  
@@ -858,6 +859,7 @@  
memcpy(screen\_contents, screen-\>pixels, screen\_arealen);  
}  
FB\_SavePaletteTo(this, 256, saved\_pal);

- ioctl(console\_fd, FBIOGET\_VSCREENINFO, &vinfo);  
ioctl(keyboard\_fd, KDSETMODE, KD\_TEXT);

- ioctl(console\_fd, FBIOPUT\_VSCREENINFO, &vinfo);  
FB\_RestorePaletteFrom(this, 256, saved\_pal);  
if ( screen\_contents ) {  
memcpy(screen-\>pixels, screen\_contents, screen\_arealen);
