Add support for user-level 9P servers/clients and various bug fixes to go with them.
This commit is contained in:
parent
ac244f8d28
commit
32f69c36e0
60 changed files with 965 additions and 485 deletions
|
|
@ -9,21 +9,15 @@ openfont(Display *d, char *name)
|
|||
{
|
||||
Font *fnt;
|
||||
int fd, i, n;
|
||||
char *buf, *nambuf, *root;
|
||||
char *buf, *nambuf;
|
||||
|
||||
nambuf = 0;
|
||||
fd = open(name, OREAD);
|
||||
|
||||
if(fd < 0 && strncmp(name, "/lib/font/bit/", 14) == 0){
|
||||
root = getenv("PLAN9");
|
||||
if(root == nil)
|
||||
return 0;
|
||||
nambuf = malloc(strlen(root)+5+strlen(name+13)+1);
|
||||
nambuf = smprint("#9/font/%s", name+14);
|
||||
if(nambuf == nil)
|
||||
return 0;
|
||||
strcpy(nambuf, root);
|
||||
strcat(nambuf, "/font");
|
||||
strcat(nambuf, name+13);
|
||||
if((fd = open(nambuf, OREAD)) < 0){
|
||||
free(nambuf);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* Allocate a Memimage with an optional pixmap backing on the X server.
|
||||
*/
|
||||
Memimage*
|
||||
xallocmemimage(Rectangle r, u32int chan, int pixmap)
|
||||
_xallocmemimage(Rectangle r, u32int chan, int pixmap)
|
||||
{
|
||||
int d, offset;
|
||||
Memimage *m;
|
||||
|
|
@ -95,7 +95,7 @@ xallocmemimage(Rectangle r, u32int chan, int pixmap)
|
|||
Memimage*
|
||||
allocmemimage(Rectangle r, u32int chan)
|
||||
{
|
||||
return xallocmemimage(r, chan, PMundef);
|
||||
return _xallocmemimage(r, chan, PMundef);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
|
|||
|
||||
n = _cloadmemimage(i, r, data, ndata);
|
||||
if(n > 0 && i->X)
|
||||
xputxdata(i, r);
|
||||
_xputxdata(i, r);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp,
|
|||
|
||||
/* only fetch dst data if we need it */
|
||||
if((par->state&(Simplemask|Fullmask)) != (Simplemask|Fullmask))
|
||||
xgetxdata(dst, par->r);
|
||||
_xgetxdata(dst, par->r);
|
||||
|
||||
/* always fetch source and mask */
|
||||
xgetxdata(src, par->sr);
|
||||
xgetxdata(mask, par->mr);
|
||||
_xgetxdata(src, par->sr);
|
||||
_xgetxdata(mask, par->mr);
|
||||
|
||||
/* now can run memimagedraw on the in-memory bits */
|
||||
_memimagedraw(par);
|
||||
|
|
@ -37,7 +37,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp,
|
|||
return;
|
||||
|
||||
/* put bits back on x server */
|
||||
xputxdata(dst, par->r);
|
||||
_xputxdata(dst, par->r);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -66,7 +66,7 @@ xdraw(Memdrawparam *par)
|
|||
*/
|
||||
m = Simplesrc|Simplemask|Fullmask;
|
||||
if((state&m) == m){
|
||||
xfillcolor(dst, r, par->sdval);
|
||||
_xfillcolor(dst, r, par->sdval);
|
||||
// xdirtyxdata(dst, r);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ eread(ulong keys, Event *e)
|
|||
xmask |= MouseMask|StructureNotifyMask;
|
||||
if(keys&Ekeyboard){
|
||||
xmask |= KeyPressMask;
|
||||
if((r = xtoplan9kbd(nil)) >= 0){
|
||||
if((r = _xtoplan9kbd(nil)) >= 0){
|
||||
e->kbdc = r;
|
||||
return Ekeyboard;
|
||||
}
|
||||
|
|
@ -60,24 +60,24 @@ again:
|
|||
|
||||
switch(xevent.type){
|
||||
case Expose:
|
||||
xexpose(&xevent, _x.display);
|
||||
_xexpose(&xevent, _x.display);
|
||||
goto again;
|
||||
case DestroyNotify:
|
||||
if(xdestroy(&xevent, _x.display))
|
||||
if(_xdestroy(&xevent, _x.display))
|
||||
postnote(PNGROUP, getpgrp(), "hangup");
|
||||
goto again;
|
||||
case ConfigureNotify:
|
||||
if(xconfigure(&xevent, _x.display))
|
||||
if(_xconfigure(&xevent, _x.display))
|
||||
eresized(1);
|
||||
goto again;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
if(xtoplan9mouse(_x.display, &xevent, &e->mouse) < 0)
|
||||
if(_xtoplan9mouse(_x.display, &xevent, &e->mouse) < 0)
|
||||
goto again;
|
||||
return Emouse;
|
||||
case KeyPress:
|
||||
e->kbdc = xtoplan9kbd(&xevent);
|
||||
e->kbdc = _xtoplan9kbd(&xevent);
|
||||
if(e->kbdc == -1)
|
||||
goto again;
|
||||
return Ekeyboard;
|
||||
|
|
@ -136,7 +136,7 @@ ecanmouse(void)
|
|||
eflush();
|
||||
again:
|
||||
if(XCheckWindowEvent(_x.display, _x.drawable, MouseMask, &xe)){
|
||||
if(xtoplan9mouse(_x.display, &xe, &m) < 0)
|
||||
if(_xtoplan9mouse(_x.display, &xe, &m) < 0)
|
||||
goto again;
|
||||
XPutBackEvent(_x.display, &xe);
|
||||
return 1;
|
||||
|
|
@ -151,13 +151,13 @@ ecankbd(void)
|
|||
int r;
|
||||
|
||||
eflush();
|
||||
if((r = xtoplan9kbd(nil)) >= 0){
|
||||
xtoplan9kbd((XEvent*)-1);
|
||||
if((r = _xtoplan9kbd(nil)) >= 0){
|
||||
_xtoplan9kbd((XEvent*)-1);
|
||||
return 1;
|
||||
}
|
||||
again:
|
||||
if(XCheckWindowEvent(_x.display, _x.drawable, KeyPressMask, &xe)){
|
||||
if(xtoplan9kbd(&xe) == -1)
|
||||
if(_xtoplan9kbd(&xe) == -1)
|
||||
goto again;
|
||||
XPutBackEvent(_x.display, &xe);
|
||||
return 1;
|
||||
|
|
@ -168,12 +168,12 @@ again:
|
|||
void
|
||||
emoveto(Point p)
|
||||
{
|
||||
xmoveto(p);
|
||||
_xmoveto(p);
|
||||
}
|
||||
|
||||
void
|
||||
esetcursor(Cursor *c)
|
||||
{
|
||||
xsetcursor(c);
|
||||
_xsetcursor(c);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ memfillcolor(Memimage *m, u32int val)
|
|||
if(m->X == nil)
|
||||
return;
|
||||
if((val & 0xFF) == 0xFF) /* full alpha */
|
||||
xfillcolor(m, m->r, _rgbatoimg(m, val));
|
||||
_xfillcolor(m, m->r, _rgbatoimg(m, val));
|
||||
else
|
||||
xputxdata(m, m->r);
|
||||
_xputxdata(m, m->r);
|
||||
}
|
||||
|
||||
void
|
||||
xfillcolor(Memimage *m, Rectangle r, u32int v)
|
||||
_xfillcolor(Memimage *m, Rectangle r, u32int v)
|
||||
{
|
||||
Point p;
|
||||
Xmem *xm;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ addrect(Rectangle *rp, Rectangle r)
|
|||
}
|
||||
|
||||
XImage*
|
||||
xgetxdata(Memimage *m, Rectangle r)
|
||||
_xgetxdata(Memimage *m, Rectangle r)
|
||||
{
|
||||
int x, y;
|
||||
uchar *p;
|
||||
|
|
@ -55,7 +55,7 @@ xgetxdata(Memimage *m, Rectangle r)
|
|||
}
|
||||
|
||||
void
|
||||
xputxdata(Memimage *m, Rectangle r)
|
||||
_xputxdata(Memimage *m, Rectangle r)
|
||||
{
|
||||
int offset, x, y;
|
||||
uchar *p;
|
||||
|
|
@ -97,7 +97,7 @@ xputxdata(Memimage *m, Rectangle r)
|
|||
}
|
||||
|
||||
void
|
||||
xdirtyxdata(Memimage *m, Rectangle r)
|
||||
_xdirtyxdata(Memimage *m, Rectangle r)
|
||||
{
|
||||
Xmem *xm;
|
||||
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ xattach(char *label)
|
|||
_x.screenr = r;
|
||||
_x.screenpm = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth);
|
||||
_x.nextscreenpm = _x.screenpm;
|
||||
_x.screenimage = xallocmemimage(r, _x.chan, _x.screenpm);
|
||||
_x.screenimage = _xallocmemimage(r, _x.chan, _x.screenpm);
|
||||
|
||||
/*
|
||||
* Allocate some useful graphics contexts for the future.
|
||||
|
|
@ -651,7 +651,7 @@ flushmemscreen(Rectangle r)
|
|||
}
|
||||
|
||||
void
|
||||
xexpose(XEvent *e, XDisplay *xd)
|
||||
_xexpose(XEvent *e, XDisplay *xd)
|
||||
{
|
||||
XExposeEvent *xe;
|
||||
Rectangle r;
|
||||
|
|
@ -673,7 +673,7 @@ xexpose(XEvent *e, XDisplay *xd)
|
|||
}
|
||||
|
||||
int
|
||||
xdestroy(XEvent *e, XDisplay *xd)
|
||||
_xdestroy(XEvent *e, XDisplay *xd)
|
||||
{
|
||||
XDestroyWindowEvent *xe;
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ xdestroy(XEvent *e, XDisplay *xd)
|
|||
}
|
||||
|
||||
int
|
||||
xconfigure(XEvent *e, XDisplay *xd)
|
||||
_xconfigure(XEvent *e, XDisplay *xd)
|
||||
{
|
||||
Rectangle r;
|
||||
XConfigureEvent *xe = (XConfigureEvent*)e;
|
||||
|
|
@ -719,7 +719,7 @@ xreplacescreenimage(void)
|
|||
return 0;
|
||||
|
||||
pixmap = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth);
|
||||
m = xallocmemimage(r, _x.chan, pixmap);
|
||||
m = _xallocmemimage(r, _x.chan, pixmap);
|
||||
if(_x.nextscreenpm != _x.screenpm)
|
||||
XFreePixmap(_x.display, _x.nextscreenpm);
|
||||
_x.nextscreenpm = pixmap;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "x11-memdraw.h"
|
||||
|
||||
static int
|
||||
_xtoplan9kbd(XEvent *e)
|
||||
__xtoplan9kbd(XEvent *e)
|
||||
{
|
||||
int ind, k, md;
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ xtoplan9latin1(XEvent *e)
|
|||
int n;
|
||||
int r;
|
||||
|
||||
r = _xtoplan9kbd(e);
|
||||
r = __xtoplan9kbd(e);
|
||||
if(r < 0)
|
||||
return nil;
|
||||
if(alting){
|
||||
|
|
@ -156,7 +156,7 @@ xtoplan9latin1(XEvent *e)
|
|||
}
|
||||
|
||||
int
|
||||
xtoplan9kbd(XEvent *e)
|
||||
_xtoplan9kbd(XEvent *e)
|
||||
{
|
||||
static Rune *r;
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ xtoplan9kbd(XEvent *e)
|
|||
}
|
||||
|
||||
int
|
||||
xtoplan9mouse(XDisplay *xd, XEvent *e, Mouse *m)
|
||||
_xtoplan9mouse(XDisplay *xd, XEvent *e, Mouse *m)
|
||||
{
|
||||
int s;
|
||||
XButtonEvent *be;
|
||||
|
|
@ -260,7 +260,7 @@ xtoplan9mouse(XDisplay *xd, XEvent *e, Mouse *m)
|
|||
}
|
||||
|
||||
void
|
||||
xmoveto(Point p)
|
||||
_xmoveto(Point p)
|
||||
{
|
||||
XWarpPointer(_x.display, None, _x.drawable, 0, 0, 0, 0, p.x, p.y);
|
||||
XFlush(_x.display);
|
||||
|
|
@ -296,7 +296,7 @@ xcursorarrow(void)
|
|||
|
||||
|
||||
void
|
||||
xsetcursor(Cursor *c)
|
||||
_xsetcursor(Cursor *c)
|
||||
{
|
||||
XColor fg, bg;
|
||||
XCursor xc;
|
||||
|
|
@ -335,7 +335,7 @@ struct {
|
|||
} clip;
|
||||
|
||||
char*
|
||||
xgetsnarf(XDisplay *xd)
|
||||
_xgetsnarf(XDisplay *xd)
|
||||
{
|
||||
uchar *data, *xdata;
|
||||
Atom clipboard, type, prop;
|
||||
|
|
@ -420,7 +420,7 @@ out:
|
|||
}
|
||||
|
||||
void
|
||||
xputsnarf(XDisplay *xd, char *data)
|
||||
_xputsnarf(XDisplay *xd, char *data)
|
||||
{
|
||||
XButtonEvent e;
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ xputsnarf(XDisplay *xd, char *data)
|
|||
}
|
||||
|
||||
int
|
||||
xselect(XEvent *e, XDisplay *xd)
|
||||
_xselect(XEvent *e, XDisplay *xd)
|
||||
{
|
||||
char *name;
|
||||
XEvent r;
|
||||
|
|
@ -493,12 +493,12 @@ if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d\n",
|
|||
void
|
||||
putsnarf(char *data)
|
||||
{
|
||||
xputsnarf(_x.snarfcon, data);
|
||||
_xputsnarf(_x.snarfcon, data);
|
||||
}
|
||||
|
||||
char*
|
||||
getsnarf(void)
|
||||
{
|
||||
return xgetsnarf(_x.snarfcon);
|
||||
return _xgetsnarf(_x.snarfcon);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ _ioproc(void *arg)
|
|||
XWindowEvent(_x.kbdcon, _x.drawable, KeyPressMask, &xevent);
|
||||
switch(xevent.type){
|
||||
case KeyPress:
|
||||
i = xtoplan9kbd(&xevent);
|
||||
i = _xtoplan9kbd(&xevent);
|
||||
if(i == -1)
|
||||
continue;
|
||||
r = i;
|
||||
send(kc->c, &r);
|
||||
while((i=xtoplan9kbd(nil)) >= 0){
|
||||
while((i=_xtoplan9kbd(nil)) >= 0){
|
||||
r = i;
|
||||
send(kc->c, &r);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
|
|||
|
||||
n = _loadmemimage(i, r, data, ndata);
|
||||
if(n > 0 && i->X)
|
||||
xputxdata(i, r);
|
||||
_xputxdata(i, r);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,26 +76,26 @@ struct Xprivate {
|
|||
|
||||
extern Xprivate _x;
|
||||
|
||||
extern Memimage *xallocmemimage(Rectangle, u32int, int);
|
||||
extern XImage *xallocxdata(Memimage*, Rectangle);
|
||||
extern void xdirtyxdata(Memimage*, Rectangle);
|
||||
extern void xfillcolor(Memimage*, Rectangle, u32int);
|
||||
extern void xfreexdata(Memimage*);
|
||||
extern XImage *xgetxdata(Memimage*, Rectangle);
|
||||
extern void xputxdata(Memimage*, Rectangle);
|
||||
extern Memimage *_xallocmemimage(Rectangle, u32int, int);
|
||||
extern XImage *_xallocxdata(Memimage*, Rectangle);
|
||||
extern void _xdirtyxdata(Memimage*, Rectangle);
|
||||
extern void _xfillcolor(Memimage*, Rectangle, u32int);
|
||||
extern void _xfreexdata(Memimage*);
|
||||
extern XImage *_xgetxdata(Memimage*, Rectangle);
|
||||
extern void _xputxdata(Memimage*, Rectangle);
|
||||
extern void _initdisplaymemimage(Display*, Memimage*);
|
||||
|
||||
struct Mouse;
|
||||
extern int xtoplan9mouse(XDisplay*, XEvent*, struct Mouse*);
|
||||
extern int xtoplan9kbd(XEvent*);
|
||||
extern void xexpose(XEvent*, XDisplay*);
|
||||
extern int xselect(XEvent*, XDisplay*);
|
||||
extern int xconfigure(XEvent*, XDisplay*);
|
||||
extern int xdestroy(XEvent*, XDisplay*);
|
||||
extern void flushmemscreen(Rectangle);
|
||||
extern void xmoveto(Point);
|
||||
extern int _xtoplan9mouse(XDisplay*, XEvent*, struct Mouse*);
|
||||
extern int _xtoplan9kbd(XEvent*);
|
||||
extern void _xexpose(XEvent*, XDisplay*);
|
||||
extern int _xselect(XEvent*, XDisplay*);
|
||||
extern int _xconfigure(XEvent*, XDisplay*);
|
||||
extern int _xdestroy(XEvent*, XDisplay*);
|
||||
extern void _flushmemscreen(Rectangle);
|
||||
extern void _xmoveto(Point);
|
||||
struct Cursor;
|
||||
extern void xsetcursor(struct Cursor*);
|
||||
extern void _xsetcursor(struct Cursor*);
|
||||
|
||||
#define MouseMask (\
|
||||
ButtonPressMask|\
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
void
|
||||
moveto(Mousectl *m, Point pt)
|
||||
{
|
||||
xmoveto(pt);
|
||||
_xmoveto(pt);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -64,10 +64,10 @@ _ioproc(void *arg)
|
|||
XNextEvent(_x.mousecon, &xevent);
|
||||
switch(xevent.type){
|
||||
case Expose:
|
||||
xexpose(&xevent, _x.mousecon);
|
||||
_xexpose(&xevent, _x.mousecon);
|
||||
continue;
|
||||
case DestroyNotify:
|
||||
if(xdestroy(&xevent, _x.mousecon)){
|
||||
if(_xdestroy(&xevent, _x.mousecon)){
|
||||
/* drain it before sending */
|
||||
/* apps that care can notice we sent a 0 */
|
||||
/* otherwise we'll have getwindow send SIGHUP */
|
||||
|
|
@ -77,16 +77,16 @@ _ioproc(void *arg)
|
|||
}
|
||||
continue;
|
||||
case ConfigureNotify:
|
||||
if(xconfigure(&xevent, _x.mousecon))
|
||||
if(_xconfigure(&xevent, _x.mousecon))
|
||||
nbsend(mc->resizec, &one);
|
||||
continue;
|
||||
case SelectionRequest:
|
||||
xselect(&xevent, _x.mousecon);
|
||||
_xselect(&xevent, _x.mousecon);
|
||||
continue;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
if(xtoplan9mouse(_x.mousecon, &xevent, &m) < 0)
|
||||
if(_xtoplan9mouse(_x.mousecon, &xevent, &m) < 0)
|
||||
continue;
|
||||
send(mc->c, &m);
|
||||
/*
|
||||
|
|
@ -117,6 +117,6 @@ initmouse(char *file, Image *i)
|
|||
void
|
||||
setcursor(Mousectl *mc, Cursor *c)
|
||||
{
|
||||
xsetcursor(c);
|
||||
_xsetcursor(c);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ u32int
|
|||
pixelbits(Memimage *m, Point p)
|
||||
{
|
||||
if(m->X)
|
||||
xgetxdata(m, Rect(p.x, p.y, p.x+1, p.y+1));
|
||||
_xgetxdata(m, Rect(p.x, p.y, p.x+1, p.y+1));
|
||||
return _pixelbits(m, p);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ int
|
|||
unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
|
||||
{
|
||||
if(i->X)
|
||||
xgetxdata(i, r);
|
||||
_xgetxdata(i, r);
|
||||
return _unloadmemimage(i, r, data, ndata);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue