mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
add mouse_scroll_workspaces bar setting
This commit is contained in:
parent
84358788aa
commit
5090c131db
|
@ -152,22 +152,23 @@ sway_cmd bar_cmd_binding_mode_indicator;
|
||||||
sway_cmd bar_cmd_bindsym;
|
sway_cmd bar_cmd_bindsym;
|
||||||
sway_cmd bar_cmd_colors;
|
sway_cmd bar_cmd_colors;
|
||||||
sway_cmd bar_cmd_font;
|
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_height;
|
||||||
sway_cmd bar_cmd_hidden_state;
|
sway_cmd bar_cmd_hidden_state;
|
||||||
sway_cmd bar_cmd_id;
|
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_position;
|
||||||
sway_cmd bar_cmd_separator_symbol;
|
sway_cmd bar_cmd_separator_symbol;
|
||||||
sway_cmd bar_cmd_status_command;
|
sway_cmd bar_cmd_status_command;
|
||||||
sway_cmd bar_cmd_pango_markup;
|
|
||||||
sway_cmd bar_cmd_strip_workspace_numbers;
|
sway_cmd bar_cmd_strip_workspace_numbers;
|
||||||
sway_cmd bar_cmd_swaybar_command;
|
sway_cmd bar_cmd_swaybar_command;
|
||||||
sway_cmd bar_cmd_tray_output;
|
sway_cmd bar_cmd_tray_output;
|
||||||
sway_cmd bar_cmd_tray_padding;
|
sway_cmd bar_cmd_tray_padding;
|
||||||
sway_cmd bar_cmd_wrap_scroll;
|
|
||||||
sway_cmd bar_cmd_workspace_buttons;
|
sway_cmd bar_cmd_workspace_buttons;
|
||||||
|
sway_cmd bar_cmd_wrap_scroll;
|
||||||
|
|
||||||
sway_cmd bar_colors_cmd_active_workspace;
|
sway_cmd bar_colors_cmd_active_workspace;
|
||||||
sway_cmd bar_colors_cmd_background;
|
sway_cmd bar_colors_cmd_background;
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct bar_config {
|
||||||
int height; // -1 not defined
|
int height; // -1 not defined
|
||||||
int tray_padding;
|
int tray_padding;
|
||||||
bool workspace_buttons;
|
bool workspace_buttons;
|
||||||
|
bool mouse_scroll_workspaces;
|
||||||
bool wrap_scroll;
|
bool wrap_scroll;
|
||||||
char *separator_symbol;
|
char *separator_symbol;
|
||||||
bool strip_workspace_numbers;
|
bool strip_workspace_numbers;
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct config {
|
||||||
char *mode;
|
char *mode;
|
||||||
bool strip_workspace_numbers;
|
bool strip_workspace_numbers;
|
||||||
bool binding_mode_indicator;
|
bool binding_mode_indicator;
|
||||||
|
bool mouse_scroll_workspaces;
|
||||||
bool wrap_scroll;
|
bool wrap_scroll;
|
||||||
bool workspace_buttons;
|
bool workspace_buttons;
|
||||||
bool all_outputs;
|
bool all_outputs;
|
||||||
|
|
29
sway/commands/bar/mouse_scroll_workspaces.c
Normal file
29
sway/commands/bar/mouse_scroll_workspaces.c
Normal 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);
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
|
@ -1291,6 +1291,7 @@ struct bar_config *default_bar_config(void) {
|
||||||
bar->font = NULL;
|
bar->font = NULL;
|
||||||
bar->height = -1;
|
bar->height = -1;
|
||||||
bar->workspace_buttons = true;
|
bar->workspace_buttons = true;
|
||||||
|
bar->mouse_scroll_workspaces = true;
|
||||||
bar->wrap_scroll = false;
|
bar->wrap_scroll = false;
|
||||||
bar->separator_symbol = NULL;
|
bar->separator_symbol = NULL;
|
||||||
bar->strip_workspace_numbers = false;
|
bar->strip_workspace_numbers = false;
|
||||||
|
|
|
@ -48,6 +48,10 @@ Commands
|
||||||
**separator_symbol** <symbol>::
|
**separator_symbol** <symbol>::
|
||||||
Specifies the separator symbol to separate blocks on the bar.
|
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>::
|
**wrap_scroll** <yes|no>::
|
||||||
Enables or disables wrapping when scrolling through workspaces with the
|
Enables or disables wrapping when scrolling through workspaces with the
|
||||||
scroll wheel. Default is no.
|
scroll wheel. Default is no.
|
||||||
|
|
|
@ -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) {
|
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");
|
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) {
|
if (!swaybar.config->wrap_scroll) {
|
||||||
// Find output this window lives on
|
// Find output this window lives on
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct config *init_config() {
|
||||||
config->sep_symbol = NULL;
|
config->sep_symbol = NULL;
|
||||||
config->strip_workspace_numbers = false;
|
config->strip_workspace_numbers = false;
|
||||||
config->binding_mode_indicator = true;
|
config->binding_mode_indicator = true;
|
||||||
|
config->mouse_scroll_workspaces = true;
|
||||||
config->wrap_scroll = false;
|
config->wrap_scroll = false;
|
||||||
config->workspace_buttons = true;
|
config->workspace_buttons = true;
|
||||||
config->all_outputs = false;
|
config->all_outputs = false;
|
||||||
|
|
Loading…
Reference in a new issue