diff --git a/common/loop.c b/common/loop.c index 1b1749673..750bee757 100644 --- a/common/loop.c +++ b/common/loop.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 199309L #include #include #include diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 22e3927d9..9cc0d5c27 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -22,6 +22,7 @@ static void swap_places(struct sway_container *con1, temp->width = con1->width; temp->height = con1->height; temp->parent = con1->parent; + temp->workspace = con1->workspace; con1->x = con2->x; con1->y = con2->y; @@ -34,8 +35,18 @@ static void swap_places(struct sway_container *con1, con2->height = temp->height; int temp_index = container_sibling_index(con1); - container_insert_child(con2->parent, con1, container_sibling_index(con2)); - container_insert_child(temp->parent, con2, temp_index); + if (con2->parent) { + container_insert_child(con2->parent, con1, + container_sibling_index(con2)); + } else { + workspace_insert_tiling(con2->workspace, con1, + container_sibling_index(con2)); + } + if (temp->parent) { + container_insert_child(temp->parent, con2, temp_index); + } else { + workspace_insert_tiling(temp->workspace, con2, temp_index); + } free(temp); } diff --git a/swaybar/bar.c b/swaybar/bar.c index be290c180..0deba72df 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -586,7 +586,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { } bar->display = wl_display_connect(NULL); - assert(bar->display); + if (!bar->display) { + sway_abort("Unable to connect to the compositor. " + "If your compositor is running, check or set the " + "WAYLAND_DISPLAY environment variable."); + } struct wl_registry *registry = wl_display_get_registry(bar->display); wl_registry_add_listener(registry, ®istry_listener, bar); diff --git a/swaybg/main.c b/swaybg/main.c index 742669ef3..45b7a913a 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -222,7 +222,12 @@ int main(int argc, const char **argv) { } state.display = wl_display_connect(NULL); - assert(state.display); + if (!state.display) { + wlr_log(WLR_ERROR, "Unable to connect to the compositor. " + "If your compositor is running, check or set the " + "WAYLAND_DISPLAY environment variable."); + return 1; + } struct wl_registry *registry = wl_display_get_registry(state.display); wl_registry_add_listener(registry, ®istry_listener, &state); diff --git a/swayidle/main.c b/swayidle/main.c index 5b6c95a7d..93f4c94ba 100644 --- a/swayidle/main.c +++ b/swayidle/main.c @@ -388,7 +388,9 @@ int main(int argc, char *argv[]) { state.display = wl_display_connect(NULL); if (state.display == NULL) { - wlr_log(WLR_ERROR, "Failed to create display"); + wlr_log(WLR_ERROR, "Unable to connect to the compositor. " + "If your compositor is running, check or set the " + "WAYLAND_DISPLAY environment variable."); return -3; } diff --git a/swaylock/main.c b/swaylock/main.c index 27bcfe32b..86dfd5777 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -634,13 +634,9 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, } break; case 'v': -#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE - fprintf(stdout, "swaylock version %s (%s, branch \"%s\")\n", - SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); -#else - fprintf(stdout, "version unknown\n"); -#endif - return 1; + fprintf(stdout, "swaylock version " SWAY_VERSION "\n"); + exit(EXIT_SUCCESS); + break; case LO_BS_HL_COLOR: if (state) { state->args.colors.bs_highlight = parse_color(optarg); @@ -908,7 +904,11 @@ int main(int argc, char **argv) { wl_list_init(&state.surfaces); state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); state.display = wl_display_connect(NULL); - assert(state.display); + if (!state.display) { + sway_abort("Unable to connect to the compositor. " + "If your compositor is running, check or set the " + "WAYLAND_DISPLAY environment variable."); + } struct wl_registry *registry = wl_display_get_registry(state.display); wl_registry_add_listener(registry, ®istry_listener, &state); diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 69da851e6..fa6bbe057 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -342,7 +342,11 @@ static const struct wl_registry_listener registry_listener = { void swaynag_setup(struct swaynag *swaynag) { swaynag->display = wl_display_connect(NULL); - assert(swaynag->display); + if (!swaynag->display) { + sway_abort("Unable to connect to the compositor. " + "If your compositor is running, check or set the " + "WAYLAND_DISPLAY environment variable."); + } swaynag->scale = 1; wl_list_init(&swaynag->outputs);