no more output from programs called with exec, fixed focus return values

This commit is contained in:
Taiyu 2015-08-12 22:58:15 -07:00
parent dc9efcd79f
commit ac1c2d31bf
3 changed files with 24 additions and 7 deletions

View File

@ -6,6 +6,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <ctype.h>
#include "stringop.h"
#include "layout.h"
@ -118,6 +119,22 @@ static bool cmd_exec_always(struct sway_config *config, int argc, char **argv) {
if(cleanup == false) {
signal(SIGCHLD, cmd_exec_cleanup);
cleanup = true;
/* Set it so filedescriptors are closed for executed programs */
int flag_out = fcntl(STDOUT_FILENO, F_GETFD);
int flag_in = fcntl(STDIN_FILENO, F_GETFD);
int flag_err = fcntl(STDERR_FILENO, F_GETFD);
if (flag_out != -1) {
flag_out |= FD_CLOEXEC;
fcntl(STDOUT_FILENO, F_SETFD, flag_out);
}
if (flag_in != -1) {
flag_in |= FD_CLOEXEC;
fcntl(STDIN_FILENO, F_SETFD, flag_in);
}
if (flag_err != -1) {
flag_err |= FD_CLOEXEC;
fcntl(STDERR_FILENO, F_SETFD, flag_err);
}
}
if (checkarg(argc, "exec_always", EXPECTED_MORE_THEN, 0) == false) {
@ -287,7 +304,7 @@ static bool cmd_log_colors(struct sway_config *config, int argc, char **argv) {
}
static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
if (checkarg(argc, "fullscreen", EXPECTED_SAME_AS, 1) == false) {
if (checkarg(argc, "fullscreen", EXPECTED_SAME_AS, 0) == false) {
return false;
}

View File

@ -5,7 +5,7 @@
#include "layout.h"
#include "movement.h"
int move_focus(enum movement_direction direction) {
bool move_focus(enum movement_direction direction) {
swayc_t *current = get_focused_container(&root_container);
swayc_t *parent = current->parent;
@ -14,12 +14,12 @@ int move_focus(enum movement_direction direction) {
parent = parent->parent;
if (parent->type == C_ROOT) {
sway_log(L_DEBUG, "Focus cannot move to parent");
return 1;
return false;
} else {
sway_log(L_DEBUG, "Moving focus away from %p", current);
unfocus_all(parent);
focus_view(parent);
return 0;
return true;
}
}
@ -56,7 +56,7 @@ int move_focus(enum movement_direction direction) {
} else {
unfocus_all(&root_container);
focus_view(parent->children->items[desired]);
return 0;
return true;
}
}
if (!can_move) {
@ -65,7 +65,7 @@ int move_focus(enum movement_direction direction) {
parent = parent->parent;
if (parent->type == C_ROOT) {
// Nothing we can do
return 1;
return false;
}
}
}

View File

@ -12,6 +12,6 @@ enum movement_direction {
MOVE_PARENT
};
int move_focus(enum movement_direction direction);
bool move_focus(enum movement_direction direction);
#endif