diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-03-30 08:34:32 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-03-30 08:34:32 -0400 |
commit | a12850444d38cc1b00e30adb6dea82b6e2045914 (patch) | |
tree | 60b01009710f0379a5ff08f777405ebba93736a3 | |
parent | Update README screenshot (diff) | |
download | sway-a12850444d38cc1b00e30adb6dea82b6e2045914.tar.gz sway-a12850444d38cc1b00e30adb6dea82b6e2045914.tar.zst sway-a12850444d38cc1b00e30adb6dea82b6e2045914.zip |
New feature: adjust gaps with floating_mod+scroll
I made this configurable but I didn't make the command for it. That's
left as an exercise to an eager contributor.
mod_scroll_behavior [gaps inner|gaps outer]
Would merge implementions of more behaviors for mod+scroll, if anyone
has some neato ideas.
-rw-r--r-- | include/config.h | 8 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/handlers.c | 25 |
3 files changed, 34 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h index fb84423c..0ef8c5bf 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -163,6 +163,13 @@ enum edge_border_types { | |||
163 | E_BOTH /**< hide vertical and horizontal edge borders */ | 163 | E_BOTH /**< hide vertical and horizontal edge borders */ |
164 | }; | 164 | }; |
165 | 165 | ||
166 | enum floating_scroll_behavior { | ||
167 | FSB_GAPS_OUTER, /**< Adjust outer gaps */ | ||
168 | FSB_GAPS_INNER /**< Adjust inner gaps */ | ||
169 | // Note: in the future I expect to see more things you can do with the scroll | ||
170 | // wheel than maniuplating gaps | ||
171 | }; | ||
172 | |||
166 | /** | 173 | /** |
167 | * The configuration struct. The result of loading a config file. | 174 | * The configuration struct. The result of loading a config file. |
168 | */ | 175 | */ |
@@ -181,6 +188,7 @@ struct sway_config { | |||
181 | uint32_t floating_mod; | 188 | uint32_t floating_mod; |
182 | uint32_t dragging_key; | 189 | uint32_t dragging_key; |
183 | uint32_t resizing_key; | 190 | uint32_t resizing_key; |
191 | enum floating_scroll_behavior floating_scroll; // TODO: command to set this | ||
184 | enum swayc_layouts default_orientation; | 192 | enum swayc_layouts default_orientation; |
185 | enum swayc_layouts default_layout; | 193 | enum swayc_layouts default_layout; |
186 | char *font; | 194 | char *font; |
diff --git a/sway/config.c b/sway/config.c index 5501ab31..f6241a3d 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -159,6 +159,7 @@ static void config_defaults(struct sway_config *config) { | |||
159 | config->floating_mod = 0; | 159 | config->floating_mod = 0; |
160 | config->dragging_key = M_LEFT_CLICK; | 160 | config->dragging_key = M_LEFT_CLICK; |
161 | config->resizing_key = M_RIGHT_CLICK; | 161 | config->resizing_key = M_RIGHT_CLICK; |
162 | config->floating_scroll = FSB_GAPS_INNER; | ||
162 | config->default_layout = L_NONE; | 163 | config->default_layout = L_NONE; |
163 | config->default_orientation = L_NONE; | 164 | config->default_orientation = L_NONE; |
164 | config->font = strdup("monospace 10"); | 165 | config->font = strdup("monospace 10"); |
diff --git a/sway/handlers.c b/sway/handlers.c index 54326dd0..9648e729 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -647,6 +647,31 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
647 | case M_SCROLL_DOWN: | 647 | case M_SCROLL_DOWN: |
648 | break; | 648 | break; |
649 | } | 649 | } |
650 | if (!(modifiers->mods ^ config->floating_mod) && | ||
651 | (button == M_SCROLL_UP || button == M_SCROLL_DOWN)) { | ||
652 | switch (config->floating_scroll) { | ||
653 | case FSB_GAPS_INNER: | ||
654 | case FSB_GAPS_OUTER: | ||
655 | { | ||
656 | int amount = button == M_SCROLL_UP ? -1 : 1; | ||
657 | int i,j; | ||
658 | for (i = 0; i < root_container.children->length; ++i) { | ||
659 | swayc_t *op = root_container.children->items[i]; | ||
660 | for (j = 0; j < op->children->length; ++j) { | ||
661 | swayc_t *ws = op->children->items[j]; | ||
662 | // TODO: adjust outer gaps ws->gaps = 0; | ||
663 | if (config->floating_scroll == FSB_GAPS_INNER) { | ||
664 | container_map(ws, add_gaps, &amount); | ||
665 | } else { | ||
666 | ws->gaps += amount; | ||
667 | } | ||
668 | } | ||
669 | } | ||
670 | arrange_windows(&root_container, -1, -1); | ||
671 | break; | ||
672 | } | ||
673 | } | ||
674 | } | ||
650 | 675 | ||
651 | // get focused window and check if to change focus on mouse click | 676 | // get focused window and check if to change focus on mouse click |
652 | swayc_t *focused = get_focused_container(&root_container); | 677 | swayc_t *focused = get_focused_container(&root_container); |