Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Last active July 14, 2020 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutsui/6bcef41da9b2003ae33fdaea0286b000 to your computer and use it in GitHub Desktop.
Save tsutsui/6bcef41da9b2003ae33fdaea0286b000 to your computer and use it in GitHub Desktop.
Fixes to make Xorg black and white monochrome server print the mouse cursor and twm window titlebars etc.
? xorg-server.old/dist/hw/sun
Index: xorg-server/dist/fb/fb.h
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server/dist/fb/fb.h,v
retrieving revision 1.1.1.6
diff -u -p -d -r1.1.1.6 fb.h
--- xorg-server/dist/fb/fb.h 31 Dec 2018 09:36:09 -0000 1.1.1.6
+++ xorg-server/dist/fb/fb.h 14 Jul 2020 13:41:45 -0000
@@ -734,6 +734,9 @@ fbResolveColor(unsigned short *pred,
extern _X_EXPORT Bool
fbInitializeColormap(ColormapPtr pmap);
+extern _X_EXPORT Bool
+mfbCreateColormap(ColormapPtr pmap);
+
extern _X_EXPORT int
fbExpandDirectColors(ColormapPtr pmap,
Index: xorg-server/dist/fb/fbcmap_mi.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server/dist/fb/fbcmap_mi.c,v
retrieving revision 1.1.1.5
diff -u -p -d -r1.1.1.5 fbcmap_mi.c
--- xorg-server/dist/fb/fbcmap_mi.c 10 Aug 2016 07:44:35 -0000 1.1.1.5
+++ xorg-server/dist/fb/fbcmap_mi.c 14 Jul 2020 13:41:45 -0000
@@ -66,6 +66,41 @@ fbInitializeColormap(ColormapPtr pmap)
return miInitializeColormap(pmap);
}
+Bool
+mfbCreateColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen;
+ unsigned short red0, green0, blue0;
+ unsigned short red1, green1, blue1;
+ Pixel pix;
+
+ pScreen = pmap->pScreen;
+ if (pScreen->whitePixel == 0)
+ {
+ red0 = green0 = blue0 = ~0;
+ red1 = green1 = blue1 = 0;
+ }
+ else
+ {
+ red0 = green0 = blue0 = 0;
+ red1 = green1 = blue1 = ~0;
+ }
+
+ /* this is a monochrome colormap, it only has two entries, just fill
+ * them in by hand. If it were a more complex static map, it would be
+ * worth writing a for loop or three to initialize it */
+
+ /* this will be pixel 0 */
+ pix = 0;
+ if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success)
+ return FALSE;
+
+ /* this will be pixel 1 */
+ if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success)
+ return FALSE;
+ return TRUE;
+}
+
int
fbExpandDirectColors(ColormapPtr pmap,
int ndef, xColorItem * indefs, xColorItem * outdefs)
Index: xorg-server/dist/fb/fbscreen.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server/dist/fb/fbscreen.c,v
retrieving revision 1.1.1.6
diff -u -p -d -r1.1.1.6 fbscreen.c
--- xorg-server/dist/fb/fbscreen.c 31 Dec 2018 09:36:09 -0000 1.1.1.6
+++ xorg-server/dist/fb/fbscreen.c 14 Jul 2020 13:41:45 -0000
@@ -100,8 +100,10 @@ fbSetupScreen(ScreenPtr pScreen, void *p
if (!fbAllocatePrivates(pScreen))
return FALSE;
pScreen->defColormap = FakeClientID(0);
- /* let CreateDefColormap do whatever it wants for pixels */
- pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ if (bpp > 1) {
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ }
pScreen->QueryBestSize = fbQueryBestSize;
/* SaveScreen */
pScreen->GetImage = fbGetImage;
@@ -118,7 +120,11 @@ fbSetupScreen(ScreenPtr pScreen, void *p
pScreen->RealizeFont = fbRealizeFont;
pScreen->UnrealizeFont = fbUnrealizeFont;
pScreen->CreateGC = fbCreateGC;
- pScreen->CreateColormap = fbInitializeColormap;
+ if (bpp == 1) {
+ pScreen->CreateColormap = mfbCreateColormap;
+ } else {
+ pScreen->CreateColormap = fbInitializeColormap;
+ }
pScreen->DestroyColormap = (void (*)(ColormapPtr)) NoopDDA;
pScreen->InstallColormap = fbInstallColormap;
pScreen->UninstallColormap = fbUninstallColormap;
Index: xorg-server.old/dist/fb/fb.h
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server.old/dist/fb/fb.h,v
retrieving revision 1.1.1.1
diff -u -p -d -r1.1.1.1 fb.h
--- xorg-server.old/dist/fb/fb.h 9 Jun 2016 09:07:56 -0000 1.1.1.1
+++ xorg-server.old/dist/fb/fb.h 14 Jul 2020 13:41:46 -0000
@@ -1282,6 +1282,9 @@ fbResolveColor(unsigned short *pred,
extern _X_EXPORT Bool
fbInitializeColormap(ColormapPtr pmap);
+extern _X_EXPORT Bool
+mfbCreateColormap(ColormapPtr pmap);
+
extern _X_EXPORT int
fbExpandDirectColors (ColormapPtr pmap,
int ndef,
Index: xorg-server.old/dist/fb/fbcmap_mi.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server.old/dist/fb/fbcmap_mi.c,v
retrieving revision 1.1.1.1
diff -u -p -d -r1.1.1.1 fbcmap_mi.c
--- xorg-server.old/dist/fb/fbcmap_mi.c 9 Jun 2016 09:07:56 -0000 1.1.1.1
+++ xorg-server.old/dist/fb/fbcmap_mi.c 14 Jul 2020 13:41:47 -0000
@@ -69,6 +69,41 @@ fbInitializeColormap(ColormapPtr pmap)
return miInitializeColormap(pmap);
}
+Bool
+mfbCreateColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen;
+ unsigned short red0, green0, blue0;
+ unsigned short red1, green1, blue1;
+ Pixel pix;
+
+ pScreen = pmap->pScreen;
+ if (pScreen->whitePixel == 0)
+ {
+ red0 = green0 = blue0 = ~0;
+ red1 = green1 = blue1 = 0;
+ }
+ else
+ {
+ red0 = green0 = blue0 = 0;
+ red1 = green1 = blue1 = ~0;
+ }
+
+ /* this is a monochrome colormap, it only has two entries, just fill
+ * them in by hand. If it were a more complex static map, it would be
+ * worth writing a for loop or three to initialize it */
+
+ /* this will be pixel 0 */
+ pix = 0;
+ if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success)
+ return FALSE;
+
+ /* this will be pixel 1 */
+ if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success)
+ return FALSE;
+ return TRUE;
+}
+
int
fbExpandDirectColors (ColormapPtr pmap,
int ndef,
Index: xorg-server.old/dist/fb/fbscreen.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xorg-server.old/dist/fb/fbscreen.c,v
retrieving revision 1.1.1.1
diff -u -p -d -r1.1.1.1 fbscreen.c
--- xorg-server.old/dist/fb/fbscreen.c 9 Jun 2016 09:07:56 -0000 1.1.1.1
+++ xorg-server.old/dist/fb/fbscreen.c 14 Jul 2020 13:41:47 -0000
@@ -103,8 +103,10 @@ fbSetupScreen(ScreenPtr pScreen,
if (!fbAllocatePrivates(pScreen, NULL))
return FALSE;
pScreen->defColormap = FakeClientID(0);
- /* let CreateDefColormap do whatever it wants for pixels */
- pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ if (bpp > 1) {
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ }
pScreen->QueryBestSize = fbQueryBestSize;
/* SaveScreen */
pScreen->GetImage = fbGetImage;
@@ -121,7 +123,11 @@ fbSetupScreen(ScreenPtr pScreen,
pScreen->RealizeFont = fbRealizeFont;
pScreen->UnrealizeFont = fbUnrealizeFont;
pScreen->CreateGC = fbCreateGC;
- pScreen->CreateColormap = fbInitializeColormap;
+ if (bpp == 1) {
+ pScreen->CreateColormap = mfbCreateColormap;
+ } else {
+ pScreen->CreateColormap = fbInitializeColormap;
+ }
pScreen->DestroyColormap = (void (*)(ColormapPtr))NoopDDA;
pScreen->InstallColormap = fbInstallColormap;
pScreen->UninstallColormap = fbUninstallColormap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment