Merge pull request #2680 from Airblader/feature-2677
[#2677] Allow using left/right scrolling like up/down scrolling.
This commit is contained in:
commit
4a2d5da044
|
@ -531,7 +531,8 @@ void handle_button(xcb_button_press_event_t *event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event->detail) {
|
switch (event->detail) {
|
||||||
case 4:
|
case XCB_BUTTON_SCROLL_UP:
|
||||||
|
case XCB_BUTTON_SCROLL_LEFT:
|
||||||
/* Mouse wheel up. We select the previous ws, if any.
|
/* Mouse wheel up. We select the previous ws, if any.
|
||||||
* If there is no more workspace, don’t even send the workspace
|
* If there is no more workspace, don’t even send the workspace
|
||||||
* command, otherwise (with workspace auto_back_and_forth) we’d end
|
* command, otherwise (with workspace auto_back_and_forth) we’d end
|
||||||
|
@ -541,7 +542,8 @@ void handle_button(xcb_button_press_event_t *event) {
|
||||||
|
|
||||||
cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq);
|
cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case XCB_BUTTON_SCROLL_DOWN:
|
||||||
|
case XCB_BUTTON_SCROLL_RIGHT:
|
||||||
/* Mouse wheel down. We select the next ws, if any.
|
/* Mouse wheel down. We select the next ws, if any.
|
||||||
* If there is no more workspace, don’t even send the workspace
|
* If there is no more workspace, don’t even send the workspace
|
||||||
* command, otherwise (with workspace auto_back_and_forth) we’d end
|
* command, otherwise (with workspace auto_back_and_forth) we’d end
|
||||||
|
|
|
@ -24,6 +24,16 @@
|
||||||
|
|
||||||
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||||
|
|
||||||
|
/** Mouse buttons */
|
||||||
|
#define XCB_BUTTON_CLICK_LEFT XCB_BUTTON_INDEX_1
|
||||||
|
#define XCB_BUTTON_CLICK_MIDDLE XCB_BUTTON_INDEX_2
|
||||||
|
#define XCB_BUTTON_CLICK_RIGHT XCB_BUTTON_INDEX_3
|
||||||
|
#define XCB_BUTTON_SCROLL_UP XCB_BUTTON_INDEX_4
|
||||||
|
#define XCB_BUTTON_SCROLL_DOWN XCB_BUTTON_INDEX_5
|
||||||
|
/* xcb doesn't define constants for these. */
|
||||||
|
#define XCB_BUTTON_SCROLL_LEFT 6
|
||||||
|
#define XCB_BUTTON_SCROLL_RIGHT 7
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XCB connection and root screen
|
* XCB connection and root screen
|
||||||
*
|
*
|
||||||
|
|
26
src/click.c
26
src/click.c
|
@ -178,8 +178,8 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
if (con->parent->type == CT_DOCKAREA)
|
if (con->parent->type == CT_DOCKAREA)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
const bool is_left_or_right_click = (event->detail == XCB_BUTTON_INDEX_1 ||
|
const bool is_left_or_right_click = (event->detail == XCB_BUTTON_CLICK_LEFT ||
|
||||||
event->detail == XCB_BUTTON_INDEX_3);
|
event->detail == XCB_BUTTON_CLICK_RIGHT);
|
||||||
|
|
||||||
/* if the user has bound an action to this click, it should override the
|
/* if the user has bound an action to this click, it should override the
|
||||||
* default behavior. */
|
* default behavior. */
|
||||||
|
@ -228,8 +228,10 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
/* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
|
/* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
|
||||||
if (in_stacked &&
|
if (in_stacked &&
|
||||||
dest == CLICK_DECORATION &&
|
dest == CLICK_DECORATION &&
|
||||||
(event->detail == XCB_BUTTON_INDEX_4 ||
|
(event->detail == XCB_BUTTON_SCROLL_UP ||
|
||||||
event->detail == XCB_BUTTON_INDEX_5)) {
|
event->detail == XCB_BUTTON_SCROLL_DOWN ||
|
||||||
|
event->detail == XCB_BUTTON_SCROLL_LEFT ||
|
||||||
|
event->detail == XCB_BUTTON_SCROLL_RIGHT)) {
|
||||||
DLOG("Scrolling on a window decoration\n");
|
DLOG("Scrolling on a window decoration\n");
|
||||||
orientation_t orientation = (con->parent->layout == L_STACKED ? VERT : HORIZ);
|
orientation_t orientation = (con->parent->layout == L_STACKED ? VERT : HORIZ);
|
||||||
/* Focus the currently focused container on the same level that the
|
/* Focus the currently focused container on the same level that the
|
||||||
|
@ -244,10 +246,12 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
* #557), we first check if scrolling is possible at all. */
|
* #557), we first check if scrolling is possible at all. */
|
||||||
bool scroll_prev_possible = (TAILQ_PREV(focused, nodes_head, nodes) != NULL);
|
bool scroll_prev_possible = (TAILQ_PREV(focused, nodes_head, nodes) != NULL);
|
||||||
bool scroll_next_possible = (TAILQ_NEXT(focused, nodes) != NULL);
|
bool scroll_next_possible = (TAILQ_NEXT(focused, nodes) != NULL);
|
||||||
if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
|
if ((event->detail == XCB_BUTTON_SCROLL_UP || event->detail == XCB_BUTTON_SCROLL_LEFT) && scroll_prev_possible) {
|
||||||
tree_next('p', orientation);
|
tree_next('p', orientation);
|
||||||
else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
|
} else if ((event->detail == XCB_BUTTON_SCROLL_DOWN || event->detail == XCB_BUTTON_SCROLL_RIGHT) && scroll_next_possible) {
|
||||||
tree_next('n', orientation);
|
tree_next('n', orientation);
|
||||||
|
}
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +265,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
floating_raise_con(floatingcon);
|
floating_raise_con(floatingcon);
|
||||||
|
|
||||||
/* 4: floating_modifier plus left mouse button drags */
|
/* 4: floating_modifier plus left mouse button drags */
|
||||||
if (mod_pressed && event->detail == XCB_BUTTON_INDEX_1) {
|
if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) {
|
||||||
floating_drag_window(floatingcon, event);
|
floating_drag_window(floatingcon, event);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +273,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
/* 5: resize (floating) if this was a (left or right) click on the
|
/* 5: resize (floating) if this was a (left or right) click on the
|
||||||
* left/right/bottom border, or a right click on the decoration.
|
* left/right/bottom border, or a right click on the decoration.
|
||||||
* also try resizing (tiling) if it was a click on the top */
|
* also try resizing (tiling) if it was a click on the top */
|
||||||
if (mod_pressed && event->detail == XCB_BUTTON_INDEX_3) {
|
if (mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
||||||
DLOG("floating resize due to floatingmodifier\n");
|
DLOG("floating resize due to floatingmodifier\n");
|
||||||
floating_resize_window(floatingcon, proportional, event);
|
floating_resize_window(floatingcon, proportional, event);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -283,7 +287,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_INDEX_3) {
|
if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
||||||
DLOG("floating resize due to decoration right click\n");
|
DLOG("floating resize due to decoration right click\n");
|
||||||
floating_resize_window(floatingcon, proportional, event);
|
floating_resize_window(floatingcon, proportional, event);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -298,7 +302,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
/* 6: dragging, if this was a click on a decoration (which did not lead
|
/* 6: dragging, if this was a click on a decoration (which did not lead
|
||||||
* to a resize) */
|
* to a resize) */
|
||||||
if (!in_stacked && dest == CLICK_DECORATION &&
|
if (!in_stacked && dest == CLICK_DECORATION &&
|
||||||
(event->detail == XCB_BUTTON_INDEX_1)) {
|
(event->detail == XCB_BUTTON_CLICK_LEFT)) {
|
||||||
floating_drag_window(floatingcon, event);
|
floating_drag_window(floatingcon, event);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +317,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 7: floating modifier pressed, initiate a resize */
|
/* 7: floating modifier pressed, initiate a resize */
|
||||||
if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_INDEX_3) {
|
if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
||||||
if (floating_mod_on_tiled_client(con, event))
|
if (floating_mod_on_tiled_client(con, event))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue