projects
/
xmenu
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
257e42c
)
Reordering stuff, removing unused variables
author
phillbush
<phillbush@cock.li>
Wed, 27 May 2020 17:34:55 +0000
(14:34 -0300)
committer
phillbush
<phillbush@cock.li>
Wed, 27 May 2020 17:34:55 +0000
(14:34 -0300)
xmenu.c
patch
|
blob
|
blame
|
history
diff --git
a/xmenu.c
b/xmenu.c
index
c6c693e
..
116f31d
100644
(file)
--- a/
xmenu.c
+++ b/
xmenu.c
@@
-91,11
+91,11
@@
static void cleanup(struct Menu *rootmenu);
static void usage(void);
/* global variables (X stuff and geometries) */
static void usage(void);
/* global variables (X stuff and geometries) */
-static Colormap colormap;
static Display *dpy;
static Display *dpy;
+static int screen;
static Visual *visual;
static Window rootwin;
static Visual *visual;
static Window rootwin;
-static
int screen
;
+static
Colormap colormap
;
static struct DC dc;
static struct Geometry geom;
static struct DC dc;
static struct Geometry geom;
@@
-117,6
+117,9
@@
main(int argc, char *argv[])
argc -= optind;
argv += optind;
argc -= optind;
argv += optind;
+ if (argc != 0)
+ usage();
+
/* open connection to server and set X variables */
if ((dpy = XOpenDisplay(NULL)) == NULL)
errx(1, "cannot open display");
/* open connection to server and set X variables */
if ((dpy = XOpenDisplay(NULL)) == NULL)
errx(1, "cannot open display");
@@
-305,16
+308,15
@@
allocmenu(struct Menu *parent, struct Item *list, unsigned level)
static struct Menu *
parsestdin(void)
{
static struct Menu *
parsestdin(void)
{
- struct Menu *rootmenu;
char *s, buf[BUFSIZ];
char *label, *output;
unsigned level = 0;
unsigned i;
struct Item *curritem = NULL; /* item currently being read */
struct Menu *prevmenu = NULL; /* menu the previous item was added to */
char *s, buf[BUFSIZ];
char *label, *output;
unsigned level = 0;
unsigned i;
struct Item *curritem = NULL; /* item currently being read */
struct Menu *prevmenu = NULL; /* menu the previous item was added to */
- struct Item *item; /* dummy item for
for
loops */
- struct Menu *menu; /* dummy menu for
for
loops */
- s
ize_t count = 0; /* number of items in the current menu
*/
+ struct Item *item; /* dummy item for loops */
+ struct Menu *menu; /* dummy menu for loops */
+ s
truct Menu *rootmenu; /* menu to be returned
*/
rootmenu = NULL;
rootmenu = NULL;
@@
-350,7
+352,6
@@
parsestdin(void)
menu = allocmenu(NULL, curritem, level);
rootmenu = menu;
prevmenu = menu;
menu = allocmenu(NULL, curritem, level);
rootmenu = menu;
prevmenu = menu;
- count = 1;
curritem->prev = NULL;
curritem->next = NULL;
} else if (level < prevmenu->level) { /* item is continuation of a parent menu*/
curritem->prev = NULL;
curritem->next = NULL;
} else if (level < prevmenu->level) { /* item is continuation of a parent menu*/
@@
-393,7
+394,6
@@
parsestdin(void)
prevmenu = menu;
}
prevmenu = menu;
}
- count++;
}
return rootmenu;
}
return rootmenu;
@@
-729,20
+729,18
@@
run(struct Menu *currmenu)
case MotionNotify:
menu = getmenu(currmenu, ev.xbutton.window);
item = getitem(menu, ev.xbutton.y);
case MotionNotify:
menu = getmenu(currmenu, ev.xbutton.window);
item = getitem(menu, ev.xbutton.y);
- if (menu == NULL || item == NULL)
+ if (menu == NULL || item == NULL
|| previtem == item
)
break;
break;
- if (previtem != item) {
- previtem = item;
- menu->selected = item;
- if (item->submenu != NULL) {
- currmenu = item->submenu;
- currmenu->selected = NULL;
- } else {
- currmenu = menu;
- }
- mapmenu(currmenu);
- drawmenu(currmenu);
+ previtem = item;
+ menu->selected = item;
+ if (item->submenu != NULL) {
+ currmenu = item->submenu;
+ currmenu->selected = NULL;
+ } else {
+ currmenu = menu;
}
}
+ mapmenu(currmenu);
+ drawmenu(currmenu);
break;
case ButtonRelease:
menu = getmenu(currmenu, ev.xbutton.window);
break;
case ButtonRelease:
menu = getmenu(currmenu, ev.xbutton.window);
@@
-846,6
+844,6
@@
cleanup(struct Menu *rootmenu)
static void
usage(void)
{
static void
usage(void)
{
- (void)fprintf(stderr, "usage: xmenu
title...
\n");
+ (void)fprintf(stderr, "usage: xmenu\n");
exit(1);
}
exit(1);
}