diff options
-rw-r--r-- | include/config.h | 10 | ||||
-rw-r--r-- | sway/commands.c | 28 | ||||
-rw-r--r-- | sway/config.c | 5 | ||||
-rw-r--r-- | sway/handlers.c | 25 | ||||
-rw-r--r-- | sway/sway.5.txt | 5 |
5 files changed, 44 insertions, 29 deletions
diff --git a/include/config.h b/include/config.h index 8e5e33c3..e15ba311 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -166,13 +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 | // Note: in the future I expect to see more things you can do with the scroll | ||
173 | // wheel than maniuplating gaps | ||
174 | }; | ||
175 | |||
176 | /** | 169 | /** |
177 | * The configuration struct. The result of loading a config file. | 170 | * The configuration struct. The result of loading a config file. |
178 | */ | 171 | */ |
@@ -191,7 +184,8 @@ struct sway_config { | |||
191 | uint32_t floating_mod; | 184 | uint32_t floating_mod; |
192 | uint32_t dragging_key; | 185 | uint32_t dragging_key; |
193 | uint32_t resizing_key; | 186 | uint32_t resizing_key; |
194 | enum floating_scroll_behavior floating_scroll; // TODO: command to set this | 187 | char *floating_scroll_up_cmd; |
188 | char *floating_scroll_down_cmd; | ||
195 | enum swayc_layouts default_orientation; | 189 | enum swayc_layouts default_orientation; |
196 | enum swayc_layouts default_layout; | 190 | enum swayc_layouts default_layout; |
197 | char *font; | 191 | char *font; |
diff --git a/sway/commands.c b/sway/commands.c index 9b0356c4..5a592555 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -58,6 +58,7 @@ static sway_cmd cmd_exec_always; | |||
58 | static sway_cmd cmd_exit; | 58 | static sway_cmd cmd_exit; |
59 | static sway_cmd cmd_floating; | 59 | static sway_cmd cmd_floating; |
60 | static sway_cmd cmd_floating_mod; | 60 | static sway_cmd cmd_floating_mod; |
61 | static sway_cmd cmd_floating_scroll; | ||
61 | static sway_cmd cmd_focus; | 62 | static sway_cmd cmd_focus; |
62 | static sway_cmd cmd_focus_follows_mouse; | 63 | static sway_cmd cmd_focus_follows_mouse; |
63 | static sway_cmd cmd_font; | 64 | static sway_cmd cmd_font; |
@@ -705,6 +706,32 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) { | |||
705 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 706 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
706 | } | 707 | } |
707 | 708 | ||
709 | static struct cmd_results *cmd_floating_scroll(int argc, char **argv) { | ||
710 | struct cmd_results *error = NULL; | ||
711 | if ((error = checkarg(argc, "floating_scroll", EXPECTED_AT_LEAST, 1))) { | ||
712 | return error; | ||
713 | } | ||
714 | if (!strcasecmp("up", argv[0])) { | ||
715 | free(config->floating_scroll_up_cmd); | ||
716 | if (argc < 2) { | ||
717 | config->floating_scroll_up_cmd = strdup(""); | ||
718 | } else { | ||
719 | config->floating_scroll_up_cmd = join_args(argv + 1, argc - 1); | ||
720 | } | ||
721 | } else if (!strcasecmp("down", argv[0])) { | ||
722 | free(config->floating_scroll_down_cmd); | ||
723 | if (argc < 2) { | ||
724 | config->floating_scroll_down_cmd = strdup(""); | ||
725 | } else { | ||
726 | config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1); | ||
727 | } | ||
728 | } else { | ||
729 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); | ||
730 | return error; | ||
731 | } | ||
732 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
733 | } | ||
734 | |||
708 | static struct cmd_results *cmd_focus(int argc, char **argv) { | 735 | static struct cmd_results *cmd_focus(int argc, char **argv) { |
709 | if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file."); | 736 | if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file."); |
710 | struct cmd_results *error = NULL; | 737 | struct cmd_results *error = NULL; |
@@ -2377,6 +2404,7 @@ static struct cmd_handler handlers[] = { | |||
2377 | { "exit", cmd_exit }, | 2404 | { "exit", cmd_exit }, |
2378 | { "floating", cmd_floating }, | 2405 | { "floating", cmd_floating }, |
2379 | { "floating_modifier", cmd_floating_mod }, | 2406 | { "floating_modifier", cmd_floating_mod }, |
2407 | { "floating_scroll", cmd_floating_scroll }, | ||
2380 | { "focus", cmd_focus }, | 2408 | { "focus", cmd_focus }, |
2381 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 2409 | { "focus_follows_mouse", cmd_focus_follows_mouse }, |
2382 | { "font", cmd_font }, | 2410 | { "font", cmd_font }, |
diff --git a/sway/config.c b/sway/config.c index 237d8996..6c1d21c8 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -131,6 +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->floating_scroll_up_cmd); | ||
135 | free(config->floating_scroll_down_cmd); | ||
134 | free(config); | 136 | free(config); |
135 | } | 137 | } |
136 | 138 | ||
@@ -159,7 +161,8 @@ static void config_defaults(struct sway_config *config) { | |||
159 | config->floating_mod = 0; | 161 | config->floating_mod = 0; |
160 | config->dragging_key = M_LEFT_CLICK; | 162 | config->dragging_key = M_LEFT_CLICK; |
161 | config->resizing_key = M_RIGHT_CLICK; | 163 | config->resizing_key = M_RIGHT_CLICK; |
162 | config->floating_scroll = FSB_GAPS_INNER; | 164 | config->floating_scroll_up_cmd = strdup(""); |
165 | config->floating_scroll_down_cmd = strdup(""); | ||
163 | config->default_layout = L_NONE; | 166 | config->default_layout = L_NONE; |
164 | config->default_orientation = L_NONE; | 167 | config->default_orientation = L_NONE; |
165 | config->font = strdup("monospace 10"); | 168 | config->font = strdup("monospace 10"); |
diff --git a/sway/handlers.c b/sway/handlers.c index b82456e2..67275575 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -723,26 +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 | } | 731 | } |
747 | } | 732 | } |
748 | return EVENT_PASSTHROUGH; | 733 | return EVENT_PASSTHROUGH; |
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index a2570dcd..25229033 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -156,6 +156,11 @@ 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** <up|down> [command]:: | ||
160 | Sets the command to be executed on scrolling up and down | ||
161 | (respectively) while holding the floating modifier. Resets the | ||
162 | command, when given no arguments. | ||
163 | |||
159 | **focus_follows_mouse** <yes|no>:: | 164 | **focus_follows_mouse** <yes|no>:: |
160 | 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 |
161 | mouse around the screen to the view that ends up underneath your mouse. | 166 | mouse around the screen to the view that ends up underneath your mouse. |