From 124f39472d1f4f44d424d120758eee54e297c2ef Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Thu, 2 Feb 2006 15:50:04 +0200 Subject: [PATCH] initializing IXP server in wm.c --- cmd/wm/fs.c | 24 +----------------------- cmd/wm/wm.c | 34 ++++++++++++++++++++++++++++++++++ cmd/wm/wm.h | 24 ++++++++++++++++++++++++ cmd/wmiibar.c | 5 +---- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c index 033a00dd..6551817f 100644 --- a/cmd/wm/fs.c +++ b/cmd/wm/fs.c @@ -61,26 +61,6 @@ * /1/1/1/ctl Fctl command interface (client) */ -/* 8-bit qid.path.type */ -enum { - Droot, - Ddefault, - Dpage, - Darea, - Dclient, - Ffont, - Fselcolor, - Fnormcolor, - Fborder, - Fsnap, - Ftitle, - Finc, - Fgeom, - Fevent, - Fctl, - Fname -}; - static char E9pversion[] = "9P version not supported"; static char Enoperm[] = "permission denied"; static char Enofid[] = "fid not assigned"; @@ -91,12 +71,10 @@ static char Enofunc[] = "function not supported"; const char *err; static unsigned char *msg[IXP_MAX_MSG]; -char *errstr = 0; -static Qid root_qid; /* IXP stuff */ -static unsigned long long +unsigned long long mkqpath(unsigned char type, unsigned short pg, unsigned short area, unsigned short cl) { return ((unsigned long long) type << 48) | ((unsigned long long) pg << 32) diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c index b320b13e..cfd08bda 100644 --- a/cmd/wm/wm.c +++ b/cmd/wm/wm.c @@ -646,6 +646,7 @@ main(int argc, char *argv[]) int i; int checkwm = 0; char *address= 0; + IXPConn *c; /* command line args */ if(argc > 1) { @@ -697,6 +698,34 @@ main(int argc, char *argv[]) XSetErrorHandler(0); x_error_handler = XSetErrorHandler(wmii_error_handler); + errstr = nil; + if(!address) + usage(); + i = ixp_create_sock(address, &errstr); + if(i < 0) { + fprintf(stderr, "wmii: fatal: %s\n", errstr); + exit(1); + } + + /* IXP server */ + c = cext_emallocz(sizeof(IXPConn)); + c->fd = i; + c->read = new_ixp_conn; + c->close = close_ixp_conn; + srv.conn = (IXPConn **)cext_array_attach((void **)srv.conn, c, + sizeof(IXPConn *), &srv.connsz); + /* X server */ + c = cext_emallocz(sizeof(IXPConn)); + c->fd = ConnectionNumber(dpy); + c->read = check_x_event; + srv.conn = (IXPConn **)cext_array_attach((void **)srv.conn, c, + sizeof(IXPConn *), &srv.connsz); + + root_qid.type = IXP_QTDIR; + root_qid.version = 0; + root_qid.path = mkqpath(Droot, 0, 0, 0); + root_qid.dir = nil; + init_event_hander(); ndet = npage = nclient = aqsz = detsz = pagesz = clientsz = sel = 0; @@ -714,6 +743,11 @@ main(int argc, char *argv[]) scan_wins(); /* main event loop */ + errstr = ixp_server_loop(&srv); + if(errstr) + fprintf(stderr, "wmii: fatal: %s\n", errstr); + + cleanup(); XCloseDisplay(dpy); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index f1c37cfc..89a32912 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -17,6 +17,26 @@ enum { NET_WM_DESKTOP /* ✗ ✗ */ }; +/* 8-bit qid.path.type */ +enum { + Droot, + Ddefault, + Dpage, + Darea, + Dclient, + Ffont, + Fselcolor, + Fnormcolor, + Fborder, + Fsnap, + Ftitle, + Finc, + Fgeom, + Fevent, + Fctl, + Fname +}; + #define NET_ATOM_COUNT 3 #define PROTO_DEL 1 @@ -97,6 +117,8 @@ XColor color_xor; GC gc_xor; GC gc_transient; IXPServer srv; +char *errstr; +static Qid root_qid; /* default values */ typedef struct { @@ -167,6 +189,8 @@ void init_event_hander(); void check_x_event(IXPServer *s, IXPConn *c); /* fs.c */ +unsigned long long mkqpath(unsigned char type, unsigned short pg, + unsigned short area, unsigned short cl); void do_pend_fcall(char *event); void new_ixp_conn(IXPServer *s, IXPConn *c); void close_ixp_conn(IXPServer *s, IXPConn *c); diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c index 623f358a..065721e5 100644 --- a/cmd/wmiibar.c +++ b/cmd/wmiibar.c @@ -71,7 +71,6 @@ static size_t itemsz = 0; static size_t iexpand = 0; static Item **item = 0; static char *address = nil; -static pid_t mypid = 0; static IXPServer srv = { 0 }; static Qid root_qid; static Display *dpy; @@ -971,8 +970,6 @@ main(int argc, char *argv[]) root_qid.path = mkqpath(Droot, 0); root_qid.dir = nil; - mypid = getpid(); - /* default settings */ new_item(); cext_strlcpy(item[0]->color, BLITZ_SEL_COLOR, sizeof(item[0]->color)); @@ -1012,7 +1009,6 @@ main(int argc, char *argv[]) draw(); errstr = ixp_server_loop(&srv); - if(errstr) fprintf(stderr, "wmiibar: fatal: %s\n", errstr); @@ -1020,6 +1016,7 @@ main(int argc, char *argv[]) for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) if(srv.conn[i]->close) srv.conn[i]->close(&srv, srv.conn[i]); + XCloseDisplay(dpy); return errstr ? 1 : 0; }