Re: [hackers] [tabbed] Adding a geometry flag to tabbed. || Christoph Lohmann

From: Joerg Jung <mail_AT_umaxx.net>
Date: Wed, 21 Aug 2013 00:51:05 +0200

Am 20.08.2013 um 18:47 schrieb git_AT_suckless.org:

> commit 9b007101f20b0f6cb011111486c79c34078b7b5d
> Author: Christoph Lohmann <20h_AT_r-36.net>
> Date: Tue Aug 20 18:44:00 2013 +0200
>
> Adding a geometry flag to tabbed.
>
> Thanks for the hint Thorsten Glaser!
>
> diff --git a/tabbed.1 b/tabbed.1
> index d3ef06a..c2183a5 100644
> --- a/tabbed.1
> +++ b/tabbed.1
> _AT_@ -8,6 +8,8 @@ tabbed \- generic tabbed interface
> .RB [ \-h ]
> .RB [ \-s ]
> .RB [ \-v ]
> +.RB [ \-g
> +.IR geometry ]
> .RB [ \-n
> .IR name ]
> .RB [ \-p
> _AT_@ -37,6 +39,12 @@ closed. Mutually exclusive with -c.
> .B \-h
> will print the usage of tabbed.
> .TP
> +.BI \-g " geometry"
> +defines the X11 geometry string, which will fixate the height and width of st.

...of st? This is tabbed.

Regards,
Joerg

> +Them form is [=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]. See
> +.BR XParseGeometry (3)
> +for further details.
> +.TP
> .BI \-n " name"
> will set the WM_CLASS attribute to
> .I name.
> diff --git a/tabbed.c b/tabbed.c
> index ba1df21..3df24c2 100644
> --- a/tabbed.c
> +++ b/tabbed.c
> _AT_@ -160,6 +160,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
> static char winid[64];
> static char **cmd = NULL;
> static char *wmname = "tabbed";
> +static const char *geometry = NULL;
>
> char *argv0;
>
> _AT_@ -866,6 +867,10 @@ setcmd(int argc, char *argv[], int replace) {
>
> void
> setup(void) {
> + int bitm, tx, ty, tw, th, dh, dw, isfixed;
> + XClassHint class_hint;
> + XSizeHints *size_hint;
> +
> /* clean up any zombies immediately */
> sigchld(0);
>
> _AT_@ -889,6 +894,34 @@ setup(void) {
> wy = 0;
> ww = 800;
> 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[ColFG] = getcolor(normfgcolor);
> _AT_@ -908,11 +941,23 @@ setup(void) {
> StructureNotifyMask|SubstructureRedirectMask);
> xerrorxlib = XSetErrorHandler(xerror);
>
> - XClassHint class_hint;
> class_hint.res_name = wmname;
> class_hint.res_class = "tabbed";
> 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);
>
> snprintf(winid, sizeof(winid), "%lu", win);
> _AT_@ -1105,8 +1150,8 @@ char *argv0;
>
> void
> usage(void) {
> - die("usage: %s [-dfhsv] [-n name] [-p [s+/-]pos] [-r narg]"
> - " command...
> ", argv0);
> + die("usage: %s [-dfhsv] [-g geometry] [-n name] [-p [s+/-]pos] "
> + "[-r narg] command...
> ", argv0);
> }
>
> int
> _AT_@ -1125,6 +1170,9 @@ main(int argc, char *argv[]) {
> case 'f':
> fillagain = True;
> break;
> + case 'g':
> + geometry = EARGF(usage());
> + break;
> case 'n':
> wmname = EARGF(usage());
> break;
>
>
Received on Wed Aug 21 2013 - 00:51:05 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 21 2013 - 01:00:18 CEST