@ -1,9 +1,7 @@
# include <string.h>
# include <libevdev/libevdev.h>
# include <strings.h>
# include <errno.h>
# include "sway/config.h"
# include "sway/config.h"
# include "sway/commands.h"
# include "sway/commands.h"
# include "sway/input/ input-manage r.h"
# include "sway/input/ curso r.h"
struct cmd_results * input_cmd_scroll_button ( int argc , char * * argv ) {
struct cmd_results * input_cmd_scroll_button ( int argc , char * * argv ) {
struct cmd_results * error = NULL ;
struct cmd_results * error = NULL ;
@ -16,22 +14,26 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
" No input device defined. " ) ;
" No input device defined. " ) ;
}
}
errno = 0 ;
if ( strcmp ( * argv , " disable " ) = = 0 ) {
char * endptr ;
ic - > scroll_button = 0 ;
int scroll_button = strtol ( * argv , & endptr , 10 ) ;
return cmd_results_new ( CMD_SUCCESS , NULL , NULL ) ;
if ( endptr = = * argv & & scroll_button = = 0 ) {
return cmd_results_new ( CMD_INVALID , " scroll_button " ,
" Scroll button identifier must be an integer. " ) ;
}
}
if ( errno = = ERANGE ) {
char * message = NULL ;
uint32_t button = get_mouse_button ( * argv , & message ) ;
if ( message ) {
error = cmd_results_new ( CMD_INVALID , " scroll_button " , message ) ;
free ( message ) ;
return error ;
} else if ( button = = SWAY_SCROLL_UP | | button = = SWAY_SCROLL_DOWN
| | button = = SWAY_SCROLL_LEFT | | button = = SWAY_SCROLL_RIGHT ) {
return cmd_results_new ( CMD_INVALID , " scroll_button " ,
return cmd_results_new ( CMD_INVALID , " scroll_button " ,
" Scroll button identifier out of range. " ) ;
" X11 axis buttons are not supported for scroll_button " ) ;
}
} else if ( ! button ) {
if ( scroll_button < 0 ) {
return cmd_results_new ( CMD_INVALID , " scroll_button " ,
return cmd_results_new ( CMD_INVALID , " scroll_button " ,
" Scroll button identifier cannot be negative. " ) ;
" Unknown button %s" , * argv ) ;
}
}
ic - > scroll_button = scroll_button ;
ic - > scroll_button = button;
return cmd_results_new ( CMD_SUCCESS , NULL , NULL ) ;
return cmd_results_new ( CMD_SUCCESS , NULL , NULL ) ;
}
}