dmenu-xyw-5.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dmenu-xyw-5.2.diff (3157B)
---
1 --- a/dmenu.1 2022-10-04 10:36:58.000000000 -0700
2 +++ b/dmenu.1 2024-03-23 19:40:27.116453289 -0700
3 @@ -8,6 +8,12 @@
4 .IR lines ]
5 .RB [ \-m
6 .IR monitor ]
7 +.RB [ \-x
8 +.IR xoffset ]
9 +.RB [ \-y
10 +.IR yoffset ]
11 +.RB [ \-z
12 +.IR width ]
13 .RB [ \-p
14 .IR prompt ]
15 .RB [ \-fn
16 @@ -54,6 +60,24 @@
17 dmenu is displayed on the monitor number supplied. Monitor numbers are starting
18 from 0.
19 .TP
20 +.BI \-x " xoffset"
21 +dmenu is placed at this offset measured from the left side of the monitor.
22 +Can be negative.
23 +If option
24 +.B \-m
25 +is present, the measurement will use the given monitor.
26 +.TP
27 +.BI \-y " yoffset"
28 +dmenu is placed at this offset measured from the top of the monitor. If the
29 +.B \-b
30 +option is used, the offset is measured from the bottom. Can be negative.
31 +If option
32 +.B \-m
33 +is present, the measurement will use the given monitor.
34 +.TP
35 +.BI \-z " width"
36 +sets the width of the dmenu window.
37 +.TP
38 .BI \-p " prompt"
39 defines the prompt to be displayed to the left of the input field.
40 .TP
41 --- a/dmenu.c 2022-10-04 10:36:58.000000000 -0700
42 +++ b/dmenu.c 2024-03-23 19:39:53.173081139 -0700
43 @@ -37,6 +37,9 @@
44 static char text[BUFSIZ] = "";
45 static char *embed;
46 static int bh, mw, mh;
47 +static int dmx = 0; /* put dmenu at this x offset */
48 +static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
49 +static unsigned int dmw = 0; /* make dmenu this wide */
50 static int inputw = 0, promptw;
51 static int lrpad; /* sum of left and right padding */
52 static size_t cursor;
53 @@ -658,9 +661,9 @@
54 if (INTERSECT(x, y, 1, 1, info[i]) != 0)
55 break;
56
57 - x = info[i].x_org;
58 - y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
59 - mw = info[i].width;
60 + x = info[i].x_org + dmx;
61 + y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
62 + mw = (dmw>0 ? dmw : info[i].width);;
63 XFree(info);
64 } else
65 #endif
66 @@ -668,9 +671,9 @@
67 if (!XGetWindowAttributes(dpy, parentwin, &wa))
68 die("could not get embedding window attributes: 0x%lx",
69 parentwin);
70 - x = 0;
71 - y = topbar ? 0 : wa.height - mh;
72 - mw = wa.width;
73 + x = dmx;
74 + y = topbar ? dmy : wa.height - mh - dmy;
75 + mw = (dmw>0 ? dmw : wa.width);
76 }
77 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
78 inputw = mw / 3; /* input width: ~33% of monitor width */
79 @@ -711,6 +714,7 @@
80 usage(void)
81 {
82 die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
83 + " [-x xoffset] [-y yoffset] [-z width]\n"
84 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
85 }
86
87 @@ -737,6 +741,12 @@
88 /* these options take one argument */
89 else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
90 lines = atoi(argv[++i]);
91 + else if (!strcmp(argv[i], "-x")) /* window x offset */
92 + dmx = atoi(argv[++i]);
93 + else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
94 + dmy = atoi(argv[++i]);
95 + else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */
96 + dmw = atoi(argv[++i]);
97 else if (!strcmp(argv[i], "-m"))
98 mon = atoi(argv[++i]);
99 else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */