dmenu-xyw-5.0.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dmenu-xyw-5.0.diff (3621B) | |
--- | |
1 From 7dc7cb96cdda9ad66e33109223c4cc297a7721d1 Mon Sep 17 00:00:00 2001 | |
2 From: Alex Cole <[email protected]> | |
3 Date: Tue, 6 Oct 2020 10:42:07 +1300 | |
4 Subject: [PATCH] Updated xyw for 5.0 properly | |
5 | |
6 --- | |
7 dmenu.1 | 24 ++++++++++++++++++++++++ | |
8 dmenu.c | 22 ++++++++++++++++------ | |
9 2 files changed, 40 insertions(+), 6 deletions(-) | |
10 | |
11 diff --git a/dmenu.1 b/dmenu.1 | |
12 index 323f93c..a4ecbbb 100644 | |
13 --- a/dmenu.1 | |
14 +++ b/dmenu.1 | |
15 @@ -8,6 +8,12 @@ dmenu \- dynamic menu | |
16 .IR lines ] | |
17 .RB [ \-m | |
18 .IR monitor ] | |
19 +.RB [ \-x | |
20 +.IR xoffset ] | |
21 +.RB [ \-y | |
22 +.IR yoffset ] | |
23 +.RB [ \-z | |
24 +.IR width ] | |
25 .RB [ \-p | |
26 .IR prompt ] | |
27 .RB [ \-fn | |
28 @@ -54,6 +60,24 @@ dmenu lists items vertically, with the given number o… | |
29 dmenu is displayed on the monitor number supplied. Monitor numbers are … | |
30 from 0. | |
31 .TP | |
32 +.BI \-x " xoffset" | |
33 +dmenu is placed at this offset measured from the left side of the monit… | |
34 +Can be negative. | |
35 +If option | |
36 +.B \-m | |
37 +is present, the measurement will use the given monitor. | |
38 +.TP | |
39 +.BI \-y " yoffset" | |
40 +dmenu is placed at this offset measured from the top of the monitor. I… | |
41 +.B \-b | |
42 +option is used, the offset is measured from the bottom. Can be negativ… | |
43 +If option | |
44 +.B \-m | |
45 +is present, the measurement will use the given monitor. | |
46 +.TP | |
47 +.BI \-z " width" | |
48 +sets the width of the dmenu window. | |
49 +.TP | |
50 .BI \-p " prompt" | |
51 defines the prompt to be displayed to the left of the input field. | |
52 .TP | |
53 diff --git a/dmenu.c b/dmenu.c | |
54 index 65f25ce..7be19ae 100644 | |
55 --- a/dmenu.c | |
56 +++ b/dmenu.c | |
57 @@ -37,6 +37,9 @@ struct item { | |
58 static char text[BUFSIZ] = ""; | |
59 static char *embed; | |
60 static int bh, mw, mh; | |
61 +static int dmx = 0; /* put dmenu at this x offset */ | |
62 +static int dmy = 0; /* put dmenu at this y offset (measured from the bo… | |
63 +static unsigned int dmw = 0; /* make dmenu this wide */ | |
64 static int inputw = 0, promptw; | |
65 static int lrpad; /* sum of left and right padding */ | |
66 static size_t cursor; | |
67 @@ -637,9 +640,9 @@ setup(void) | |
68 if (INTERSECT(x, y, 1, 1, info[i])) | |
69 break; | |
70 | |
71 - x = info[i].x_org; | |
72 - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); | |
73 - mw = info[i].width; | |
74 + x = info[i].x_org + dmx; | |
75 + y = info[i].y_org + (topbar ? dmy : info[i].height - mh… | |
76 + mw = (dmw>0 ? dmw : info[i].width); | |
77 XFree(info); | |
78 } else | |
79 #endif | |
80 @@ -647,9 +650,9 @@ setup(void) | |
81 if (!XGetWindowAttributes(dpy, parentwin, &wa)) | |
82 die("could not get embedding window attributes:… | |
83 parentwin); | |
84 - x = 0; | |
85 - y = topbar ? 0 : wa.height - mh; | |
86 - mw = wa.width; | |
87 + x = dmx; | |
88 + y = topbar ? dmy : wa.height - mh - dmy; | |
89 + mw = (dmw>0 ? dmw : wa.width); | |
90 } | |
91 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; | |
92 inputw = MIN(inputw, mw/3); | |
93 @@ -690,6 +693,7 @@ static void | |
94 usage(void) | |
95 { | |
96 fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [… | |
97 + " [-x xoffset] [-y yoffset] [-z width]\n" | |
98 " [-nb color] [-nf color] [-sb color] [-sf co… | |
99 exit(1); | |
100 } | |
101 @@ -717,6 +721,12 @@ main(int argc, char *argv[]) | |
102 /* these options take one argument */ | |
103 else if (!strcmp(argv[i], "-l")) /* number of lines i… | |
104 lines = atoi(argv[++i]); | |
105 + else if (!strcmp(argv[i], "-x")) /* window x offset */ | |
106 + dmx = atoi(argv[++i]); | |
107 + else if (!strcmp(argv[i], "-y")) /* window y offset (… | |
108 + dmy = atoi(argv[++i]); | |
109 + else if (!strcmp(argv[i], "-z")) /* make dmenu this w… | |
110 + dmw = atoi(argv[++i]); | |
111 else if (!strcmp(argv[i], "-m")) | |
112 mon = atoi(argv[++i]); | |
113 else if (!strcmp(argv[i], "-p")) /* adds prompt to le… | |
114 -- | |
115 2.28.0 | |
116 |