Adding a geometry flag to tabbed.
Thanks for the hint Thorsten Glaser!
This commit is contained in:
parent
97ce0f717a
commit
9b007101f2
8
tabbed.1
8
tabbed.1
@ -8,6 +8,8 @@ tabbed \- generic tabbed interface
|
|||||||
.RB [ \-h ]
|
.RB [ \-h ]
|
||||||
.RB [ \-s ]
|
.RB [ \-s ]
|
||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
|
.RB [ \-g
|
||||||
|
.IR geometry ]
|
||||||
.RB [ \-n
|
.RB [ \-n
|
||||||
.IR name ]
|
.IR name ]
|
||||||
.RB [ \-p
|
.RB [ \-p
|
||||||
@ -37,6 +39,12 @@ closed. Mutually exclusive with -c.
|
|||||||
.B \-h
|
.B \-h
|
||||||
will print the usage of tabbed.
|
will print the usage of tabbed.
|
||||||
.TP
|
.TP
|
||||||
|
.BI \-g " geometry"
|
||||||
|
defines the X11 geometry string, which will fixate the height and width of st.
|
||||||
|
Them form is [=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]. See
|
||||||
|
.BR XParseGeometry (3)
|
||||||
|
for further details.
|
||||||
|
.TP
|
||||||
.BI \-n " name"
|
.BI \-n " name"
|
||||||
will set the WM_CLASS attribute to
|
will set the WM_CLASS attribute to
|
||||||
.I name.
|
.I name.
|
||||||
|
54
tabbed.c
54
tabbed.c
@ -160,6 +160,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
|
|||||||
static char winid[64];
|
static char winid[64];
|
||||||
static char **cmd = NULL;
|
static char **cmd = NULL;
|
||||||
static char *wmname = "tabbed";
|
static char *wmname = "tabbed";
|
||||||
|
static const char *geometry = NULL;
|
||||||
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
|
|
||||||
@ -866,6 +867,10 @@ setcmd(int argc, char *argv[], int replace) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
setup(void) {
|
setup(void) {
|
||||||
|
int bitm, tx, ty, tw, th, dh, dw, isfixed;
|
||||||
|
XClassHint class_hint;
|
||||||
|
XSizeHints *size_hint;
|
||||||
|
|
||||||
/* clean up any zombies immediately */
|
/* clean up any zombies immediately */
|
||||||
sigchld(0);
|
sigchld(0);
|
||||||
|
|
||||||
@ -889,6 +894,34 @@ setup(void) {
|
|||||||
wy = 0;
|
wy = 0;
|
||||||
ww = 800;
|
ww = 800;
|
||||||
wh = 600;
|
wh = 600;
|
||||||
|
isfixed = 0;
|
||||||
|
|
||||||
|
if(geometry) {
|
||||||
|
tx = ty = tw = th = 0;
|
||||||
|
bitm = XParseGeometry(geometry, &tx, &ty, (unsigned *)&tw,
|
||||||
|
(unsigned *)&th);
|
||||||
|
if(bitm & XValue)
|
||||||
|
wx = tx;
|
||||||
|
if(bitm & YValue)
|
||||||
|
wy = ty;
|
||||||
|
if(bitm & WidthValue)
|
||||||
|
ww = tw;
|
||||||
|
if(bitm & HeightValue)
|
||||||
|
wh = th;
|
||||||
|
if(bitm & XNegative && wx == 0)
|
||||||
|
wx = -1;
|
||||||
|
if(bitm & YNegative && wy == 0)
|
||||||
|
wy = -1;
|
||||||
|
if(bitm & (HeightValue|WidthValue))
|
||||||
|
isfixed = 1;
|
||||||
|
|
||||||
|
dw = DisplayWidth(dpy, screen);
|
||||||
|
dh = DisplayHeight(dpy, screen);
|
||||||
|
if(wx < 0)
|
||||||
|
wx = dw + wx - ww - 1;
|
||||||
|
if(wy < 0)
|
||||||
|
wy = dh + wy - wh - 1;
|
||||||
|
}
|
||||||
|
|
||||||
dc.norm[ColBG] = getcolor(normbgcolor);
|
dc.norm[ColBG] = getcolor(normbgcolor);
|
||||||
dc.norm[ColFG] = getcolor(normfgcolor);
|
dc.norm[ColFG] = getcolor(normfgcolor);
|
||||||
@ -908,11 +941,23 @@ setup(void) {
|
|||||||
StructureNotifyMask|SubstructureRedirectMask);
|
StructureNotifyMask|SubstructureRedirectMask);
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
xerrorxlib = XSetErrorHandler(xerror);
|
||||||
|
|
||||||
XClassHint class_hint;
|
|
||||||
class_hint.res_name = wmname;
|
class_hint.res_name = wmname;
|
||||||
class_hint.res_class = "tabbed";
|
class_hint.res_class = "tabbed";
|
||||||
XSetClassHint(dpy, win, &class_hint);
|
XSetClassHint(dpy, win, &class_hint);
|
||||||
|
|
||||||
|
size_hint = XAllocSizeHints();
|
||||||
|
if(!isfixed) {
|
||||||
|
size_hint->flags = PSize;
|
||||||
|
size_hint->height = wh;
|
||||||
|
size_hint->width = ww;
|
||||||
|
} else {
|
||||||
|
size_hint->flags = PMaxSize | PMinSize;
|
||||||
|
size_hint->min_width = size_hint->max_width = ww;
|
||||||
|
size_hint->min_height = size_hint->max_height = wh;
|
||||||
|
}
|
||||||
|
XSetWMProperties(dpy, win, NULL, NULL, NULL, 0, size_hint, NULL, NULL);
|
||||||
|
XFree(size_hint);
|
||||||
|
|
||||||
XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1);
|
XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1);
|
||||||
|
|
||||||
snprintf(winid, sizeof(winid), "%lu", win);
|
snprintf(winid, sizeof(winid), "%lu", win);
|
||||||
@ -1105,8 +1150,8 @@ char *argv0;
|
|||||||
|
|
||||||
void
|
void
|
||||||
usage(void) {
|
usage(void) {
|
||||||
die("usage: %s [-dfhsv] [-n name] [-p [s+/-]pos] [-r narg]"
|
die("usage: %s [-dfhsv] [-g geometry] [-n name] [-p [s+/-]pos] "
|
||||||
" command...\n", argv0);
|
"[-r narg] command...\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1125,6 +1170,9 @@ main(int argc, char *argv[]) {
|
|||||||
case 'f':
|
case 'f':
|
||||||
fillagain = True;
|
fillagain = True;
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
geometry = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
wmname = EARGF(usage());
|
wmname = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user