Merge pull request #4005 from orestisfl/route_click_clutter
route_click readability improvements
This commit is contained in:
commit
62279aba45
32
src/click.c
32
src/click.c
|
@ -160,15 +160,10 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
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_CLICK_LEFT ||
|
|
||||||
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. */
|
||||||
if (dest == CLICK_DECORATION || dest == CLICK_INSIDE || dest == CLICK_BORDER) {
|
|
||||||
Binding *bind = get_binding_from_xcb_event((xcb_generic_event_t *)event);
|
Binding *bind = get_binding_from_xcb_event((xcb_generic_event_t *)event);
|
||||||
|
if (bind && ((dest == CLICK_DECORATION && !bind->exclude_titlebar) ||
|
||||||
if (bind != NULL && ((dest == CLICK_DECORATION && !bind->exclude_titlebar) ||
|
|
||||||
(dest == CLICK_INSIDE && bind->whole_window) ||
|
(dest == CLICK_INSIDE && bind->whole_window) ||
|
||||||
(dest == CLICK_BORDER && bind->border))) {
|
(dest == CLICK_BORDER && bind->border))) {
|
||||||
CommandResult *result = run_binding(bind, con);
|
CommandResult *result = run_binding(bind, con);
|
||||||
|
@ -180,7 +175,6 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
command_result_free(result);
|
command_result_free(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* There is no default behavior for button release events so we are done. */
|
/* There is no default behavior for button release events so we are done. */
|
||||||
if (event->response_type == XCB_BUTTON_RELEASE) {
|
if (event->response_type == XCB_BUTTON_RELEASE) {
|
||||||
|
@ -207,14 +201,16 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
const bool proportional = (event->state & XCB_KEY_BUT_MASK_SHIFT) == XCB_KEY_BUT_MASK_SHIFT;
|
const bool proportional = (event->state & XCB_KEY_BUT_MASK_SHIFT) == XCB_KEY_BUT_MASK_SHIFT;
|
||||||
const bool in_stacked = (con->parent->layout == L_STACKED || con->parent->layout == L_TABBED);
|
const bool in_stacked = (con->parent->layout == L_STACKED || con->parent->layout == L_TABBED);
|
||||||
const bool was_focused = focused == con;
|
const bool was_focused = focused == con;
|
||||||
|
const bool is_left_click = (event->detail == XCB_BUTTON_CLICK_LEFT);
|
||||||
/* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
|
const bool is_right_click = (event->detail == XCB_BUTTON_CLICK_RIGHT);
|
||||||
if (in_stacked &&
|
const bool is_left_or_right_click = (is_left_click || is_right_click);
|
||||||
dest == CLICK_DECORATION &&
|
const bool is_scroll = (event->detail == XCB_BUTTON_SCROLL_UP ||
|
||||||
(event->detail == XCB_BUTTON_SCROLL_UP ||
|
|
||||||
event->detail == XCB_BUTTON_SCROLL_DOWN ||
|
event->detail == XCB_BUTTON_SCROLL_DOWN ||
|
||||||
event->detail == XCB_BUTTON_SCROLL_LEFT ||
|
event->detail == XCB_BUTTON_SCROLL_LEFT ||
|
||||||
event->detail == XCB_BUTTON_SCROLL_RIGHT)) {
|
event->detail == XCB_BUTTON_SCROLL_RIGHT);
|
||||||
|
|
||||||
|
/* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
|
||||||
|
if (in_stacked && dest == CLICK_DECORATION && is_scroll) {
|
||||||
DLOG("Scrolling on a window decoration\n");
|
DLOG("Scrolling on a window decoration\n");
|
||||||
/* Use the focused child of the tabbed / stacked container, not the
|
/* Use the focused child of the tabbed / stacked container, not the
|
||||||
* container the user scrolled on. */
|
* container the user scrolled on. */
|
||||||
|
@ -235,7 +231,7 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
Con *fs = con_get_fullscreen_covering_ws(ws);
|
Con *fs = con_get_fullscreen_covering_ws(ws);
|
||||||
if (floatingcon != NULL && fs != con) {
|
if (floatingcon != NULL && fs != con) {
|
||||||
/* 4: floating_modifier plus left mouse button drags */
|
/* 4: floating_modifier plus left mouse button drags */
|
||||||
if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) {
|
if (mod_pressed && is_left_click) {
|
||||||
floating_drag_window(floatingcon, event, false);
|
floating_drag_window(floatingcon, event, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +239,7 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
/* 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 possible */
|
* also try resizing (tiling) if possible */
|
||||||
if (mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
if (mod_pressed && is_right_click) {
|
||||||
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;
|
return;
|
||||||
|
@ -257,7 +253,7 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
if (dest == CLICK_DECORATION && is_right_click) {
|
||||||
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;
|
return;
|
||||||
|
@ -271,7 +267,7 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
|
|
||||||
/* 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 (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_LEFT) {
|
if (dest == CLICK_DECORATION && is_left_click) {
|
||||||
floating_drag_window(floatingcon, event, !was_focused);
|
floating_drag_window(floatingcon, event, !was_focused);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +276,7 @@ static void route_click(Con *con, xcb_button_press_event_t *event, const bool mo
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 7: floating modifier pressed, initiate a resize */
|
/* 7: floating modifier pressed, initiate a resize */
|
||||||
if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
|
if (dest == CLICK_INSIDE && mod_pressed && is_right_click) {
|
||||||
floating_mod_on_tiled_client(con, event);
|
floating_mod_on_tiled_client(con, event);
|
||||||
/* Avoid propagating events to clients, since the user expects
|
/* Avoid propagating events to clients, since the user expects
|
||||||
* $mod + click to be handled by i3. */
|
* $mod + click to be handled by i3. */
|
||||||
|
|
Loading…
Reference in New Issue