diff options
-rw-r--r-- | include/config.h | 11 | ||||
-rw-r--r-- | sway/commands.c | 29 | ||||
-rw-r--r-- | sway/config.c | 9 | ||||
-rw-r--r-- | sway/handlers.c | 35 | ||||
-rw-r--r-- | sway/sway.5.txt | 11 |
5 files changed, 20 insertions, 75 deletions
diff --git a/include/config.h b/include/config.h index 6bd09151..e15ba311 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -166,12 +166,6 @@ enum edge_border_types { | |||
166 | E_BOTH /**< hide vertical and horizontal edge borders */ | 166 | E_BOTH /**< hide vertical and horizontal edge borders */ |
167 | }; | 167 | }; |
168 | 168 | ||
169 | enum floating_scroll_behavior { | ||
170 | FSB_GAPS_OUTER, /**< Adjust outer gaps */ | ||
171 | FSB_GAPS_INNER, /**< Adjust inner gaps */ | ||
172 | FSB_CUSTOM /**< Perform a user-defined action */ | ||
173 | }; | ||
174 | |||
175 | /** | 169 | /** |
176 | * The configuration struct. The result of loading a config file. | 170 | * The configuration struct. The result of loading a config file. |
177 | */ | 171 | */ |
@@ -190,9 +184,8 @@ struct sway_config { | |||
190 | uint32_t floating_mod; | 184 | uint32_t floating_mod; |
191 | uint32_t dragging_key; | 185 | uint32_t dragging_key; |
192 | uint32_t resizing_key; | 186 | uint32_t resizing_key; |
193 | enum floating_scroll_behavior floating_scroll; | 187 | char *floating_scroll_up_cmd; |
194 | char *fsb_up; | 188 | char *floating_scroll_down_cmd; |
195 | char *fsb_down; | ||
196 | enum swayc_layouts default_orientation; | 189 | enum swayc_layouts default_orientation; |
197 | enum swayc_layouts default_layout; | 190 | enum swayc_layouts default_layout; |
198 | char *font; | 191 | char *font; |
diff --git a/sway/commands.c b/sway/commands.c index a4fcde78..5a592555 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -711,34 +711,19 @@ static struct cmd_results *cmd_floating_scroll(int argc, char **argv) { | |||
711 | if ((error = checkarg(argc, "floating_scroll", EXPECTED_AT_LEAST, 1))) { | 711 | if ((error = checkarg(argc, "floating_scroll", EXPECTED_AT_LEAST, 1))) { |
712 | return error; | 712 | return error; |
713 | } | 713 | } |
714 | if (!strcasecmp("behavior", argv[0])) { | 714 | if (!strcasecmp("up", argv[0])) { |
715 | free(config->floating_scroll_up_cmd); | ||
715 | if (argc < 2) { | 716 | if (argc < 2) { |
716 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Insufficient parameters given"); | 717 | config->floating_scroll_up_cmd = strdup(""); |
717 | return error; | ||
718 | } | ||
719 | if (!strcasecmp("gaps_inner", argv[1])) { | ||
720 | config->floating_scroll = FSB_GAPS_INNER; | ||
721 | } else if (!strcasecmp("gaps_outer", argv[1])) { | ||
722 | config->floating_scroll = FSB_GAPS_OUTER; | ||
723 | } else if (!strcasecmp("custom", argv[1])) { | ||
724 | config->floating_scroll = FSB_CUSTOM; | ||
725 | } else { | ||
726 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown behavior: '%s'", argv[1]); | ||
727 | return error; | ||
728 | } | ||
729 | } else if (!strcasecmp("up", argv[0])) { | ||
730 | free(config->fsb_up); | ||
731 | if (argc < 2) { | ||
732 | config->fsb_up = strdup(""); | ||
733 | } else { | 718 | } else { |
734 | config->fsb_up = join_args(argv + 1, argc - 1); | 719 | config->floating_scroll_up_cmd = join_args(argv + 1, argc - 1); |
735 | } | 720 | } |
736 | } else if (!strcasecmp("down", argv[0])) { | 721 | } else if (!strcasecmp("down", argv[0])) { |
737 | free(config->fsb_down); | 722 | free(config->floating_scroll_down_cmd); |
738 | if (argc < 2) { | 723 | if (argc < 2) { |
739 | config->fsb_down = strdup(""); | 724 | config->floating_scroll_down_cmd = strdup(""); |
740 | } else { | 725 | } else { |
741 | config->fsb_down = join_args(argv + 1, argc - 1); | 726 | config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1); |
742 | } | 727 | } |
743 | } else { | 728 | } else { |
744 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); | 729 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); |
diff --git a/sway/config.c b/sway/config.c index 15aed11b..6c1d21c8 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -131,8 +131,8 @@ void free_config(struct sway_config *config) { | |||
131 | list_free(config->active_bar_modifiers); | 131 | list_free(config->active_bar_modifiers); |
132 | free_flat_list(config->config_chain); | 132 | free_flat_list(config->config_chain); |
133 | free(config->font); | 133 | free(config->font); |
134 | free(config->fsb_up); | 134 | free(config->floating_scroll_up_cmd); |
135 | free(config->fsb_down); | 135 | free(config->floating_scroll_down_cmd); |
136 | free(config); | 136 | free(config); |
137 | } | 137 | } |
138 | 138 | ||
@@ -161,9 +161,8 @@ static void config_defaults(struct sway_config *config) { | |||
161 | config->floating_mod = 0; | 161 | config->floating_mod = 0; |
162 | config->dragging_key = M_LEFT_CLICK; | 162 | config->dragging_key = M_LEFT_CLICK; |
163 | config->resizing_key = M_RIGHT_CLICK; | 163 | config->resizing_key = M_RIGHT_CLICK; |
164 | config->floating_scroll = FSB_GAPS_INNER; | 164 | config->floating_scroll_up_cmd = strdup(""); |
165 | config->fsb_up = strdup(""); | 165 | config->floating_scroll_down_cmd = strdup(""); |
166 | config->fsb_down = strdup(""); | ||
167 | config->default_layout = L_NONE; | 166 | config->default_layout = L_NONE; |
168 | config->default_orientation = L_NONE; | 167 | config->default_orientation = L_NONE; |
169 | config->font = strdup("monospace 10"); | 168 | config->font = strdup("monospace 10"); |
diff --git a/sway/handlers.c b/sway/handlers.c index 23c9985e..67275575 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -723,36 +723,11 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
723 | bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers, | 723 | bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers, |
724 | uint8_t axis_bits, double _amount[2]) { | 724 | uint8_t axis_bits, double _amount[2]) { |
725 | if (!(modifiers->mods ^ config->floating_mod)) { | 725 | if (!(modifiers->mods ^ config->floating_mod)) { |
726 | switch (config->floating_scroll) { | 726 | int amount = (int)_amount[0]; |
727 | case FSB_GAPS_INNER: | 727 | if (amount > 0) { |
728 | case FSB_GAPS_OUTER: | 728 | handle_command(config->floating_scroll_up_cmd); |
729 | { | 729 | } else if (amount < 0) { |
730 | int amount = (int)_amount[0]; | 730 | handle_command(config->floating_scroll_down_cmd); |
731 | int i,j; | ||
732 | for (i = 0; i < root_container.children->length; ++i) { | ||
733 | swayc_t *op = root_container.children->items[i]; | ||
734 | for (j = 0; j < op->children->length; ++j) { | ||
735 | swayc_t *ws = op->children->items[j]; | ||
736 | if (config->floating_scroll == FSB_GAPS_INNER) { | ||
737 | container_map(ws, add_gaps, &amount); | ||
738 | } else { | ||
739 | ws->gaps += amount; | ||
740 | } | ||
741 | } | ||
742 | } | ||
743 | arrange_windows(&root_container, -1, -1); | ||
744 | break; | ||
745 | } | ||
746 | case FSB_CUSTOM: | ||
747 | { | ||
748 | int amount = (int)_amount[0]; | ||
749 | if (amount > 0) { | ||
750 | handle_command(config->fsb_up); | ||
751 | } else if (amount < 0) { | ||
752 | handle_command(config->fsb_down); | ||
753 | } | ||
754 | break; | ||
755 | } | ||
756 | } | 731 | } |
757 | } | 732 | } |
758 | return EVENT_PASSTHROUGH; | 733 | return EVENT_PASSTHROUGH; |
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index fdb7818c..25229033 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -156,17 +156,10 @@ or triggered at runtime. | |||
156 | enabled, left click is used for resizing and right click for dragging. The | 156 | enabled, left click is used for resizing and right click for dragging. The |
157 | mode paramenter is optional and defaults to _normal_ if it isn't defined. | 157 | mode paramenter is optional and defaults to _normal_ if it isn't defined. |
158 | 158 | ||
159 | **floating_scroll** behavior <gaps_inner|gaps_outer|custom>:: | ||
160 | If set to _gaps_inner_, adjusts inner gaps of the windows on scrolling | ||
161 | while holding the floating modifier. If set to _gaps_outer_, adjusts | ||
162 | outer gaps. If set to _custom_, performs user-defined commands, | ||
163 | specified in *floating_scroll up|down*. | ||
164 | |||
165 | **floating_scroll** <up|down> [command]:: | 159 | **floating_scroll** <up|down> [command]:: |
166 | Sets the command to be executed on scrolling up and down | 160 | Sets the command to be executed on scrolling up and down |
167 | (respectively) while holding the floating modifier, when | 161 | (respectively) while holding the floating modifier. Resets the |
168 | *floating_scroll behavior* is set to _custom_. Resets the command, | 162 | command, when given no arguments. |
169 | when given none. | ||
170 | 163 | ||
171 | **focus_follows_mouse** <yes|no>:: | 164 | **focus_follows_mouse** <yes|no>:: |
172 | If set to _yes_, the currently focused view will change as you move your | 165 | If set to _yes_, the currently focused view will change as you move your |