X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=b331eadebdeb2208ae77916cc2ece6a4291a07a4;hb=3959a99293785e603270d8798fbe0cb2ba0ae0ee;hp=bc17df35d4285aeaae547059e2e44d733a17024f;hpb=189a81caa11a278079fde3e610870e07870d8968;p=st.git diff --git a/st.c b/st.c index bc17df3..b331ead 100644 --- a/st.c +++ b/st.c @@ -35,7 +35,7 @@ #define USAGE \ "st-" VERSION ", (c) 2010-2011 st engineers\n" \ - "usage: st [-t title] [-c class] [-v] [-e command...]\n" + "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n" /* Arbitrary sizes */ #define ESC_TITLE_SIZ 256 @@ -260,6 +260,7 @@ static pid_t pid; static Selection sel; static char **opt_cmd = NULL; static char *opt_title = NULL; +static char *opt_embed = NULL; static char *opt_class = NULL; int @@ -483,8 +484,7 @@ selcopy(void) { void selnotify(XEvent *e) { - unsigned long nitems; - unsigned long ofs, rem; + unsigned long nitems, ofs, rem; int format; unsigned char *data; Atom type; @@ -767,7 +767,7 @@ tnew(int col, int row) { term.row = row, term.col = col; term.line = malloc(term.row * sizeof(Line)); term.alt = malloc(term.row * sizeof(Line)); - for(row = 0 ; row < term.row; row++) { + for(row = 0; row < term.row; row++) { term.line[row] = malloc(term.col * sizeof(Glyph)); term.alt [row] = malloc(term.col * sizeof(Glyph)); } @@ -1607,6 +1607,7 @@ void xinit(void) { XSetWindowAttributes attrs; Cursor cursor; + Window parent; if(!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); @@ -1637,7 +1638,8 @@ xinit(void) { | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; attrs.colormap = xw.cmap; - xw.win = XCreateWindow(xw.dpy, XRootWindow(xw.dpy, xw.scr), 0, 0, + parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr); + xw.win = XCreateWindow(xw.dpy, parent, 0, 0, xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, XDefaultVisual(xw.dpy, xw.scr), CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask @@ -1944,6 +1946,9 @@ main(int argc, char *argv[]) { case 'c': if(++i < argc) opt_class = argv[i]; break; + case 'w': + if(++i < argc) opt_embed = argv[i]; + break; case 'e': /* eat every remaining arguments */ if(++i < argc) opt_cmd = &argv[i];