add -r option
This commit is contained in:
parent
ef667106e9
commit
1146fd8114
6
xmenu.1
6
xmenu.1
|
@ -3,7 +3,7 @@
|
||||||
xmenu \- menu utility for X
|
xmenu \- menu utility for X
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B xmenu
|
.B xmenu
|
||||||
.RB [ \-iw ]
|
.RB [ \-irw ]
|
||||||
.RB [ -p
|
.RB [ -p
|
||||||
.IR position ]
|
.IR position ]
|
||||||
.RI [ title ]
|
.RI [ title ]
|
||||||
|
@ -54,6 +54,10 @@ specifies that
|
||||||
.B xmenu
|
.B xmenu
|
||||||
must spawn at the position 100x500 of the monitor 0.
|
must spawn at the position 100x500 of the monitor 0.
|
||||||
.TP
|
.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
|
.B -w
|
||||||
Asks the window manager to draw a border around the menus.
|
Asks the window manager to draw a border around the menus.
|
||||||
This option may be buggy in some window managers,
|
This option may be buggy in some window managers,
|
||||||
|
|
21
xmenu.c
21
xmenu.c
|
@ -31,6 +31,7 @@ static Atom netatom[NetLast];
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
static int iflag = 0; /* whether to disable icons */
|
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 mflag = 0; /* whether the user specified a monitor with -p */
|
||||||
static int pflag = 0; /* whether the user specified a position 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 int wflag = 0; /* whether to let the window manager control XMenu */
|
||||||
|
@ -42,7 +43,7 @@ static int wflag = 0; /* whether to let the window manager control XMenu */
|
||||||
static void
|
static void
|
||||||
usage(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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,6 +1056,17 @@ itemcycle(struct Menu *currmenu, int direction)
|
||||||
return item;
|
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 */
|
/* run event loop */
|
||||||
static void
|
static void
|
||||||
run(struct Menu *currmenu)
|
run(struct Menu *currmenu)
|
||||||
|
@ -1091,6 +1103,8 @@ run(struct Menu *currmenu)
|
||||||
drawmenus(currmenu);
|
drawmenus(currmenu);
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
if (!isclickbutton(ev.xbutton.button))
|
||||||
|
break;
|
||||||
menu = getmenu(currmenu, ev.xbutton.window);
|
menu = getmenu(currmenu, ev.xbutton.window);
|
||||||
item = getitem(menu, ev.xbutton.y);
|
item = getitem(menu, ev.xbutton.y);
|
||||||
if (menu == NULL || item == NULL)
|
if (menu == NULL || item == NULL)
|
||||||
|
@ -1240,7 +1254,7 @@ main(int argc, char *argv[])
|
||||||
XClassHint classh;
|
XClassHint classh;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "ip:w")) != -1) {
|
while ((ch = getopt(argc, argv, "ip:rw")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'i':
|
case 'i':
|
||||||
iflag = 1;
|
iflag = 1;
|
||||||
|
@ -1249,6 +1263,9 @@ main(int argc, char *argv[])
|
||||||
pflag = 1;
|
pflag = 1;
|
||||||
parseposition(optarg);
|
parseposition(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
rflag = 1;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
wflag = 1;
|
wflag = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user