aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2011-06-08 21:35:58 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2011-06-08 21:35:58 +0200
commit4259a3ba3a99da4bc551c9cde6868366fb2c01fa (patch)
treee906e58aa8338ad307f318368fe6d602cc805240
parentfb32d01a183979b3235740aaea555bfe94759dab (diff)
downloadst-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.tar.bz2
st-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.tar.xz
st-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.zip
add -w option to embed st. (thx nodus cursorius)
-rw-r--r--st.16
-rw-r--r--st.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/st.1 b/st.1
index 69cfe86..b6c119f 100644
--- a/st.1
+++ b/st.1
@@ -7,6 +7,8 @@ st \- simple terminal
7.IR class ] 7.IR class ]
8.RB [ \-t 8.RB [ \-t
9.IR title ] 9.IR title ]
10.RB [ \-w
11.IR windowid ]
10.RB [ \-v ] 12.RB [ \-v ]
11.RB [ \-e 13.RB [ \-e
12.IR command ...] 14.IR command ...]
@@ -21,6 +23,10 @@ defines the window title (default 'st').
21.BI \-c " class" 23.BI \-c " class"
22defines the window class (default $TERM). 24defines the window class (default $TERM).
23.TP 25.TP
26.BI \-w " windowid"
27embeds st within the window identified by
28.I windowid
29.TP
24.B \-v 30.B \-v
25prints version information to stderr, then exits. 31prints version information to stderr, then exits.
26.TP 32.TP
diff --git a/st.c b/st.c
index 6ba5c4c..b331ead 100644
--- a/st.c
+++ b/st.c
@@ -35,7 +35,7 @@
35 35
36#define USAGE \ 36#define USAGE \
37 "st-" VERSION ", (c) 2010-2011 st engineers\n" \ 37 "st-" VERSION ", (c) 2010-2011 st engineers\n" \
38 "usage: st [-t title] [-c class] [-v] [-e command...]\n" 38 "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n"
39 39
40/* Arbitrary sizes */ 40/* Arbitrary sizes */
41#define ESC_TITLE_SIZ 256 41#define ESC_TITLE_SIZ 256
@@ -260,6 +260,7 @@ static pid_t pid;
260static Selection sel; 260static Selection sel;
261static char **opt_cmd = NULL; 261static char **opt_cmd = NULL;
262static char *opt_title = NULL; 262static char *opt_title = NULL;
263static char *opt_embed = NULL;
263static char *opt_class = NULL; 264static char *opt_class = NULL;
264 265
265int 266int
@@ -1606,6 +1607,7 @@ void
1606xinit(void) { 1607xinit(void) {
1607 XSetWindowAttributes attrs; 1608 XSetWindowAttributes attrs;
1608 Cursor cursor; 1609 Cursor cursor;
1610 Window parent;
1609 1611
1610 if(!(xw.dpy = XOpenDisplay(NULL))) 1612 if(!(xw.dpy = XOpenDisplay(NULL)))
1611 die("Can't open display\n"); 1613 die("Can't open display\n");
@@ -1636,7 +1638,8 @@ xinit(void) {
1636 | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; 1638 | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
1637 attrs.colormap = xw.cmap; 1639 attrs.colormap = xw.cmap;
1638 1640
1639 xw.win = XCreateWindow(xw.dpy, XRootWindow(xw.dpy, xw.scr), 0, 0, 1641 parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
1642 xw.win = XCreateWindow(xw.dpy, parent, 0, 0,
1640 xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, 1643 xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
1641 XDefaultVisual(xw.dpy, xw.scr), 1644 XDefaultVisual(xw.dpy, xw.scr),
1642 CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask 1645 CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
@@ -1943,6 +1946,9 @@ main(int argc, char *argv[]) {
1943 case 'c': 1946 case 'c':
1944 if(++i < argc) opt_class = argv[i]; 1947 if(++i < argc) opt_class = argv[i];
1945 break; 1948 break;
1949 case 'w':
1950 if(++i < argc) opt_embed = argv[i];
1951 break;
1946 case 'e': 1952 case 'e':
1947 /* eat every remaining arguments */ 1953 /* eat every remaining arguments */
1948 if(++i < argc) opt_cmd = &argv[i]; 1954 if(++i < argc) opt_cmd = &argv[i];