xmenu \- menu utility for X
.SH SYNOPSIS
.B xmenu
-.RB [ \-iw ]
+.RB [ \-irw ]
.RB [ -p
.IR position ]
.RI [ title ]
.B xmenu
must spawn at the position 100x500 of the monitor 0.
.TP
+.B -r
+If this option is set, the right mouse button is disabled;
+so pressing it will not trigger any menu item.
+.TP
.B -w
Asks the window manager to draw a border around the menus.
This option may be buggy in some window managers,
/* flags */
static int iflag = 0; /* whether to disable icons */
+static int rflag = 0; /* whether to disable right-click */
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 wflag = 0; /* whether to let the window manager control XMenu */
static void
usage(void)
{
- (void)fprintf(stderr, "usage: xmenu [-iw] [-p position] [title]\n");
+ (void)fprintf(stderr, "usage: xmenu [-irw] [-p position] [title]\n");
exit(1);
}
return item;
}
+/* check if button is used to open a item on click */
+static int
+isclickbutton(unsigned int button)
+{
+ if (button == Button1)
+ return 1;
+ if (!rflag && button == Button3)
+ return 1;
+ return 0;
+}
+
/* run event loop */
static void
run(struct Menu *currmenu)
drawmenus(currmenu);
break;
case ButtonRelease:
+ if (!isclickbutton(ev.xbutton.button))
+ break;
menu = getmenu(currmenu, ev.xbutton.window);
item = getitem(menu, ev.xbutton.y);
if (menu == NULL || item == NULL)
XClassHint classh;
int ch;
- while ((ch = getopt(argc, argv, "ip:w")) != -1) {
+ while ((ch = getopt(argc, argv, "ip:rw")) != -1) {
switch (ch) {
case 'i':
iflag = 1;
pflag = 1;
parseposition(optarg);
break;
+ case 'r':
+ rflag = 1;
+ break;
case 'w':
wflag = 1;
break;