summaryrefslogtreecommitdiff
path: root/src/rmd.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-10-18 17:10:22 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-10-18 17:18:29 -0700
commitf5c9b65592327c2094d5981bb95d3e4afdf76344 (patch)
treeed1c1e7f3e8bc7dbcb762eca6de9409dace5e7a3 /src/rmd.c
parentc2f9bcd457b57b6d96a5cbdd9c36272994bc19c3 (diff)
parseargs,error: add --need-shortcuts
When you depend on the shortcuts as _the_ means of stopping/pausing a recording, like in a WM integration scenario, it's preferable to have rmd exit fatally when the grabs can't be setup. (usually this occurs when you've accidentally tried starting multiple recordings, and the shortcuts collide) This way, the integration can detect the failure and throw up a dialog or something informing the user that the recording wasn't started. All that's needed is including --need-shortcuts. Note this is a little janky in how it's implemented, because XSetErrorHandler() is janky and doesn't even support a user pointer payload. Rather than introducing global variables to either communicate the grab failures to other parts of rmd, or exposing the parsed args struct to the error handler globally in the other direction, I just made a grab-errors-are-fatal variant of the handler which gets installed when --need-shortcuts is specified.
Diffstat (limited to 'src/rmd.c')
-rw-r--r--src/rmd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rmd.c b/src/rmd.c
index c76b5bf..27e7183 100644
--- a/src/rmd.c
+++ b/src/rmd.c
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
if (pdata.args.display != NULL) {
pdata.dpy = XOpenDisplay(pdata.args.display);
- XSetErrorHandler(rmdErrorHandler);
+ XSetErrorHandler(pdata.args.need_shortcuts ? rmdGrabErrorsFatalErrorHandler : rmdErrorHandler);
} else {
fprintf(stderr, "No display specified for connection!\n");
exit(8);
© All Rights Reserved