aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/util.c16
-rw-r--r--completions/fish/swaymsg.fish17
-rw-r--r--include/util.h2
-rw-r--r--sway/commands/focus.c11
-rw-r--r--sway/commands/move.c13
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 @@
#define _XOPEN_SOURCE 700
+#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -138,3 +139,18 @@ bool parse_boolean(const char *boolean, bool current) {
// All other values are false to match i3
return false;
}
+
+enum wlr_direction opposite_direction(enum wlr_direction d) {
+ switch (d) {
+ case WLR_DIRECTION_UP:
+ return WLR_DIRECTION_DOWN;
+ case WLR_DIRECTION_DOWN:
+ return WLR_DIRECTION_UP;
+ case WLR_DIRECTION_RIGHT:
+ return WLR_DIRECTION_LEFT;
+ case WLR_DIRECTION_LEFT:
+ return WLR_DIRECTION_RIGHT;
+ }
+ assert(false);
+ return 0;
+}
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 @@
complete -c swaymsg -s h -l help --description "Show help message and quit."
complete -c swaymsg -s q -l quiet --description "Sends the IPC message but does not print the response from sway."
-complete -c swaymsg -s r -l raw --description "Use raw output even if using tty."
-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)."
-complete -c swaymsg -s t -l type --description "Specify the type of IPC message."
complete -c swaymsg -s v -l version --description "Print the version (of swaymsg) and quit."
+complete -c swaymsg -s r -l raw --description "Use raw output even if using tty."
+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)."
+
+complete -c swaymsg -s t -l type -fr --description "Specify the type of IPC message."
+complete -c swaymsg -s t -l type -fra 'get_workspaces' --description "Gets a JSON-encoded list of workspaces and their status."
+complete -c swaymsg -s t -l type -fra 'get_inputs' --description "Gets a JSON-encoded list of current inputs."
+complete -c swaymsg -s t -l type -fra 'get_outputs' --description "Gets a JSON-encoded list of current outputs."
+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."
+complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-encoded list of marks."
+complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar."
+complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway."
+complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes."
+complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration."
+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);
*/
bool parse_boolean(const char *boolean, bool current);
+enum wlr_direction opposite_direction(enum wlr_direction d);
+
#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,
}
struct sway_workspace *ws = seat_get_focused_workspace(seat);
output = output_get_in_direction(ws->output, direction);
+
+ if (!output) {
+ int center_lx = ws->output->lx + ws->output->width / 2;
+ int center_ly = ws->output->ly + ws->output->height / 2;
+ struct wlr_output *target = wlr_output_layout_farthest_output(
+ root->output_layout, opposite_direction(direction),
+ ws->output->wlr_output, center_lx, center_ly);
+ if (target) {
+ output = output_from_wlr_output(target);
+ }
+ }
}
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 =
"'move <container|window|workspace> [to] output <name|direction>' or "
"'move <container|window> [to] mark <mark>'";
-enum wlr_direction opposite_direction(enum wlr_direction d) {
- switch (d) {
- case WLR_DIRECTION_UP:
- return WLR_DIRECTION_DOWN;
- case WLR_DIRECTION_DOWN:
- return WLR_DIRECTION_UP;
- case WLR_DIRECTION_RIGHT:
- return WLR_DIRECTION_LEFT;
- default:
- return WLR_DIRECTION_RIGHT;
- }
-}
-
static struct sway_output *output_in_direction(const char *direction_string,
struct sway_output *reference, int ref_lx, int ref_ly) {
struct {