Example #1
0
struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
	struct cmd_results *error = NULL;
	if ((error = checkarg(argc, "scroll_button", EXPECTED_AT_LEAST, 1))) {
		return error;
	}
	struct input_config *ic = config->handler_context.input_config;
	if (!ic) {
		return cmd_results_new(CMD_FAILURE, "No input device defined.");
	}

	if (strcmp(*argv, "disable") == 0) {
		ic->scroll_button = 0;
		return cmd_results_new(CMD_SUCCESS, NULL);
	}

	char *message = NULL;
	uint32_t button = get_mouse_button(*argv, &message);
	if (message) {
		error = cmd_results_new(CMD_INVALID, 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,
				"X11 axis buttons are not supported for scroll_button");
	} else if (!button) {
		return cmd_results_new(CMD_INVALID, "Unknown button %s", *argv);
	}
	ic->scroll_button = button;

	return cmd_results_new(CMD_SUCCESS, NULL);
}
Example #2
0
static widget_handler_status_T
mouse_listbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
{
#ifdef CONFIG_MOUSE
	struct listbox_data *box = get_listbox_widget_data(widget_data);
	struct term_event *ev = dlg_data->term_event;

	if (!list_empty(*box->items)) {
		if (!box->top) box->top = (struct listbox_item *)box->items->next;
		if (!box->sel) box->sel = box->top;
	}

	if (check_mouse_action(ev, B_DOWN)) {
		struct widget_data *dlg_item = dlg_data->widgets_data;

		switch (get_mouse_button(ev)) {
			case B_WHEEL_DOWN:
				listbox_sel_move(dlg_item, 1);
				display_widget(dlg_data, dlg_item);
				return EVENT_PROCESSED;

			case B_WHEEL_UP:
				listbox_sel_move(dlg_item, -1);
				display_widget(dlg_data, dlg_item);
				return EVENT_PROCESSED;
		}
	}

	if (check_mouse_wheel(ev))
		return EVENT_NOT_PROCESSED;

	if (check_mouse_position(ev, &widget_data->box)) {
		/* Clicked in the box. */
		int offset = ev->info.mouse.y - widget_data->box.y;

		box->sel_offset = offset;
		box->sel = offset ? traverse_listbox_items_list(box->top, box,
								offset, 1,
								NULL, NULL)
				  : box->top;

		if (box->sel && box->sel->type == BI_FOLDER) {
			int xdepth = widget_data->box.x + box->sel->depth * 5;
			int x = ev->info.mouse.x;

			if (x >= xdepth && x <= xdepth + 2)
				box->sel->expanded = !box->sel->expanded;
		}

		display_widget(dlg_data, widget_data);

		return EVENT_PROCESSED;
	}

#endif /* CONFIG_MOUSE */

	return EVENT_NOT_PROCESSED;
}
Example #3
0
void load_mouse_actions(char *modefile, ViewInfo * v)
{
/*#define MM_PAN					0
#define MM_ZOOM					1
#define MM_ROTATE				2
#define MM_SINGLE_SELECT		3
#define MM_RECTANGULAR_SELECT	4
#define MM_RECTANGULAR_X_SELECT	5
#define MM_MOVE					10
#define MM_MAGNIFIER			20
#define MM_FISHEYE_MAGNIFIER	21*/
    /*file parsing is temporarrily not available */
    int i = 0;
    FILE *file;
    char line[BUFSIZ];
    char *a;
    char *action_file = smyrnaPath("mouse_actions.txt");
    file = fopen(action_file, "r");
    if (file != NULL) {
	int ind = 0;
	while (fgets(line, BUFSIZ, file) != NULL) {
	    int idx = 0;
	    a = strtok(line, ",");

	    if ((line[0] == '#') || (line[0] == ' ')
		|| (strlen(line) == 0))
		continue;

	    v->mouse_action_count++;
	    v->mouse_actions =
		realloc(v->mouse_actions,
			v->mouse_action_count * sizeof(mouse_action_t));
	    v->mouse_actions[ind].action = get_mouse_mode(a);
	    v->mouse_actions[ind].index = i;

	    while ((a = strtok(NULL, ","))) {
		//#Action(0),hotkey(1),view_mode(2),mouse_button(3),drag(4)
		switch (idx) {
		case 0:
		    v->mouse_actions[ind].hotkey = get_button(a);
		    break;
		case 1:
		    v->mouse_actions[ind].mode = get_view_mode(a);
		    break;
		case 2:
		    v->mouse_actions[ind].type = get_mouse_button(a);
		    break;
		case 3:
		    v->mouse_actions[ind].drag = get_drag(a);
		    break;

		}
		idx++;
	    }
	    ind++;
	}
	fclose(file);
    }
    free(action_file);


/*
    v->mouse_action_count=7;
    v->mouse_actions=realloc(v->mouse_actions,v->mouse_action_count * sizeof(mouse_action_t));
    v->mouse_actions[ind].action=MM_PAN;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_ROTATE;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LSHIFT;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_3D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_SINGLE_SELECT;
    v->mouse_actions[ind].drag=0;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all_but_fisheye;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_RECTANGULAR_SELECT;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all;
    v->mouse_actions[ind].type=glMouseRightButton;

    ind++;

    v->mouse_actions[ind].action=MM_MOVE;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LCTRL;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_2D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_FISHEYE_MAGNIFIER;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LSHIFT;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_2D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_FISHEYE_PICK;
    v->mouse_actions[ind].drag=0;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_fisheye;
    v->mouse_actions[ind].type=glMouseRightButton;
*/
}