The thing that itches me the most :)
Here is patch to restore default palette from kernel when exiting X.
This code detects if the palette is all black. In this case it sets
default palette.
I have inserted and attached the diff file because I dont know if this
mailing list filters attachements.
Guido, please add it to your code if you like it :)
--
Dominik Behr
--- newport_cmap.c.old Fri Nov 23 11:50:45 2001
+++ newport_cmap.c Mon Mar 4 01:56:34 2002
@@ -33,11 +33,45 @@
}
}
+/* stolen from kernel :) */
+static unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
+ 8,12,10,14, 9,13,11,15 };
+
+/* the default colour table, for VGA+ colour systems */
+static int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
+ 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
+static int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
+ 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
+static int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
+ 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
+
/* restore the default colormap */
void NewportRestorePalette(ScrnInfoPtr pScrn)
{
int i;
+ int nSum;
NewportPtr pNewport = NEWPORTPTR(pScrn);
+
+ for (nSum = 0, i = 0; i < 16; i++)
+ {
+ nSum += pNewport->txt_colormap[i].red;
+ nSum += pNewport->txt_colormap[i].green;
+ nSum += pNewport->txt_colormap[i].blue;
+ }
+ if (!nSum)
+ {
+ /*
+ it seems that first 16 entries in saved palette are 0
+ this is bad because when we'll return to the console we will see black screen
+ so we will just restore default palette
+ */
+ for (i = 0; i < 16; i++)
+ {
+ pNewport->txt_colormap[color_table[i]].red = default_red[i];
+ pNewport->txt_colormap[color_table[i]].green = default_grn[i];
+ pNewport->txt_colormap[color_table[i]].blue = default_blu[i];
+ }
+ }
for(i = 0; i < 256; i++) {
NewportCmapSetRGB(pNewport->pNewportRegs, i, pNewport->txt_colormap[i]);
Attachment:
console_restore_fix.diff
Description: Binary data