Add an option to disable the active area. From Sebastien Marie.

ok claudio@ Thanks.
This commit is contained in:
matthieu 2018-09-06 07:21:34 +00:00
parent 5ee5cf05ca
commit f4445f7d08
2 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: xidle.1,v 1.4 2017/11/09 19:13:03 schwarze Exp $ .\" $OpenBSD: xidle.1,v 1.5 2018/09/06 07:21:34 matthieu Exp $
.\" .\"
.\" Copyright (c) 2005 Federico G. Schwindt. .\" Copyright (c) 2005 Federico G. Schwindt.
.\" .\"
@ -35,7 +35,7 @@
.Op Fl area Ar pixels .Op Fl area Ar pixels
.Op Fl delay Ar secs .Op Fl delay Ar secs
.Op Fl display Ar display .Op Fl display Ar display
.Op Fl nw | ne | sw | se .Op Fl no | nw | ne | sw | se
.Op Fl program Ar path .Op Fl program Ar path
.Op Fl timeout Ar secs .Op Fl timeout Ar secs
.Ek .Ek
@ -66,8 +66,8 @@ The default is 2 seconds.
.It Fl display Ar display .It Fl display Ar display
This argument allows you to specify the server to connect to; see This argument allows you to specify the server to connect to; see
.Xr X 7 . .Xr X 7 .
.It Fl nw | ne | sw | se .It Fl no | nw | ne | sw | se
Set the position to one of northwest, northeast, southwest, or southeast, Set the position to one of none, northwest, northeast, southwest, or southeast,
respectively. respectively.
If no position is specified, If no position is specified,
the default is northwest. the default is northwest.
@ -100,7 +100,9 @@ Specify the number of seconds to wait before running the program; see the
.Fl delay .Fl delay
option. option.
.It Sy position No (class Sy Position ) .It Sy position No (class Sy Position )
Set the position to one of: "nw", "ne", "sw", or "se"; see descriptions of the Set the position to one of: "no", "nw", "ne", "sw", or "se"; see descriptions
of the
.Fl no ,
.Fl nw , .Fl nw ,
.Fl ne , .Fl ne ,
.Fl sw , .Fl sw ,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xidle.c,v 1.5 2017/08/20 16:43:25 matthieu Exp $ */ /* $OpenBSD: xidle.c,v 1.6 2018/09/06 07:21:34 matthieu Exp $ */
/* /*
* Copyright (c) 2005 Federico G. Schwindt * Copyright (c) 2005 Federico G. Schwindt
* Copyright (c) 2005 Claudio Castiglia * Copyright (c) 2005 Claudio Castiglia
@ -53,7 +53,8 @@ enum {
north = 0x01, north = 0x01,
south = 0x02, south = 0x02,
east = 0x04, east = 0x04,
west = 0x08 west = 0x08,
none = 0x10,
}; };
enum { XIDLE_LOCK = 1, XIDLE_DIE = 2 }; enum { XIDLE_LOCK = 1, XIDLE_DIE = 2 };
@ -84,6 +85,7 @@ static XrmOptionDescRec opts[] = {
{ "-program", ".program", XrmoptionSepArg, (caddr_t)NULL }, { "-program", ".program", XrmoptionSepArg, (caddr_t)NULL },
{ "-timeout", ".timeout", XrmoptionSepArg, (caddr_t)NULL }, { "-timeout", ".timeout", XrmoptionSepArg, (caddr_t)NULL },
{ "-no", ".position", XrmoptionNoArg, (caddr_t)"no" },
{ "-ne", ".position", XrmoptionNoArg, (caddr_t)"ne" }, { "-ne", ".position", XrmoptionNoArg, (caddr_t)"ne" },
{ "-nw", ".position", XrmoptionNoArg, (caddr_t)"nw" }, { "-nw", ".position", XrmoptionNoArg, (caddr_t)"nw" },
{ "-se", ".position", XrmoptionNoArg, (caddr_t)"se" }, { "-se", ".position", XrmoptionNoArg, (caddr_t)"se" },
@ -108,7 +110,7 @@ usage()
{ {
fprintf(stderr, "Usage:\n%s %s\n", __progname, fprintf(stderr, "Usage:\n%s %s\n", __progname,
"[-area pixels] [-delay secs] [-display host:dpy] " "[-area pixels] [-delay secs] [-display host:dpy] "
"[-ne | -nw | -se | -sw]\n [-program path] [-timeout secs]"); "[-no | -ne | -nw | -se | -sw]\n [-program path] [-timeout secs]");
exit(1); exit(1);
} }
@ -133,12 +135,14 @@ init_x(struct xinfo *xi, int position, int area, int timeout)
xi->coord_x, xi->coord_y, area, area, 0, 0, InputOnly, xi->coord_x, xi->coord_y, area, area, 0, 0, InputOnly,
CopyFromParent, CWOverrideRedirect, &attr); CopyFromParent, CWOverrideRedirect, &attr);
XSelectInput(dpy, xi->win, EnterWindowMask|StructureNotifyMask if (position != none) {
XSelectInput(dpy, xi->win, EnterWindowMask|StructureNotifyMask
#if 0 #if 0
|VisibilityChangeMask |VisibilityChangeMask
#endif #endif
); );
XMapWindow(dpy, xi->win); XMapWindow(dpy, xi->win);
}
/* /*
* AFAICT, we need the event number for ScreenSaverNotify * AFAICT, we need the event number for ScreenSaverNotify
@ -228,6 +232,7 @@ str2pos(const char *src)
{ "nw", north|west }, { "nw", north|west },
{ "se", south|east }, { "se", south|east },
{ "sw", south|west }, { "sw", south|west },
{ "no", none },
{ NULL, 0 } { NULL, 0 }
}, *s; }, *s;