[dwm] Re: PATCH: -x and -w options for dmenu (Xinerama)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Mon, 2 Apr 2007 09:31:31 +0200

On Sun, Apr 01, 2007 at 08:19:16PM -0600, Jason Creighton wrote:
> Attached is a patch to give dmenu -x and -w options to specify the x
> position and width of dmenu, respectively. The useful application of
> this is for Xinerama-aware window mangers (namely, xmonad) to launch
> dmenu only on the current screen. (There may be other uses, but that's
> why I wrote it.)
>
> I thought about adding corresponding -y and -h options, but they raise
> lots of issues: If the WM is trying to place dmenu at the bottom of an
> Xinerama screen, and -x and -y specify the top-left corner of dmenu, the
> WM would have to know the height as well. and if both -b and -y are
> given, which one wins? In the end, it seemed easiest to have y-offset
> and height chosen entirely by dmenu and let -b break on Xinerama.
>
> Jason Creighton

Hmm, I'm not convinced about this change. That sounds a little
bit too hackish... letting -b break and so on, hmmm.

What about adding xinerama support directly with an option -xN?
If present this option will grab the correct Xinerama
information and setup dmenu for the specific screen N only.
That seems better to me... however, I'm not sure if it would be
worth to add this support to dmenu - simply because both, dwm
and dmenu aren't intended as Xinerama-capable - I prefer the old
way of running them in a multihead-setup... one instance per
screen (dmenu is invoked correctly anyways, depending on the
screen which is selected).

> diff -ur dmenu-2.8-orig/dmenu.1 dmenu-2.8/dmenu.1
> --- dmenu-2.8-orig/dmenu.1 2007-03-07 05:30:51.000000000 -0700
> +++ dmenu-2.8/dmenu.1 2007-03-31 12:54:37.000000000 -0600
> @@ -10,6 +10,8 @@
> .RB [ \-p " <prompt>"]
> .RB [ \-sb " <color>"]
> .RB [ \-sf " <color>"]
> +.RB [ \-x " <offset"]
> +.RB [ \-w " <size>"]
> .RB [ \-v ]
> .SH DESCRIPTION
> .SS Overview
> @@ -40,6 +42,12 @@
> .B \-sf <color>
> defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
> .TP
> +.B \-x <offset>
> +makes dmenu appear at the given X offset. (by default this is 0).
> +.TP
> +.B \-w <size>
> +defines demnu's width. (by default this is the width of the screen).
> +.TP
> .B \-v
> prints version information to standard output, then exits.
> .SH USAGE
> diff -ur dmenu-2.8-orig/main.c dmenu-2.8/main.c
> --- dmenu-2.8-orig/main.c 2007-03-07 05:30:51.000000000 -0700
> +++ dmenu-2.8/main.c 2007-03-31 11:34:50.000000000 -0600
> @@ -422,10 +422,12 @@
> char *selbg = SELBGCOLOR;
> char *selfg = SELFGCOLOR;
> int i, j;
> + int xoffset = 0;
> Item *itm;
> XEvent ev;
> XModifierKeymap *modmap;
> XSetWindowAttributes wa;
> + mw = 0;
>
> /* command line args */
> for(i = 1; i < argc; i++)
> @@ -450,6 +452,12 @@
> else if(!strncmp(argv[i], "-sf", 4)) {
> if(++i < argc) selfg = argv[i];
> }
> + else if(!strncmp(argv[i], "-x", 3)) {
> + if(++i < argc) xoffset = atoi(argv[i]);
> + }
> + else if(!strncmp(argv[i], "-w", 3)) {
> + if(++i < argc) mw = atoi(argv[i]);
> + }
> else if(!strncmp(argv[i], "-v", 3))
> eprint("dmenu-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n");
> else
> @@ -488,9 +496,10 @@
> wa.override_redirect = 1;
> wa.background_pixmap = ParentRelative;
> wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
> - mw = DisplayWidth(dpy, screen);
> + if(mw == 0)
> + mw = DisplayWidth(dpy, screen);
> mh = dc.font.height + 2;
> - win = XCreateWindow(dpy, root, 0,
> + win = XCreateWindow(dpy, root, xoffset,
> bottom ? DisplayHeight(dpy, screen) - mh : 0, mw, mh, 0,
> DefaultDepth(dpy, screen), CopyFromParent,
> DefaultVisual(dpy, screen),

Regards,

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
Received on Mon Apr 02 2007 - 09:31:31 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:40:12 UTC