diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | ui.c | 18 |
2 files changed, 12 insertions, 8 deletions
@@ -1,7 +1,7 @@ EXE = xmenu OBJ != find . -name '*.c' | sed -e 's/\.c$$/.o/' -e 's|^\./||' -CFLAGS += -Wall -Wpedantic -I/usr/X11R7/include -O0 -g +CFLAGS += -Wall -Wpedantic -I/usr/X11R7/include LDFLAGS += -lX11 -lxcb -lXt -lXau -lXdmcp -L/usr/X11R7/lib -static PREFIX ?= ${HOME} @@ -56,7 +56,6 @@ ui_init(int argc, char **argv, UiOpts opt) XSetForeground(dsp, gc, fg); XSelectInput(dsp, win, KeyPressMask | ExposureMask); - XMapRaised(dsp, win); wm_delete_window = XInternAtom(dsp, "WM_DELETE_WINDOW", False); XSetWMProtocols(dsp, win, &wm_delete_window, 1); @@ -76,11 +75,13 @@ ui_init(int argc, char **argv, UiOpts opt) if (w > scr_width - 2*margin) w = scr_width - 2*margin; if (h > scr_height - 2*margin) h = scr_height - 2*margin; - XMoveResizeWindow(dsp, win, + XResizeWindow(dsp, win, w + 32, h + 32); + XSetTransientForHint(dsp, win, DefaultRootWindow(dsp)); + XMoveWindow(dsp, win, (scr_width - w - 32) / 2, - (scr_height - h - 32) / 2, - w + 32, h + 32 + (scr_height - h - 32) / 2 ); + XMapRaised(dsp, win); } UiKey @@ -156,21 +157,24 @@ ui_draw(Str input, int inpi, int seli, UiOpts o) /* draw options */ XSetFont(dsp, gc, freg->fid); + int y = 64; for (int i = 0; i < o.n; i++) { if (i == seli) { int w = XTextWidth(freg, o.v[i].s, o.v[i].n); XFillRectangle(dsp, win, gc, - 16, 28 + i * 24 + 8, w, 24); + 16, y - freg->ascent, + w, freg->descent + freg->ascent); XSetForeground(dsp, gc, bg); XDrawString(dsp, win, gc, - 16, 48 + i * 24 + 8, + 16, y, o.v[i].s, o.v[i].n); XSetForeground(dsp, gc, fg); } else { XDrawString(dsp, win, gc, - 16, 48 + i * 24 + 8, + 16, y, o.v[i].s, o.v[i].n); } + y += 24; } } |
