[dwm] [dmenu] [patch] [2] width/height/offsets

From: Frederik Schiewek <fs_AT_schiewek.net>
Date: Mon, 25 Aug 2008 21:00:31 +0200

--- dmenu-3.8-vlist/dmenu.c 2008-08-25 16:44:51.000000000 +0200
+++ dmenu-3.8-size/dmenu.c 2008-08-25 19:17:49.000000000 +0200
@@ -82,10 +82,16 @@
 static unsigned int numlockmask = 0;
 static unsigned int hits = 0;
 static unsigned int lines = 3;
+static unsigned int xoffset = 0;
+static unsigned int yoffset = 0;
+static unsigned int width = 0;
+static unsigned int height = 0;
+static unsigned int border = 0;
 static Bool running = True;
 static Bool topbar = True;
 static Bool vlist = False;
 static Bool hitcounter = False;
+static Bool alignright = False;
 static Display *dpy;
 static DC dc = {0};
 static Item *allitems = NULL; /* first of all items */
@@ -764,9 +770,12 @@
 
         /* update menu window geometry */
 
+ lines = height ? height / (dc.font.height + 2) : lines;
         mh = vlist ? (dc.font.height + 2) * lines : mh;
- y = topbar ? y : y - mh + (dc.font.height + 2);
-
+ y = topbar ? y + yoffset + border : y - mh + (dc.font.height + 2) - yoffset - border;
+ x = alignright ? mw - (width ? width : mw) - xoffset : xoffset + border;
+ mw = (width ? width : mw) - (border * (alignright ? 1 : 2));
+
         win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
                         DefaultDepth(dpy, screen), CopyFromParent,
                         DefaultVisual(dpy, screen),
@@ -819,6 +828,8 @@
                 }
                 else if(!strcmp(argv[i], "-b"))
                         topbar = False;
+ else if(!strcmp(argv[i], "-r"))
+ alignright = True;
                 else if(!strcmp(argv[i], "-l")) {
                         vlist = True;
                         calcoffsets = calcoffsetsv;
@@ -845,11 +856,30 @@
                 else if(!strcmp(argv[i], "-sf")) {
                         if(++i < argc) selfgcolor = argv[i];
                 }
+ else if(!strcmp(argv[i], "-w")) {
+ if(++i < argc) width = atoi(argv[i]);
+ }
+ else if(!strcmp(argv[i], "-h")) {
+ vlist = True;
+ calcoffsets = calcoffsetsv;
+ drawmenu = drawmenuv;
+ if(++i < argc) height = atoi(argv[i]);
+ }
+ else if(!strcmp(argv[i], "-bo")) {
+ if(++i < argc) border = atoi(argv[i]);
+ }
+ else if(!strcmp(argv[i], "-x")) {
+ if(++i < argc) xoffset = atoi(argv[i]);
+ }
+ else if(!strcmp(argv[i], "-y")) {
+ if(++i < argc) yoffset = atoi(argv[i]);
+ }
                 else if(!strcmp(argv[i], "-v"))
                         eprint("dmenu-"VERSION", 2006-2008 dmenu engineers, see LICENSE for details\n");
                 else
- eprint("usage: dmenu [-i] [-b] [-l <#items>] [-c] [-fn <font>] [-nb <color>]\n"
- "[-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
+ eprint("usage: dmenu [-i] [-b] [-r] [-l <#items>] [-c] [-fn <font>] [-nb <color>]\n"
+ "[-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-w <width>]\n"
+ "[-h <height>] [-bo <width>] [-x <xoffset>] [-y <yoffset>] [-v]\n");
         if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                 fprintf(stderr, "warning: no locale support\n");
         if(!(dpy = XOpenDisplay(0)))

-- 
Frederik Schiewek <fs_AT_schiewek.net>
Received on Mon Aug 25 2008 - 19:00:31 UTC

This archive was generated by hypermail 2.2.0 : Mon Aug 25 2008 - 19:24:02 UTC