aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-02-01 05:17:32 -0500
committerB. Watson <urchlay@slackware.uk>2024-02-01 05:17:32 -0500
commit74b0ae43c1eb2b0a263a3d7d09d0f92d4ce98ca5 (patch)
treece7c5f871f9e10151b6922b9cd77b168dbf5727e
parent2bd88c14e52a8c1e96b8ef2a7e4f5ba990b59019 (diff)
downloadxdeadzone-74b0ae43c1eb2b0a263a3d7d09d0f92d4ce98ca5.tar.gz
Enforce "only one mode argument" rule.
-rw-r--r--xdeadzone.119
-rw-r--r--xdeadzone.c10
-rw-r--r--xdeadzone.rst19
3 files changed, 30 insertions, 18 deletions
diff --git a/xdeadzone.1 b/xdeadzone.1
index 582ce08..3981861 100644
--- a/xdeadzone.1
+++ b/xdeadzone.1
@@ -46,18 +46,19 @@ position, and prevent the mouse pointer from entering it.
.sp
The intended use for it is to keep the mouse out of the "dead zone"
of a multi\-head X display where the monitors don\(aqt all have the same
-resolution. When used for this purpose, there will be no visible
-\fBxdeadzone\fP window (if there is, you\(aqve got the size and/or position
-wrong).
+resolution.
.sp
It could also be useful for covering annoying parts of the screen,
e.g. advertisements in ad\-driven software like the Opera browser, or
-Adobe Reader. Use \fB\-abs\fP (absolute positioning) mode for this.
-.sp
-When \fBxdeadzone\fP is running in a visible part of the screen, it\(aqll
-appear as a solid white rectangle with no title bar or window frame;
-it\(aqll stay on top of other windows; and it will appear on every
-virtual desktop.
+Adobe Reader. Use \fB\-abs\fP (absolute positioning) mode for this,
+and either \fB\-b\fP or \fB\-w\fP to make the window visible.
+.sp
+By default, \fBxdeadzone\fP doesn\(aqt display a visible window. It stays
+on top of other windows, and is present on every virtual desktop.
+If run with \fB\-b\fP or \fB\-w\fP, it\(aqll appear as a solid black or white
+rectangle with no title bar or window frame... although if you\(aqre
+using it to block the mouse from a dead zone, you won\(aqt be able to see
+it anyway.
.sp
\fBxdeadzone\fP has been tested with various window managers and desktop
environments, and works properly with at least: KDE (Plasma 5), XFCE
diff --git a/xdeadzone.c b/xdeadzone.c
index 5b89c94..b05a2ac 100644
--- a/xdeadzone.c
+++ b/xdeadzone.c
@@ -58,6 +58,11 @@ void errmsg(const char *msg) {
usage(1);
}
+void check_mode(int mode) {
+ if(mode != M_UNSET)
+ errmsg("multiple modes given, only one of -abs -ne -nw -se -sw is allowed");
+}
+
int streq(const char *s1, const char *s2) {
return !strcmp(s1, s2);
}
@@ -93,14 +98,19 @@ int main(int argc, char **argv) {
} else if(streq(a, "-i")) {
visible = 0;
} else if(streq(a, "-abs")) {
+ check_mode(mode);
mode = M_ABS;
} else if(streq(a, "-ne")) {
+ check_mode(mode);
mode = M_NE;
} else if(streq(a, "-nw")) {
+ check_mode(mode);
mode = M_NW;
} else if(streq(a, "-se")) {
+ check_mode(mode);
mode = M_SE;
} else if(streq(a, "-sw")) {
+ check_mode(mode);
mode = M_SW;
} else if(a[0] == '-') {
fprintf(stderr, "%s: invalid option: %s (try --help)\n", exe_name, a);
diff --git a/xdeadzone.rst b/xdeadzone.rst
index f0476e1..5b39f46 100644
--- a/xdeadzone.rst
+++ b/xdeadzone.rst
@@ -32,18 +32,19 @@ position, and prevent the mouse pointer from entering it.
The intended use for it is to keep the mouse out of the "dead zone"
of a multi-head X display where the monitors don't all have the same
-resolution. When used for this purpose, there will be no visible
-**xdeadzone** window (if there is, you've got the size and/or position
-wrong).
+resolution.
It could also be useful for covering annoying parts of the screen,
e.g. advertisements in ad-driven software like the Opera browser, or
-Adobe Reader. Use **-abs** (absolute positioning) mode for this.
-
-When **xdeadzone** is running in a visible part of the screen, it'll
-appear as a solid white rectangle with no title bar or window frame;
-it'll stay on top of other windows; and it will appear on every
-virtual desktop.
+Adobe Reader. Use **-abs** (absolute positioning) mode for this,
+and either **-b** or **-w** to make the window visible.
+
+By default, **xdeadzone** doesn't display a visible window. It stays
+on top of other windows, and is present on every virtual desktop.
+If run with **-b** or **-w**, it'll appear as a solid black or white
+rectangle with no title bar or window frame... although if you're
+using it to block the mouse from a dead zone, you won't be able to see
+it anyway.
**xdeadzone** has been tested with various window managers and desktop
environments, and works properly with at least: KDE (Plasma 5), XFCE