hlfw.ca

x9dev

Download patch

ref: 35f2249ec0b11b0c7cac2babce3423e72000733b
parent: 9ca93993f8bfaa24c83a5ea78cb973eeef67d11f
author: halfwit <michaelmisch1985@gmail.com>
date: Sat Oct 10 05:23:48 PDT 2020

Collisions with Xorg-xserver

--- a/libdraw/draw.h
+++ b/libdraw/draw.h
@@ -2,7 +2,7 @@
 typedef struct	Cacheinfo Cacheinfo;
 typedef struct	Cachesubf Cachesubf;
 typedef struct	Display Display;
-typedef struct	Font Font;
+typedef struct	_Font _Font;
 typedef struct	Fontchar Fontchar;
 typedef struct	Image Image;
 typedef struct	Mouse Mouse;
@@ -16,6 +16,7 @@
 typedef unsigned char uchar;
 typedef unsigned short ushort;
 typedef unsigned int Rune;
+typedef void* nil;
 
 enum
 {
@@ -198,7 +199,7 @@
 	uchar		*buf;
 	int			bufsize;
 	uchar		*bufp;
-	Font		*defaultfont;
+	_Font		*defaultfont;
 	Subfont		*defaultsubfont;
 	Image		*windows;
 	Image		*screenimage;
@@ -299,7 +300,7 @@
 	Subfont		*f;		/* attached subfont */
 };
 
-struct Font
+struct _Font
 {
 	char		*name;
 	Display		*display;
@@ -419,23 +420,23 @@
 extern void	polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
 extern void	fillpoly(Image*, Point*, int, int, Image*, Point);
 extern void	fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);
-extern Point	string(Image*, Point, Image*, Point, Font*, char*);
-extern Point	stringop(Image*, Point, Image*, Point, Font*, char*, Drawop);
-extern Point	stringn(Image*, Point, Image*, Point, Font*, char*, int);
-extern Point	stringnop(Image*, Point, Image*, Point, Font*, char*, int, Drawop);
-extern Point	runestring(Image*, Point, Image*, Point, Font*, Rune*);
-extern Point	runestringop(Image*, Point, Image*, Point, Font*, Rune*, Drawop);
-extern Point	runestringn(Image*, Point, Image*, Point, Font*, Rune*, int);
-extern Point	runestringnop(Image*, Point, Image*, Point, Font*, Rune*, int, Drawop);
-extern Point	stringbg(Image*, Point, Image*, Point, Font*, char*, Image*, Point);
-extern Point	stringbgop(Image*, Point, Image*, Point, Font*, char*, Image*, Point, Drawop);
-extern Point	stringnbg(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point);
-extern Point	stringnbgop(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point, Drawop);
-extern Point	runestringbg(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point);
-extern Point	runestringbgop(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point, Drawop);
-extern Point	runestringnbg(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point);
-extern Point	runestringnbgop(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point, Drawop);
-extern Point	_string(Image*, Point, Image*, Point, Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
+extern Point	string(Image*, Point, Image*, Point, _Font*, char*);
+extern Point	stringop(Image*, Point, Image*, Point, _Font*, char*, Drawop);
+extern Point	stringn(Image*, Point, Image*, Point, _Font*, char*, int);
+extern Point	stringnop(Image*, Point, Image*, Point, _Font*, char*, int, Drawop);
+extern Point	runestring(Image*, Point, Image*, Point, _Font*, Rune*);
+extern Point	runestringop(Image*, Point, Image*, Point, _Font*, Rune*, Drawop);
+extern Point	runestringn(Image*, Point, Image*, Point, _Font*, Rune*, int);
+extern Point	runestringnop(Image*, Point, Image*, Point, _Font*, Rune*, int, Drawop);
+extern Point	stringbg(Image*, Point, Image*, Point, _Font*, char*, Image*, Point);
+extern Point	stringbgop(Image*, Point, Image*, Point, _Font*, char*, Image*, Point, Drawop);
+extern Point	stringnbg(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point);
+extern Point	stringnbgop(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point, Drawop);
+extern Point	runestringbg(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point);
+extern Point	runestringbgop(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point, Drawop);
+extern Point	runestringnbg(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point);
+extern Point	runestringnbgop(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point, Drawop);
+extern Point	_string(Image*, Point, Image*, Point, _Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
 extern Point	stringsubfont(Image*, Point, Image*, Subfont*, char*);
 extern int		bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
 extern int		bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
@@ -460,12 +461,12 @@
 /*
  * Font management
  */
-extern Font*	openfont(Display*, char*);
-extern Font*	buildfont(Display*, char*, char*);
-extern void	freefont(Font*);
-extern Font*	mkfont(Subfont*, Rune);
-extern int	cachechars(Font*, char**, Rune**, ushort*, int, int*, char**);
-extern void	agefont(Font*);
+extern _Font*	openfont(Display*, char*);
+extern _Font*	buildfont(Display*, char*, char*);
+extern void	freefont(_Font*);
+extern _Font*	mkfont(Subfont*, Rune);
+extern int	cachechars(_Font*, char**, Rune**, ushort*, int, int*, char**);
+extern void	agefont(_Font*);
 extern Subfont*	allocsubfont(char*, int, int, int, Fontchar*, Image*);
 extern Subfont*	lookupsubfont(Display*, char*);
 extern void	installsubfont(char*, Subfont*);
@@ -475,14 +476,14 @@
 extern Subfont*	readsubfonti(Display*, char*, int, Image*, int);
 extern int	writesubfont(int, Subfont*);
 extern void	_unpackinfo(Fontchar*, uchar*, int);
-extern Point	stringsize(Font*, char*);
-extern int	stringwidth(Font*, char*);
-extern int	stringnwidth(Font*, char*, int);
-extern Point	runestringsize(Font*, Rune*);
-extern int	runestringwidth(Font*, Rune*);
-extern int	runestringnwidth(Font*, Rune*, int);
+extern Point	stringsize(_Font*, char*);
+extern int	stringwidth(_Font*, char*);
+extern int	stringnwidth(_Font*, char*, int);
+extern Point	runestringsize(_Font*, Rune*);
+extern int	runestringwidth(_Font*, Rune*);
+extern int	runestringnwidth(_Font*, Rune*, int);
 extern Point	strsubfontwidth(Subfont*, char*);
-extern int	loadchar(Font*, Rune, Cacheinfo*, int, int, char**);
+extern int	loadchar(_Font*, Rune, Cacheinfo*, int, int, char**);
 extern char*	subfontname(char*, char*, int);
 extern Subfont*	_getsubfont(Display*, char*);
 extern Subfont*	getdefont(Display*);
@@ -500,8 +501,8 @@
 /*
  * Set up by initdraw()
  */
-extern	Display	*display;
-extern	Font		*font;
+extern	Display	*_display; /* opaque.h defines display */
+extern	_Font		*font;
 extern	Image	*screen;
 extern	Screen	*_screen;
 extern	int	_cursorfd;
--- a/meson.build
+++ b/meson.build
@@ -19,7 +19,7 @@
     link_with: [
         c9,
         libdraw,
-        libxserver_mi
+        libxserver_mi,
         libxserver_main,
         libxserver_fb,
         libxserver,
--- a/screen.c
+++ b/screen.c
@@ -51,7 +51,7 @@
     }
 
 End:
-    flushimage(display, 1);
+    flushimage(_display, 1);
 }
 
 
@@ -58,10 +58,10 @@
 static void
 x9devResize(void)
 {
-    if (getwindow(display, Refnone) < 0)
+    if (getwindow(_display, Refnone) < 0)
         FatalError("can't reattach to window");
 
-    draw(screen, screen->r, display->white, nil, ZP);
+    draw(screen, screen->r, _display->white, nil, ZP);
     x9devRefreshScreen(0, 0, x9di.width, x9di.height);
 }
 
--- a/x9dev.h
+++ b/x9dev.h
@@ -104,7 +104,6 @@
 DeviceIntPtr x9devMouse;
 DeviceIntPtr x9devKeybd;
 x9devInfo x9di;
-Screen *screen;
 
 /* Callbacks, etc */
 Bool x9checkmod(unsigned int, DeviceIntPtr);