aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config.h1
-rw-r--r--sway.5.txt5
-rw-r--r--sway/commands.c10
-rw-r--r--sway/config.c1
-rw-r--r--sway/handlers.c58
5 files changed, 75 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index 2a8e36fa..56fba691 100644
--- a/include/config.h
+++ b/include/config.h
@@ -55,6 +55,7 @@ struct sway_config {
bool reloading;
bool reading;
bool auto_back_and_forth;
+ bool seamless_mouse;
int gaps_inner;
int gaps_outer;
diff --git a/sway.5.txt b/sway.5.txt
index 9bcfef42..d97720c5 100644
--- a/sway.5.txt
+++ b/sway.5.txt
@@ -112,6 +112,11 @@ Commands
Resizes the currently focused container or view by _amount_. _amount_ can be
specified as "n px" or "n ppt" or "n px or n ppt".
+**seamless_mouse** <on|off>::
+ Change output seamlessly when pointer touches edge of output. Outputs need to
+ be configured with perfectly aligned adjacent positions for this option to
+ have any effect.
+
**set** <name> <value>::
Creates a substitution for _value_ that can be used with $_name_ in other
commands.
diff --git a/sway/commands.c b/sway/commands.c
index 7605a36b..a9c20e51 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -410,6 +410,15 @@ static enum cmd_status cmd_focus_follows_mouse(int argc, char **argv) {
return CMD_SUCCESS;
}
+static enum cmd_status cmd_seamless_mouse(int argc, char **argv) {
+ if (!checkarg(argc, "seamless_mouse", EXPECTED_EQUAL_TO, 1)) {
+ return CMD_FAILURE;
+ }
+
+ config->seamless_mouse = (strcasecmp(argv[0], "on") == 0 || strcasecmp(argv[0], "yes") == 0);
+ return CMD_SUCCESS;
+}
+
static void hide_view_in_scratchpad(swayc_t *sp_view) {
if (sp_view == NULL) {
return;
@@ -1139,6 +1148,7 @@ static struct cmd_handler handlers[] = {
{ "reload", cmd_reload },
{ "resize", cmd_resize },
{ "scratchpad", cmd_scratchpad },
+ { "seamless_mouse", cmd_seamless_mouse },
{ "set", cmd_set },
{ "split", cmd_split },
{ "splith", cmd_splith },
diff --git a/sway/config.c b/sway/config.c
index bce074b9..67f8284c 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -102,6 +102,7 @@ static void config_defaults(struct sway_config *config) {
config->active = false;
config->failed = false;
config->auto_back_and_forth = false;
+ config->seamless_mouse = true;
config->reading = false;
config->gaps_inner = 0;
diff --git a/sway/handlers.c b/sway/handlers.c
index cf07bc8b..351d0a0f 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -353,6 +353,64 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
}
static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) {
+ // Switch to adjacent output if touching output edge.
+ //
+ // Since this doesn't currently support moving windows between outputs we
+ // don't do the switch if the pointer is in a mode.
+ if (config->seamless_mouse && !pointer_state.mode) {
+ swayc_t *output = swayc_active_output();
+
+ // TODO: This implementation is naïve: We assume all outputs are
+ // perfectly aligned (ie. only a single output per edge which covers
+ // the whole edge).
+ if (origin->x == 0) { // Left edge
+ for(int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *c = root_container.children->items[i];
+ if (c == output || c->type != C_OUTPUT) {
+ continue;
+ }
+ if (c->y == output->y && c->x + c->width == output->x) {
+ sway_log(L_DEBUG, "%s is right of %s", output->name, c->name);
+ workspace_switch(c);
+ }
+ }
+ } else if ((double)origin->x == output->width) { // Right edge
+ for(int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *c = root_container.children->items[i];
+ if (c == output || c->type != C_OUTPUT) {
+ continue;
+ }
+ if (c->y == output->y && output->x + output->width == c->x) {
+ sway_log(L_DEBUG, "%s is left of %s", output->name, c->name);
+ workspace_switch(c);
+ }
+ }
+ }
+ if (origin->y == 0) { // Top edge
+ for(int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *c = root_container.children->items[i];
+ if (c == output || c->type != C_OUTPUT) {
+ continue;
+ }
+ if (output->x == c->x && c->y + c->height == output->y) {
+ sway_log(L_DEBUG, "%s is below %s", output->name, c->name);
+ workspace_switch(c);
+ }
+ }
+ } else if ((double)origin->y == output->height) { // Bottom edge
+ for(int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *c = root_container.children->items[i];
+ if (c == output || c->type != C_OUTPUT) {
+ continue;
+ }
+ if (output->x == c->x && output->y + output->height == c->y) {
+ sway_log(L_DEBUG, "%s is above %s", output->name, c->name);
+ workspace_switch(c);
+ }
+ }
+ }
+ }
+
// Update pointer origin
pointer_state.delta.x = origin->x - pointer_state.origin.x;
pointer_state.delta.y = origin->y - pointer_state.origin.y;