mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
bindings: Rework mouse bindings (#745)
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
14993a5a98
commit
101c4dcc26
5 changed files with 109 additions and 21 deletions
|
@ -245,16 +245,16 @@ rofi.kb-custom-19: Alt+parenleft
|
|||
! "Select row 10" Set from: Default
|
||||
! rofi.kb-select-10: Super+0
|
||||
! "Go to the previous column" Set from: Default
|
||||
! rofi.ml-row-left: Mouse6
|
||||
! rofi.ml-row-left: ScrollLeft
|
||||
! "Go to the next column" Set from: Default
|
||||
! rofi.ml-row-right: Mouse7
|
||||
! rofi.ml-row-right: ScrollRight
|
||||
! "Select previous entry" Set from: Default
|
||||
! rofi.ml-row-up: Mouse4
|
||||
! rofi.ml-row-up: ScrollUp
|
||||
! "Select next entry" Set from: Default
|
||||
! rofi.ml-row-down: Mouse5
|
||||
! rofi.ml-row-down: ScrollDown
|
||||
! "Select hovered row" Set from: Default
|
||||
! rofi.me-select-entry: Mouse1
|
||||
! rofi.me-select-entry: MousePrimary
|
||||
! "Accept hovered row" Set from: Default
|
||||
! rofi.me-accept-entry: MouseD1
|
||||
! rofi.me-accept-entry: MouseDPrimary
|
||||
! "Accept hovered row with custom action" Set from: Default
|
||||
! rofi.me-accept-custom: Control+MouseD1
|
||||
! rofi.me-accept-custom: Control+MouseDPrimary
|
||||
|
|
|
@ -35,6 +35,31 @@ entry,prompt {
|
|||
}
|
||||
```
|
||||
|
||||
## Backward incompatible changes
|
||||
|
||||
### Mouse bindings
|
||||
|
||||
Mouse button and scroll bindings are now separated, and names have changed.
|
||||
|
||||
For the 3 base buttons:
|
||||
|
||||
- `Mouse1` is now `MousePrimary`
|
||||
- `Mouse2` is now `MouseMiddle`
|
||||
- `Mouse3` is `MouseSecondary`
|
||||
|
||||
For the scroll wheel:
|
||||
|
||||
- `Mouse4` is `ScrollUp`
|
||||
- `Mouse5` is `ScrollDown`
|
||||
- `Mouse6` is `ScrollLeft`
|
||||
- `Mouse7` is `ScrollRight`
|
||||
|
||||
For extra buttons:
|
||||
|
||||
- `Mouse8` is `MouseBack`
|
||||
- `Mouse9` is `MouseForward`
|
||||
- Above 10, you have to use the platform-specific `MouseExtra<number>` (replace `<number>`). Under X11, these buttons will go on from 10.
|
||||
|
||||
## Bug fixes
|
||||
|
||||
### Prompt colon
|
||||
|
|
|
@ -112,21 +112,21 @@ ActionBindingEntry rofi_bindings[] =
|
|||
|
||||
/* Mouse-aware bindings */
|
||||
|
||||
{ .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "Mouse6", .comment = "Go to the previous column" },
|
||||
{ .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "Mouse7", .comment = "Go to the next column" },
|
||||
{ .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "Mouse4", .comment = "Select previous entry" },
|
||||
{ .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "Mouse5", .comment = "Select next entry" },
|
||||
{ .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" },
|
||||
{ .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" },
|
||||
{ .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" },
|
||||
{ .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" },
|
||||
|
||||
{ .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "Mouse1", .comment = "Select hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseD1", .comment = "Accept hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseD1", .comment = "Accept hovered row with custom action" },
|
||||
{ .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action" },
|
||||
};
|
||||
|
||||
static const gchar *mouse_default_bindings[] = {
|
||||
[MOUSE_CLICK_DOWN] = "Mouse1",
|
||||
[MOUSE_CLICK_UP] = "!Mouse1",
|
||||
[MOUSE_DCLICK_DOWN] = "MouseD1",
|
||||
[MOUSE_DCLICK_UP] = "!MouseD1",
|
||||
[MOUSE_CLICK_DOWN] = "MousePrimary",
|
||||
[MOUSE_CLICK_UP] = "!MousePrimary",
|
||||
[MOUSE_DCLICK_DOWN] = "MouseDPrimary",
|
||||
[MOUSE_DCLICK_UP] = "!MouseDPrimary",
|
||||
};
|
||||
|
||||
void setup_abe ( void )
|
||||
|
|
67
source/xcb.c
67
source/xcb.c
|
@ -671,6 +671,59 @@ static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean x11_button_to_nk_bindings_button ( guint32 x11_button, NkBindingsMouseButton *button )
|
||||
{
|
||||
switch ( x11_button )
|
||||
{
|
||||
case 1:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_PRIMARY;
|
||||
break;
|
||||
case 3:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_SECONDARY;
|
||||
break;
|
||||
case 2:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
case 8:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_BACK;
|
||||
break;
|
||||
case 9:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_FORWARD;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return FALSE;
|
||||
default:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_EXTRA + x11_button;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean x11_button_to_nk_bindings_scroll ( guint32 x11_button, NkBindingsScrollAxis *axis, gint32 *steps )
|
||||
{
|
||||
*steps = 1;
|
||||
switch ( x11_button )
|
||||
{
|
||||
case 4:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 5:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
|
||||
break;
|
||||
case 6:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 7:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process X11 events in the main-loop (gui-thread) of the application.
|
||||
*/
|
||||
|
@ -704,16 +757,26 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
|
|||
case XCB_BUTTON_PRESS:
|
||||
{
|
||||
xcb_button_press_event_t *bpe = (xcb_button_press_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
NkBindingsScrollAxis axis;
|
||||
gint32 steps;
|
||||
|
||||
xcb->last_timestamp = bpe->time;
|
||||
rofi_view_handle_mouse_motion ( state, bpe->event_x, bpe->event_y );
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, bpe->detail, NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time );
|
||||
if ( x11_button_to_nk_bindings_button ( bpe->detail, &button ) )
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time );
|
||||
else if ( x11_button_to_nk_bindings_scroll ( bpe->detail, &axis, &steps) )
|
||||
nk_bindings_seat_handle_scroll ( xcb->bindings_seat, NULL, axis, steps );
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_RELEASE:
|
||||
{
|
||||
xcb_button_release_event_t *bre = (xcb_button_release_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
|
||||
xcb->last_timestamp = bre->time;
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, bre->detail, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||
if ( x11_button_to_nk_bindings_button ( bre->detail, &button ) )
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
if ( !xcb->mouse_seen ) {
|
||||
rofi_view_temp_click_to_exit ( state, bre->event );
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3c620ed303781260337c0bd9fc691e3b675511e0
|
||||
Subproject commit 1f0e3b3d12aa39d9f01c4b0bc9a2de34e79184c5
|
Loading…
Reference in a new issue