Skip to content

Commit

Permalink
feat: make gap clicking configurable as 'gap_click_redirect enable'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Dec 7, 2024
1 parent 24614bf commit cdfcd23
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ sway_cmd cmd_rename;
sway_cmd cmd_resize;
sway_cmd cmd_scratchpad;
sway_cmd cmd_scratchpad_minimize;
sway_cmd cmd_gap_click_redirect;
sway_cmd cmd_seamless_mouse;
sway_cmd cmd_set;
sway_cmd cmd_shortcuts_inhibitor;
Expand Down
1 change: 1 addition & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ struct sway_config {

bool titlebar_separator;
bool scratchpad_minimize;
bool gap_click_redirect;

list_t *layer_criteria;

Expand Down
1 change: 1 addition & 0 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static const struct cmd_handler handlers[] = {
{ "force_display_urgency_hint", cmd_force_display_urgency_hint },
{ "force_focus_wrapping", cmd_force_focus_wrapping },
{ "fullscreen", cmd_fullscreen },
{ "gap_click_redirect", cmd_gap_click_redirect },
{ "gaps", cmd_gaps },
{ "hide_edge_borders", cmd_hide_edge_borders },
{ "input", cmd_input },
Expand Down
16 changes: 16 additions & 0 deletions sway/commands/gap_click_redirect.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "util.h"

struct cmd_results *cmd_gap_click_redirect(int argc, char **argv) {
struct cmd_results *error = checkarg(argc, "gap_click_redirect", EXPECTED_AT_LEAST, 1);

if (error) {
return error;
}

config->gap_click_redirect = parse_boolean(argv[0], config->gap_click_redirect);

return cmd_results_new(CMD_SUCCESS, NULL);
}
1 change: 1 addition & 0 deletions sway/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ static void config_defaults(struct sway_config *config) {

config->titlebar_separator = true;
config->scratchpad_minimize = false;
config->gap_click_redirect = false;

if (!(config->layer_criteria = create_list())) goto cleanup;

Expand Down
12 changes: 8 additions & 4 deletions sway/input/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,14 @@ struct sway_node *node_at_coords(
return NULL;
}

double distanceSquared;
struct sway_container *closest_container = closest_tiling_container_at(&ws->node, lx, ly, surface, sx, sy, &distanceSquared);
if(closest_container) {
return &closest_container->node;
sway_log(SWAY_ERROR, "gap click redirect %i", config->gap_click_redirect);

if(config->gap_click_redirect) {
double distanceSquared;
struct sway_container *closest_container = closest_tiling_container_at(&ws->node, lx, ly, surface, sx, sy, &distanceSquared);
if(closest_container) {
return &closest_container->node;
}
}

return &ws->node;
Expand Down
1 change: 1 addition & 0 deletions sway/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ sway_sources = files(
'commands/saturation.c',
'commands/scratchpad.c',
'commands/scratchpad_minimize.c',
'commands/gap_click_redirect.c',
'commands/seat.c',
'commands/seat/attach.c',
'commands/seat/cursor.c',
Expand Down

0 comments on commit cdfcd23

Please sign in to comment.