initializing IXP server in wm.c

This commit is contained in:
Anselm R. Garbe 2006-02-02 15:50:04 +02:00
parent 5d13828aa0
commit 124f39472d
4 changed files with 60 additions and 27 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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;
}