Skip to content

Commit 6c86f1a

Browse files
feat: make gap clicking configurable as 'gap_click_redirect enable'
1 parent 24614bf commit 6c86f1a

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

include/sway/commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ sway_cmd cmd_rename;
191191
sway_cmd cmd_resize;
192192
sway_cmd cmd_scratchpad;
193193
sway_cmd cmd_scratchpad_minimize;
194+
sway_cmd cmd_gap_click_redirect;
194195
sway_cmd cmd_seamless_mouse;
195196
sway_cmd cmd_set;
196197
sway_cmd cmd_shortcuts_inhibitor;

include/sway/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ struct sway_config {
500500

501501
bool titlebar_separator;
502502
bool scratchpad_minimize;
503+
bool gap_click_redirect;
503504

504505
list_t *layer_criteria;
505506

sway/commands.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static const struct cmd_handler handlers[] = {
8585
{ "force_display_urgency_hint", cmd_force_display_urgency_hint },
8686
{ "force_focus_wrapping", cmd_force_focus_wrapping },
8787
{ "fullscreen", cmd_fullscreen },
88+
{ "gap_click_redirect", cmd_gap_click_redirect },
8889
{ "gaps", cmd_gaps },
8990
{ "hide_edge_borders", cmd_hide_edge_borders },
9091
{ "input", cmd_input },

sway/commands/gap_click_redirect.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <string.h>
2+
#include "sway/commands.h"
3+
#include "sway/config.h"
4+
#include "util.h"
5+
6+
struct cmd_results *cmd_gap_click_redirect(int argc, char **argv) {
7+
struct cmd_results *error = checkarg(argc, "gap_click_redirect", EXPECTED_AT_LEAST, 1);
8+
9+
if (error) {
10+
return error;
11+
}
12+
13+
config->gap_click_redirect = parse_boolean(argv[0], config->gap_click_redirect);
14+
15+
return cmd_results_new(CMD_SUCCESS, NULL);
16+
}

sway/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static void config_defaults(struct sway_config *config) {
368368

369369
config->titlebar_separator = true;
370370
config->scratchpad_minimize = false;
371+
config->gap_click_redirect = false;
371372

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

sway/input/cursor.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,12 @@ struct sway_node *node_at_coords(
241241
return NULL;
242242
}
243243

244-
double distanceSquared;
245-
struct sway_container *closest_container = closest_tiling_container_at(&ws->node, lx, ly, surface, sx, sy, &distanceSquared);
246-
if(closest_container) {
247-
return &closest_container->node;
244+
if(config->gap_click_redirect) {
245+
double distanceSquared;
246+
struct sway_container *closest_container = closest_tiling_container_at(&ws->node, lx, ly, surface, sx, sy, &distanceSquared);
247+
if(closest_container) {
248+
return &closest_container->node;
249+
}
248250
}
249251

250252
return &ws->node;

sway/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ sway_sources = files(
108108
'commands/saturation.c',
109109
'commands/scratchpad.c',
110110
'commands/scratchpad_minimize.c',
111+
'commands/gap_click_redirect.c',
111112
'commands/seat.c',
112113
'commands/seat/attach.c',
113114
'commands/seat/cursor.c',

0 commit comments

Comments
 (0)