projects
/
xmenu
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adding the -f option
[xmenu]
/
xmenu.c
diff --git
a/xmenu.c
b/xmenu.c
index
e66ce27
..
68c8360
100644
(file)
--- a/
xmenu.c
+++ b/
xmenu.c
@@
-95,6
+95,7
@@
static Atom wmdelete;
static Atom netatom[NetLast];
/* flags */
static Atom netatom[NetLast];
/* flags */
+static int fflag = 0; /* whether glyphs should align based on the first font */
static int iflag = 0; /* whether to disable icons */
static int mflag = 0; /* whether the user specified a monitor with -p */
static int pflag = 0; /* whether the user specified a position with -p */
static int iflag = 0; /* whether to disable icons */
static int mflag = 0; /* whether the user specified a monitor with -p */
static int pflag = 0; /* whether the user specified a position with -p */
@@
-116,8
+117,11
@@
main(int argc, char *argv[])
XClassHint classh;
int ch;
XClassHint classh;
int ch;
- while ((ch = getopt(argc, argv, "ip:w")) != -1) {
+ while ((ch = getopt(argc, argv, "
f
ip:w")) != -1) {
switch (ch) {
switch (ch) {
+ case 'f':
+ fflag = 1;
+ break;
case 'i':
iflag = 1;
break;
case 'i':
iflag = 1;
break;
@@
-297,8
+301,8
@@
initmonitor(void)
if (!mflag || (mflag && (config.monitor < 0 || config.monitor >= nmons))) {
for (i = 0; i < nmons; i++) {
if (!mflag || (mflag && (config.monitor < 0 || config.monitor >= nmons))) {
for (i = 0; i < nmons; i++) {
- if (
cursx >= info[i].x_org && cursx <= info[i].x_org + info[i].width
&&
-
cursy >= info[i].y_org && cursy <= info[i].y_org + info[i].height
) {
+ if (
BETWEEN(cursx, info[i].x_org, info[i].x_org + info[i].width)
&&
+
BETWEEN(cursy, info[i].y_org, info[i].y_org + info[i].height)
) {
selmon = i;
break;
}
selmon = i;
break;
}
@@
-437,10
+441,6
@@
allocitem(const char *label, const char *output, char *file)
}
item->y = 0;
item->h = 0;
}
item->y = 0;
item->h = 0;
- if (item->label == NULL)
- item->labellen = 0;
- else
- item->labellen = strlen(item->label);
item->next = NULL;
item->submenu = NULL;
item->icon = NULL;
item->next = NULL;
item->submenu = NULL;
item->icon = NULL;
@@
-461,10
+461,10
@@
allocmenu(struct Menu *parent, struct Item *list, unsigned level)
menu->list = list;
menu->caller = NULL;
menu->selected = NULL;
menu->list = list;
menu->caller = NULL;
menu->selected = NULL;
- menu->w = 0;
/*
calculated by setupmenu() */
- menu->h = 0;
/*
calculated by setupmenu() */
- menu->x =
0; /*
calculated by setupmenu() */
- menu->y =
0; /*
calculated by setupmenu() */
+ menu->w = 0;
/* re
calculated by setupmenu() */
+ menu->h = 0;
/* re
calculated by setupmenu() */
+ menu->x =
mon.x; /* re
calculated by setupmenu() */
+ menu->y =
mon.y; /* re
calculated by setupmenu() */
menu->level = level;
menu->drawn = 0;
menu->hasicon = 0;
menu->level = level;
menu->drawn = 0;
menu->hasicon = 0;
@@
-646,6
+646,9
@@
drawtext(XftDraw *draw, XftColor *color, int x, int y, unsigned h, const char *t
FcChar32 ucode;
XftFont *currfont;
int textlen = 0;
FcChar32 ucode;
XftFont *currfont;
int textlen = 0;
+ int texty;
+
+ texty = y + (h - (dc.fonts[0]->ascent + dc.fonts[0]->descent))/2 + dc.fonts[0]->ascent;
s = text;
while (*s) {
s = text;
while (*s) {
@@
-671,9
+674,8
@@
drawtext(XftDraw *draw, XftColor *color, int x, int y, unsigned h, const char *t
textlen += ext.xOff;
if (draw) {
textlen += ext.xOff;
if (draw) {
- int texty;
-
- texty = y + (h - (currfont->ascent + currfont->descent))/2 + currfont->ascent;
+ if (!fflag)
+ texty = y + (h - (currfont->ascent + currfont->descent))/2 + currfont->ascent;
XftDrawStringUtf8(draw, color, currfont, x, texty,
(XftChar8 *)s, len);
x += ext.xOff;
XftDrawStringUtf8(draw, color, currfont, x, texty,
(XftChar8 *)s, len);
x += ext.xOff;
@@
-705,7
+707,7
@@
setupitems(struct Menu *menu)
menu->h += item->h;
if (item->label)
menu->h += item->h;
if (item->label)
- textwidth = drawtext(NULL, NULL, 0, 0,
item->h
, item->label);
+ textwidth = drawtext(NULL, NULL, 0, 0,
0
, item->label);
else
textwidth = 0;
else
textwidth = 0;
@@
-1253,6
+1255,8
@@
cleanmenu(struct Menu *menu)
static void
cleanup(void)
{
static void
cleanup(void)
{
+ size_t i;
+
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
@@
-1263,6
+1267,9
@@
cleanup(void)
XftColorFree(dpy, visual, colormap, &dc.separator);
XftColorFree(dpy, visual, colormap, &dc.border);
XftColorFree(dpy, visual, colormap, &dc.separator);
XftColorFree(dpy, visual, colormap, &dc.border);
+ for (i = 0; i < dc.nfonts; i++)
+ XftFontClose(dpy, dc.fonts[i]);
+
XFreeGC(dpy, dc.gc);
XCloseDisplay(dpy);
}
XFreeGC(dpy, dc.gc);
XCloseDisplay(dpy);
}
@@
-1271,6
+1278,6
@@
cleanup(void)
static void
usage(void)
{
static void
usage(void)
{
- (void)fprintf(stderr, "usage: xmenu [-iw] [-p position] [title]\n");
+ (void)fprintf(stderr, "usage: xmenu [-
f
iw] [-p position] [title]\n");
exit(1);
}
exit(1);
}