chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Jun 2012 17:59:06 +0000 (18:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Jun 2012 18:10:09 +0000 (19:10 +0100)
cprogs/xacpi-simple.c

index 2a392b5..73bea7f 100644 (file)
@@ -485,6 +485,7 @@ static void initacquire(void) {
 static XrmDatabase xrm;
 static Display *disp;
 static int screen;
+static const char *parentwindow;
 
 static const char defaultresources[]=
 #define GC(g)
@@ -501,6 +502,9 @@ static const XrmOptionDescRec optiontable[]= {
   { S("-warningTime"),  S("*warningTime"),  XrmoptionSepArg },
   { S("-display"),      S("*display"),      XrmoptionSepArg },
   { S("-geometry"),     S("*geometry"),     XrmoptionSepArg },
+  { S("-into"),         S("*parentWindow"), XrmoptionSepArg },
+  { S("-icon"),         S("*icon"),         XrmoptionIsArg },
+  { S("-withdrawn"),    S("*withdrawn"),    XrmoptionIsArg },
 #define GC(g)
 #define C(c,u)                                                 \
   { S("-" #u "Color"),  S("*" #u "Color"),  XrmoptionSepArg }, \
@@ -574,6 +578,8 @@ static void parseargs(int argc, char **argv) {
   const char *alarmlevel_string= getresource("alarmLevel");
   alarmlevel = alarmlevel_string ? atoi(alarmlevel_string) : 300;
 
+  parentwindow = getresource("parentWindow");
+
   disp= XOpenDisplay(getresource("display"));
   if (!disp) fail("could not open display");
 
@@ -742,7 +748,13 @@ static void initgraphics(int argc, char **argv) {
                 &width, &height,
                 &gravity);
 
-  win= XCreateSimpleWindow(disp,DefaultRootWindow(disp),
+  unsigned long parentwindowid;
+  if (parentwindow)
+    parentwindowid = strtoul(parentwindow,0,0);
+  else
+    parentwindowid = DefaultRootWindow(disp);
+
+  win= XCreateSimpleWindow(disp,parentwindowid,
                           pos_x,pos_y,width,height,0,0,0);
   cmap= DefaultColormap(disp,screen);
   
@@ -767,6 +779,9 @@ static void initgraphics(int argc, char **argv) {
 
   wm_hints->flags= InputHint;
   wm_hints->input= False;
+  wm_hints->initial_state= (getresource("withdrawn") ? WithdrawnState :
+                           getresource("icon") ? IconicState
+                           : NormalState);
 
   class_hint->res_name= program_name_silly;
   class_hint->res_class= program_name_silly;