+ /* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
+ if (in_stacked &&
+ dest == CLICK_DECORATION &&
+ (event->detail == XCB_BUTTON_INDEX_4 ||
+ event->detail == XCB_BUTTON_INDEX_5)) {
+ DLOG("Scrolling on a window decoration\n");
+ orientation_t orientation = (con->parent->layout == L_STACKED ? VERT : HORIZ);
+ /* To prevent scrolling from going outside the container (see ticket
+ * #557), we first check if scrolling is possible at all. */
+ Con *focused = con_descend_focused(con->parent);
+ bool scroll_prev_possible = (TAILQ_PREV(focused, nodes_head, nodes) != NULL);
+ bool scroll_next_possible = (TAILQ_NEXT(focused, nodes) != NULL);
+ if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
+ tree_next('p', orientation);
+ else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
+ tree_next('n', orientation);
+ goto done;
+ }