aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/layout.c6
-rw-r--r--sway/config/output.c36
2 files changed, 29 insertions, 13 deletions
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index 2aca31dc..7d61c3be 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -111,10 +111,8 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
"Unable to change layout of floating windows");
}
- // Typically we change the layout of the current container, but if the
- // current container is a view (it usually is) then we'll change the layout
- // of the parent instead, as it doesn't make sense for views to have layout.
- if (container && container->view) {
+ // Operate on parent container, like i3.
+ if (container) {
container = container->parent;
}
diff --git a/sway/config/output.c b/sway/config/output.c
index 513d03e0..e7fbad83 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -175,12 +175,33 @@ static void handle_swaybg_client_destroy(struct wl_listener *listener,
output->swaybg_client = NULL;
}
+static bool set_cloexec(int fd, bool cloexec) {
+ int flags = fcntl(fd, F_GETFD);
+ if (flags == -1) {
+ sway_log_errno(SWAY_ERROR, "fcntl failed");
+ return false;
+ }
+ if (cloexec) {
+ flags = flags | FD_CLOEXEC;
+ } else {
+ flags = flags & ~FD_CLOEXEC;
+ }
+ if (fcntl(fd, F_SETFD, flags) == -1) {
+ sway_log_errno(SWAY_ERROR, "fcntl failed");
+ return false;
+ }
+ return true;
+}
+
static bool spawn_swaybg(struct sway_output *output, char *const cmd[]) {
int sockets[2];
- if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sockets) != 0) {
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) != 0) {
sway_log_errno(SWAY_ERROR, "socketpair failed");
return false;
}
+ if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) {
+ return false;
+ }
output->swaybg_client = wl_client_create(server.wl_display, sockets[0]);
if (output->swaybg_client == NULL) {
@@ -202,14 +223,7 @@ static bool spawn_swaybg(struct sway_output *output, char *const cmd[]) {
sway_log_errno(SWAY_ERROR, "fork failed");
exit(EXIT_FAILURE);
} else if (pid == 0) {
- // Remove the CLOEXEC flag
- int flags = fcntl(sockets[1], F_GETFD);
- if (flags == -1) {
- sway_log_errno(SWAY_ERROR, "fcntl() failed");
- exit(EXIT_FAILURE);
- }
- if (fcntl(sockets[1], F_SETFD, flags & ~FD_CLOEXEC) == -1) {
- sway_log_errno(SWAY_ERROR, "fcntl() failed");
+ if (!set_cloexec(sockets[1], false)) {
exit(EXIT_FAILURE);
}
@@ -225,6 +239,10 @@ static bool spawn_swaybg(struct sway_output *output, char *const cmd[]) {
exit(EXIT_SUCCESS);
}
+ if (close(sockets[1]) != 0) {
+ sway_log_errno(SWAY_ERROR, "close failed");
+ return false;
+ }
if (waitpid(pid, NULL, 0) < 0) {
sway_log_errno(SWAY_ERROR, "waitpid failed");
return false;