diff options
-rw-r--r-- | common/loop.c | 1 | ||||
-rw-r--r-- | sway/commands/swap.c | 15 | ||||
-rw-r--r-- | swaybar/bar.c | 6 | ||||
-rw-r--r-- | swaybg/main.c | 7 | ||||
-rw-r--r-- | swayidle/main.c | 4 | ||||
-rw-r--r-- | swaylock/main.c | 16 | ||||
-rw-r--r-- | swaynag/swaynag.c | 6 |
7 files changed, 41 insertions, 14 deletions
diff --git a/common/loop.c b/common/loop.c index 1b174967..750bee75 100644 --- a/common/loop.c +++ b/common/loop.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | ||
1 | #include <limits.h> | 2 | #include <limits.h> |
2 | #include <string.h> | 3 | #include <string.h> |
3 | #include <stdbool.h> | 4 | #include <stdbool.h> |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 22e3927d..9cc0d5c2 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -22,6 +22,7 @@ static void swap_places(struct sway_container *con1, | |||
22 | temp->width = con1->width; | 22 | temp->width = con1->width; |
23 | temp->height = con1->height; | 23 | temp->height = con1->height; |
24 | temp->parent = con1->parent; | 24 | temp->parent = con1->parent; |
25 | temp->workspace = con1->workspace; | ||
25 | 26 | ||
26 | con1->x = con2->x; | 27 | con1->x = con2->x; |
27 | con1->y = con2->y; | 28 | con1->y = con2->y; |
@@ -34,8 +35,18 @@ static void swap_places(struct sway_container *con1, | |||
34 | con2->height = temp->height; | 35 | con2->height = temp->height; |
35 | 36 | ||
36 | int temp_index = container_sibling_index(con1); | 37 | int temp_index = container_sibling_index(con1); |
37 | container_insert_child(con2->parent, con1, container_sibling_index(con2)); | 38 | if (con2->parent) { |
38 | container_insert_child(temp->parent, con2, temp_index); | 39 | container_insert_child(con2->parent, con1, |
40 | container_sibling_index(con2)); | ||
41 | } else { | ||
42 | workspace_insert_tiling(con2->workspace, con1, | ||
43 | container_sibling_index(con2)); | ||
44 | } | ||
45 | if (temp->parent) { | ||
46 | container_insert_child(temp->parent, con2, temp_index); | ||
47 | } else { | ||
48 | workspace_insert_tiling(temp->workspace, con2, temp_index); | ||
49 | } | ||
39 | 50 | ||
40 | free(temp); | 51 | free(temp); |
41 | } | 52 | } |
diff --git a/swaybar/bar.c b/swaybar/bar.c index be290c18..0deba72d 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -586,7 +586,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
586 | } | 586 | } |
587 | 587 | ||
588 | bar->display = wl_display_connect(NULL); | 588 | bar->display = wl_display_connect(NULL); |
589 | assert(bar->display); | 589 | if (!bar->display) { |
590 | sway_abort("Unable to connect to the compositor. " | ||
591 | "If your compositor is running, check or set the " | ||
592 | "WAYLAND_DISPLAY environment variable."); | ||
593 | } | ||
590 | 594 | ||
591 | struct wl_registry *registry = wl_display_get_registry(bar->display); | 595 | struct wl_registry *registry = wl_display_get_registry(bar->display); |
592 | wl_registry_add_listener(registry, ®istry_listener, bar); | 596 | wl_registry_add_listener(registry, ®istry_listener, bar); |
diff --git a/swaybg/main.c b/swaybg/main.c index 742669ef..45b7a913 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -222,7 +222,12 @@ int main(int argc, const char **argv) { | |||
222 | } | 222 | } |
223 | 223 | ||
224 | state.display = wl_display_connect(NULL); | 224 | state.display = wl_display_connect(NULL); |
225 | assert(state.display); | 225 | if (!state.display) { |
226 | wlr_log(WLR_ERROR, "Unable to connect to the compositor. " | ||
227 | "If your compositor is running, check or set the " | ||
228 | "WAYLAND_DISPLAY environment variable."); | ||
229 | return 1; | ||
230 | } | ||
226 | 231 | ||
227 | struct wl_registry *registry = wl_display_get_registry(state.display); | 232 | struct wl_registry *registry = wl_display_get_registry(state.display); |
228 | wl_registry_add_listener(registry, ®istry_listener, &state); | 233 | wl_registry_add_listener(registry, ®istry_listener, &state); |
diff --git a/swayidle/main.c b/swayidle/main.c index 5b6c95a7..93f4c94b 100644 --- a/swayidle/main.c +++ b/swayidle/main.c | |||
@@ -388,7 +388,9 @@ int main(int argc, char *argv[]) { | |||
388 | 388 | ||
389 | state.display = wl_display_connect(NULL); | 389 | state.display = wl_display_connect(NULL); |
390 | if (state.display == NULL) { | 390 | if (state.display == NULL) { |
391 | wlr_log(WLR_ERROR, "Failed to create display"); | 391 | wlr_log(WLR_ERROR, "Unable to connect to the compositor. " |
392 | "If your compositor is running, check or set the " | ||
393 | "WAYLAND_DISPLAY environment variable."); | ||
392 | return -3; | 394 | return -3; |
393 | } | 395 | } |
394 | 396 | ||
diff --git a/swaylock/main.c b/swaylock/main.c index 27bcfe32..86dfd577 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, | |||
634 | } | 634 | } |
635 | break; | 635 | break; |
636 | case 'v': | 636 | case 'v': |
637 | #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE | 637 | fprintf(stdout, "swaylock version " SWAY_VERSION "\n"); |
638 | fprintf(stdout, "swaylock version %s (%s, branch \"%s\")\n", | 638 | exit(EXIT_SUCCESS); |
639 | SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); | 639 | break; |
640 | #else | ||
641 | fprintf(stdout, "version unknown\n"); | ||
642 | #endif | ||
643 | return 1; | ||
644 | case LO_BS_HL_COLOR: | 640 | case LO_BS_HL_COLOR: |
645 | if (state) { | 641 | if (state) { |
646 | state->args.colors.bs_highlight = parse_color(optarg); | 642 | state->args.colors.bs_highlight = parse_color(optarg); |
@@ -908,7 +904,11 @@ int main(int argc, char **argv) { | |||
908 | wl_list_init(&state.surfaces); | 904 | wl_list_init(&state.surfaces); |
909 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); | 905 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); |
910 | state.display = wl_display_connect(NULL); | 906 | state.display = wl_display_connect(NULL); |
911 | assert(state.display); | 907 | if (!state.display) { |
908 | sway_abort("Unable to connect to the compositor. " | ||
909 | "If your compositor is running, check or set the " | ||
910 | "WAYLAND_DISPLAY environment variable."); | ||
911 | } | ||
912 | 912 | ||
913 | struct wl_registry *registry = wl_display_get_registry(state.display); | 913 | struct wl_registry *registry = wl_display_get_registry(state.display); |
914 | wl_registry_add_listener(registry, ®istry_listener, &state); | 914 | wl_registry_add_listener(registry, ®istry_listener, &state); |
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 69da851e..fa6bbe05 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c | |||
@@ -342,7 +342,11 @@ static const struct wl_registry_listener registry_listener = { | |||
342 | 342 | ||
343 | void swaynag_setup(struct swaynag *swaynag) { | 343 | void swaynag_setup(struct swaynag *swaynag) { |
344 | swaynag->display = wl_display_connect(NULL); | 344 | swaynag->display = wl_display_connect(NULL); |
345 | assert(swaynag->display); | 345 | if (!swaynag->display) { |
346 | sway_abort("Unable to connect to the compositor. " | ||
347 | "If your compositor is running, check or set the " | ||
348 | "WAYLAND_DISPLAY environment variable."); | ||
349 | } | ||
346 | 350 | ||
347 | swaynag->scale = 1; | 351 | swaynag->scale = 1; |
348 | wl_list_init(&swaynag->outputs); | 352 | wl_list_init(&swaynag->outputs); |