sway/main: fail if only one of --socket and --wayland-fd are given

This commit is contained in:
Ferdinand Bachmann 2024-07-20 01:16:02 +02:00
parent 934018253c
commit 6532b0eb49

View file

@ -1,3 +1,4 @@
#include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#include <signal.h> #include <signal.h>
@ -292,6 +293,14 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// Fail if only one of --socket and --wayland-fd are given.
if ((socket_name == NULL) ^ (socket_fd == -1)) {
fprintf(stderr,
"Both --socket and --wayland-fd are required for Wayland "
"socket handover, but only one was provided. Aborting.\n");
exit(EXIT_FAILURE);
}
// As the 'callback' function for wlr_log is equivalent to that for // As the 'callback' function for wlr_log is equivalent to that for
// sway, we do not need to override it. // sway, we do not need to override it.
if (debug) { if (debug) {