X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Fxacpi-simple.c;h=4adbfc12f91bb8da75b608756b25408de4cae6b9;hp=d18624f0bca51b00158766277eb3297266c20009;hb=7b71d538a8df1c6440641909947fa9bf89612fa4;hpb=004f87de1499fa37d381633dab590558257596bf diff --git a/cprogs/xacpi-simple.c b/cprogs/xacpi-simple.c index d18624f..4adbfc1 100644 --- a/cprogs/xacpi-simple.c +++ b/cprogs/xacpi-simple.c @@ -327,6 +327,8 @@ static void initacquire(void) { GC(empty) static XrmDatabase xrm; +static Display *disp; +static int screen; static const char defaultresources[]= #define GC(g) @@ -350,19 +352,6 @@ static const XrmOptionDescRec optiontable[]= { #undef C }; -static void parseargs(int argc, char **argv) { - XrmInitialize(); - - xrm= XrmGetStringDatabase((char*)defaultresources); - if (!xrm) fail("xrmgetstringdatabase"); - - XrmParseCommand(&xrm, (XrmOptionDescRec*)optiontable, - sizeof(optiontable)/sizeof(*optiontable), - program_name, &argc, argv); - - /* if (argc>0) badusage();*/ -} - static const char *getresource(const char *want) { char name_buf[256], class_buf[256]; XrmValue val; @@ -379,13 +368,44 @@ static const char *getresource(const char *want) { return val.addr; } +static void more_resources(const char *str, const char *why) { + XrmDatabase more; + + if (!str) return; + + more= XrmGetStringDatabase((char*)str); + if (!more) fail(why); + XrmCombineDatabase(more,&xrm,0); +} + +static void parseargs(int argc, char **argv) { + Screen *screenscreen; + + XrmInitialize(); + + XrmParseCommand(&xrm, (XrmOptionDescRec*)optiontable, + sizeof(optiontable)/sizeof(*optiontable), + program_name, &argc, argv); + + if (argc>1) badusage(); + + disp= XOpenDisplay(getresource("display")); + if (!disp) fail("could not open display"); + + screen= DefaultScreen(disp); + + screenscreen= ScreenOfDisplay(disp,screen); + if (!screenscreen) fail("screenofdisplay"); + more_resources(XScreenResourceString(screenscreen), "screen resources"); + more_resources(XResourceManagerString(disp), "display resources"); + more_resources(defaultresources, "default resources"); +} + /*---------- display ----------*/ -static Display *disp; static Window win; static int width, height; static Colormap cmap; -static int screen; static unsigned long lastbackground; typedef struct { @@ -510,7 +530,7 @@ static void colour(unsigned long *pix_r, const char *whichcolour) { } static void initgraphics(int argc, char **argv) { - int r; + int xwmgr, r; const char *geom_string; XSizeHints *normal_hints; XWMHints *wm_hints; @@ -520,11 +540,6 @@ static void initgraphics(int argc, char **argv) { program_name_silly= (char*)program_name; - disp= XOpenDisplay(getresource("display")); - if (!disp) fail("could not open display"); - - screen= DefaultScreen(disp); - normal_hints= XAllocSizeHints(); wm_hints= XAllocWMHints(); class_hint= XAllocClassHint(); @@ -534,7 +549,7 @@ static void initgraphics(int argc, char **argv) { geom_string= getresource("geometry"); - r= XWMGeometry(disp,screen, geom_string,"128x32", 0, + xwmgr= XWMGeometry(disp,screen, geom_string,"128x32", 0, normal_hints, &pos_x, &pos_y, &width, &height, @@ -560,7 +575,8 @@ static void initgraphics(int argc, char **argv) { normal_hints->y= pos_y; normal_hints->width= width; normal_hints->height= height; - if (geom_string) normal_hints->flags |= USPosition; + if ((xwmgr & XValue) || (xwmgr & YValue)) + normal_hints->flags |= USPosition; wm_hints->flags= InputHint; wm_hints->input= False;