diff options
-rw-r--r-- | common/util.c | 16 | ||||
-rw-r--r-- | completions/fish/swaymsg.fish | 17 | ||||
-rw-r--r-- | include/util.h | 2 | ||||
-rw-r--r-- | sway/commands/focus.c | 11 | ||||
-rw-r--r-- | sway/commands/move.c | 13 |
5 files changed, 43 insertions, 16 deletions
diff --git a/common/util.c b/common/util.c index 78d46a2a..f4588b57 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <assert.h> | ||
2 | #include <sys/types.h> | 3 | #include <sys/types.h> |
3 | #include <sys/stat.h> | 4 | #include <sys/stat.h> |
4 | #include <unistd.h> | 5 | #include <unistd.h> |
@@ -138,3 +139,18 @@ bool parse_boolean(const char *boolean, bool current) { | |||
138 | // All other values are false to match i3 | 139 | // All other values are false to match i3 |
139 | return false; | 140 | return false; |
140 | } | 141 | } |
142 | |||
143 | enum wlr_direction opposite_direction(enum wlr_direction d) { | ||
144 | switch (d) { | ||
145 | case WLR_DIRECTION_UP: | ||
146 | return WLR_DIRECTION_DOWN; | ||
147 | case WLR_DIRECTION_DOWN: | ||
148 | return WLR_DIRECTION_UP; | ||
149 | case WLR_DIRECTION_RIGHT: | ||
150 | return WLR_DIRECTION_LEFT; | ||
151 | case WLR_DIRECTION_LEFT: | ||
152 | return WLR_DIRECTION_RIGHT; | ||
153 | } | ||
154 | assert(false); | ||
155 | return 0; | ||
156 | } | ||
diff --git a/completions/fish/swaymsg.fish b/completions/fish/swaymsg.fish index e798db77..1e5bf3da 100644 --- a/completions/fish/swaymsg.fish +++ b/completions/fish/swaymsg.fish | |||
@@ -2,7 +2,18 @@ | |||
2 | 2 | ||
3 | complete -c swaymsg -s h -l help --description "Show help message and quit." | 3 | complete -c swaymsg -s h -l help --description "Show help message and quit." |
4 | complete -c swaymsg -s q -l quiet --description "Sends the IPC message but does not print the response from sway." | 4 | complete -c swaymsg -s q -l quiet --description "Sends the IPC message but does not print the response from sway." |
5 | complete -c swaymsg -s r -l raw --description "Use raw output even if using tty." | ||
6 | complete -c swaymsg -s s -l socket --description "Use the specified socket path. Otherwise, swaymsg will ask where the socket is (which is the value of $SWAYSOCK, then of $I3SOCK)." | ||
7 | complete -c swaymsg -s t -l type --description "Specify the type of IPC message." | ||
8 | complete -c swaymsg -s v -l version --description "Print the version (of swaymsg) and quit." | 5 | complete -c swaymsg -s v -l version --description "Print the version (of swaymsg) and quit." |
6 | complete -c swaymsg -s r -l raw --description "Use raw output even if using tty." | ||
7 | complete -c swaymsg -s s -l socket -r --description "Use the specified socket path. Otherwise, swaymsg will ask where the socket is (which is the value of $SWAYSOCK, then of $I3SOCK)." | ||
8 | |||
9 | complete -c swaymsg -s t -l type -fr --description "Specify the type of IPC message." | ||
10 | complete -c swaymsg -s t -l type -fra 'get_workspaces' --description "Gets a JSON-encoded list of workspaces and their status." | ||
11 | complete -c swaymsg -s t -l type -fra 'get_inputs' --description "Gets a JSON-encoded list of current inputs." | ||
12 | complete -c swaymsg -s t -l type -fra 'get_outputs' --description "Gets a JSON-encoded list of current outputs." | ||
13 | complete -c swaymsg -s t -l type -fra 'get_tree' --description "Gets a JSON-encoded layout tree of all open windows, containers, outputs, workspaces, and so on." | ||
14 | complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-encoded list of marks." | ||
15 | complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar." | ||
16 | complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway." | ||
17 | complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes." | ||
18 | complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration." | ||
19 | complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients." | ||
diff --git a/include/util.h b/include/util.h index 56ca2eb8..f143d0c0 100644 --- a/include/util.h +++ b/include/util.h | |||
@@ -59,4 +59,6 @@ uint32_t parse_color(const char *color); | |||
59 | */ | 59 | */ |
60 | bool parse_boolean(const char *boolean, bool current); | 60 | bool parse_boolean(const char *boolean, bool current); |
61 | 61 | ||
62 | enum wlr_direction opposite_direction(enum wlr_direction d); | ||
63 | |||
62 | #endif | 64 | #endif |
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 521b2427..cef92144 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -196,6 +196,17 @@ static struct cmd_results *focus_output(struct sway_seat *seat, | |||
196 | } | 196 | } |
197 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 197 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
198 | output = output_get_in_direction(ws->output, direction); | 198 | output = output_get_in_direction(ws->output, direction); |
199 | |||
200 | if (!output) { | ||
201 | int center_lx = ws->output->lx + ws->output->width / 2; | ||
202 | int center_ly = ws->output->ly + ws->output->height / 2; | ||
203 | struct wlr_output *target = wlr_output_layout_farthest_output( | ||
204 | root->output_layout, opposite_direction(direction), | ||
205 | ws->output->wlr_output, center_lx, center_ly); | ||
206 | if (target) { | ||
207 | output = output_from_wlr_output(target); | ||
208 | } | ||
209 | } | ||
199 | } | 210 | } |
200 | 211 | ||
201 | free(identifier); | 212 | free(identifier); |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 30c198e4..9035e3e2 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -27,19 +27,6 @@ static const char *expected_syntax = | |||
27 | "'move <container|window|workspace> [to] output <name|direction>' or " | 27 | "'move <container|window|workspace> [to] output <name|direction>' or " |
28 | "'move <container|window> [to] mark <mark>'"; | 28 | "'move <container|window> [to] mark <mark>'"; |
29 | 29 | ||
30 | enum wlr_direction opposite_direction(enum wlr_direction d) { | ||
31 | switch (d) { | ||
32 | case WLR_DIRECTION_UP: | ||
33 | return WLR_DIRECTION_DOWN; | ||
34 | case WLR_DIRECTION_DOWN: | ||
35 | return WLR_DIRECTION_UP; | ||
36 | case WLR_DIRECTION_RIGHT: | ||
37 | return WLR_DIRECTION_LEFT; | ||
38 | default: | ||
39 | return WLR_DIRECTION_RIGHT; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | static struct sway_output *output_in_direction(const char *direction_string, | 30 | static struct sway_output *output_in_direction(const char *direction_string, |
44 | struct sway_output *reference, int ref_lx, int ref_ly) { | 31 | struct sway_output *reference, int ref_lx, int ref_ly) { |
45 | struct { | 32 | struct { |