add mouse_scroll_workspaces bar setting

This commit is contained in:
Zandr Martin 2017-01-11 09:06:21 -05:00
parent 84358788aa
commit 5090c131db
No known key found for this signature in database
GPG key ID: AA2BB8EF77F7BBDC
9 changed files with 48 additions and 5 deletions

View file

@ -152,22 +152,23 @@ sway_cmd bar_cmd_binding_mode_indicator;
sway_cmd bar_cmd_bindsym;
sway_cmd bar_cmd_colors;
sway_cmd bar_cmd_font;
sway_cmd bar_cmd_mode;
sway_cmd bar_cmd_modifier;
sway_cmd bar_cmd_output;
sway_cmd bar_cmd_height;
sway_cmd bar_cmd_hidden_state;
sway_cmd bar_cmd_id;
sway_cmd bar_cmd_mode;
sway_cmd bar_cmd_modifier;
sway_cmd bar_cmd_mouse_scroll_workspaces;
sway_cmd bar_cmd_output;
sway_cmd bar_cmd_pango_markup;
sway_cmd bar_cmd_position;
sway_cmd bar_cmd_separator_symbol;
sway_cmd bar_cmd_status_command;
sway_cmd bar_cmd_pango_markup;
sway_cmd bar_cmd_strip_workspace_numbers;
sway_cmd bar_cmd_swaybar_command;
sway_cmd bar_cmd_tray_output;
sway_cmd bar_cmd_tray_padding;
sway_cmd bar_cmd_wrap_scroll;
sway_cmd bar_cmd_workspace_buttons;
sway_cmd bar_cmd_wrap_scroll;
sway_cmd bar_colors_cmd_active_workspace;
sway_cmd bar_colors_cmd_background;

View file

@ -135,6 +135,7 @@ struct bar_config {
int height; // -1 not defined
int tray_padding;
bool workspace_buttons;
bool mouse_scroll_workspaces;
bool wrap_scroll;
char *separator_symbol;
bool strip_workspace_numbers;

View file

@ -28,6 +28,7 @@ struct config {
char *mode;
bool strip_workspace_numbers;
bool binding_mode_indicator;
bool mouse_scroll_workspaces;
bool wrap_scroll;
bool workspace_buttons;
bool all_outputs;

View file

@ -0,0 +1,29 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "sway/commands.h"
#include "log.h"
struct cmd_results *bar_cmd_mouse_scroll_workspaces(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "mouse_scroll_workspaces", EXPECTED_EQUAL_TO, 1))) {
return error;
}
if (!config->current_bar) {
return cmd_results_new(CMD_FAILURE, "mouse_scroll_workspaces", "No bar defined.");
}
if (strcasecmp("yes", argv[0]) == 0) {
config->current_bar->mouse_scroll_workspaces = true;
sway_log(L_DEBUG, "Enabling workspace changing by mouse scroll wheel on bar: %s", config->current_bar->id);
} else if (strcasecmp("no", argv[0]) == 0) {
config->current_bar->mouse_scroll_workspaces = false;
sway_log(L_DEBUG, "Disabling workspace changing by mouse scroll wheel on bar: %s", config->current_bar->id);
} else {
error = cmd_results_new(CMD_INVALID, "mouse_scroll_workspaces", "Invalid value %s", argv[0]);
return error;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}

View file

@ -1,4 +1,5 @@
#include <string.h>
#include <stdbool.h>
#include "sway/commands.h"
#include "log.h"

View file

@ -1291,6 +1291,7 @@ struct bar_config *default_bar_config(void) {
bar->font = NULL;
bar->height = -1;
bar->workspace_buttons = true;
bar->mouse_scroll_workspaces = true;
bar->wrap_scroll = false;
bar->separator_symbol = NULL;
bar->strip_workspace_numbers = false;

View file

@ -48,6 +48,10 @@ Commands
**separator_symbol** <symbol>::
Specifies the separator symbol to separate blocks on the bar.
**mouse_scroll_workspaces** <yes|no>::
Enables or disables workspace switching using the mouse scroll wheel.
Default is yes.
**wrap_scroll** <yes|no>::
Enables or disables wrapping when scrolling through workspaces with the
scroll wheel. Default is no.

View file

@ -95,6 +95,10 @@ static void mouse_button_notify(struct window *window, int x, int y,
static void mouse_scroll_notify(struct window *window, enum scroll_direction direction) {
sway_log(L_DEBUG, "Mouse wheel scrolled %s", direction == SCROLL_UP ? "up" : "down");
if (!swaybar.config->mouse_scroll_workspaces) {
return;
}
if (!swaybar.config->wrap_scroll) {
// Find output this window lives on
int i;

View file

@ -40,6 +40,7 @@ struct config *init_config() {
config->sep_symbol = NULL;
config->strip_workspace_numbers = false;
config->binding_mode_indicator = true;
config->mouse_scroll_workspaces = true;
config->wrap_scroll = false;
config->workspace_buttons = true;
config->all_outputs = false;