resizing vlist, new dinput binding 7afd296c
Connor Lane Smith · 2010-06-30 00:52 1 file(s) · +16 −18
dmenu.c +16 −18
109 109
	next = prev = curr;
110 110
	for(i = 0; i < lines && next; i++)
111 111
		next = next->right;
112 +
	mh = (dc.font.height + 2) * (i + 1);
112 113
	for(i = 0; i < lines && prev && prev->left; i++)
113 114
		prev = prev->left;
114 115
}
166 167
	dc.w = mw;
167 168
	dc.h = mh;
168 169
	drawtext(&dc, NULL, normcol, False);
170 +
	dc.h = dc.font.height + 2;
171 +
	dc.y = topbar ? 0 : mh - dc.h;
169 172
	/* print prompt? */
170 173
	if(prompt) {
171 174
		dc.w = promptw;
177 180
	if(cmdw && item && lines == 0)
178 181
		dc.w = cmdw;
179 182
	drawtext(&dc, *text ? text : NULL, normcol, False);
180 -
	if(curr) {
181 -
		if(lines > 0)
182 -
			drawmenuv();
183 -
		else
184 -
			drawmenuh();
185 -
	}
183 +
	if(lines > 0)
184 +
		drawmenuv();
185 +
	else
186 +
		drawmenuh();
186 187
	XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
187 188
	XFlush(dpy);
188 189
}
193 194
194 195
	dc.x += cmdw;
195 196
	dc.w = spaceitem;
196 -
	drawtext(&dc, curr->left ? "<" : NULL, normcol, False);
197 +
	drawtext(&dc, curr && curr->left ? "<" : NULL, normcol, False);
197 198
	dc.x += dc.w;
198 199
	for(i = curr; i != next; i = i->right) {
199 200
		dc.w = MIN(textw(&dc, i->text), mw / 3);
208 209
void
209 210
drawmenuv(void) {
210 211
	Item *i;
212 +
	XWindowAttributes wa;
211 213
214 +
	dc.y = topbar ? dc.h : 0;
212 215
	dc.w = mw - dc.x;
213 -
	dc.h = dc.font.height + 2;
214 -
	dc.y = dc.h;
215 216
	for(i = curr; i != next; i = i->right) {
216 217
		drawtext(&dc, i->text, (sel == i) ? selcol : normcol, False);
217 218
		dc.y += dc.h;
218 219
	}
219 -
	dc.h = mh - dc.y;
220 -
	drawtext(&dc, NULL, normcol, False);
220 +
	if(!XGetWindowAttributes(dpy, win, &wa))
221 +
		eprint("cannot get window attributes");
222 +
	XMoveResizeWindow(dpy, win, wa.x, wa.y + (topbar ? 0 : wa.height - mh), mw, mh);
221 223
}
222 224
223 225
Bool
299 301
			text[++i] = '\0';
300 302
			match(text);
301 303
			break;
302 -
		case XK_x:
303 -
			dinput();
304 -
			break;
305 304
		}
306 305
	}
307 306
	switch(ksym) {
360 359
		calcoffsets();
361 360
		break;
362 361
	case XK_Return:
363 -
		if((e->state & ShiftMask) || !sel)
364 -
			fprintf(stdout, "%s", text);
365 -
		else
366 -
			fprintf(stdout, "%s", sel->text);
362 +
		if(e->state & ShiftMask)
363 +
			dinput();
364 +
		fprintf(stdout, "%s", sel ? sel->text : text);
367 365
		fflush(stdout);
368 366
		running = False;
369 367
		return;