Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse_warp to mark option #8201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ enum mouse_warping_mode {
WARP_NO,
WARP_OUTPUT,
WARP_CONTAINER,
WARP_MARK,
};

enum alignment {
Expand Down Expand Up @@ -537,6 +538,7 @@ struct sway_config {
// Flags
enum focus_follows_mouse_mode focus_follows_mouse;
enum mouse_warping_mode mouse_warping;
char *mouse_warping_mark_name;
enum focus_wrapping_mode focus_wrapping;
bool active;
bool failed;
Expand Down
5 changes: 5 additions & 0 deletions sway/commands/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
// to anyway.
if (config->mouse_warping == WARP_CONTAINER) {
cursor_warp_to_container(seat->cursor, new_focus, true);
} else if (config->mouse_warping == WARP_MARK) {
bool has_warp_mark = container_has_mark(new_focus, config->mouse_warping_mark_name);
if (has_warp_mark) {
cursor_warp_to_container(seat->cursor, new_focus, true);
}
} else {
seat_consider_warp_to_focus(seat);
}
Expand Down
10 changes: 8 additions & 2 deletions sway/commands/mouse_warping.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@

struct cmd_results *cmd_mouse_warping(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "mouse_warping", EXPECTED_EQUAL_TO, 1))) {
if ((error = checkarg(argc, "mouse_warping", EXPECTED_AT_LEAST, 1))) {
return error;
} else if (strcasecmp(argv[0], "container") == 0) {
config->mouse_warping = WARP_CONTAINER;
} else if (strcasecmp(argv[0], "output") == 0) {
config->mouse_warping = WARP_OUTPUT;
} else if (strcasecmp(argv[0], "none") == 0) {
config->mouse_warping = WARP_NO;
} else if (strcasecmp(argv[0], "mark") == 0) {
config->mouse_warping = WARP_MARK;
if (argc < 2) {
return cmd_results_new(CMD_FAILURE, "Expected an mark name as a second argument");
}
config->mouse_warping_mark_name = argv[1];
} else {
return cmd_results_new(CMD_FAILURE,
"Expected 'mouse_warping output|container|none'");
"Expected 'mouse_warping output|container|mark|none'");
}
return cmd_results_new(CMD_SUCCESS, NULL);
}
Expand Down