summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+github@sardemff7.net>2017-12-26 10:10:40 +0100
committerDave Davenport <DaveDavenport@users.noreply.github.com>2017-12-26 10:10:40 +0100
commit101c4dcc267fd112fa24e154ac97035540e1e018 (patch)
tree934e13e3751ae54ec9c9ba54c72a6361da5c1056
parent14993a5a98a816de8a0e67368f3f4363980c0adc (diff)
bindings: Rework mouse bindings (#745)
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--doc/test_xr.txt14
-rw-r--r--releasenotes/1.5.0/release-1.5.0.markdown25
-rw-r--r--source/keyb.c22
-rw-r--r--source/xcb.c67
m---------subprojects/libnkutils0
5 files changed, 108 insertions, 20 deletions
diff --git a/doc/test_xr.txt b/doc/test_xr.txt
index a3d1534f..e68606df 100644
--- a/doc/test_xr.txt
+++ b/doc/test_xr.txt
@@ -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
diff --git a/releasenotes/1.5.0/release-1.5.0.markdown b/releasenotes/1.5.0/release-1.5.0.markdown
index fdeb0063..ea5567ed 100644
--- a/releasenotes/1.5.0/release-1.5.0.markdown
+++ b/releasenotes/1.5.0/release-1.5.0.markdown
@@ -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
diff --git a/source/keyb.c b/source/keyb.c
index 24db1f33..01ad1eb8 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -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 )
diff --git a/source/xcb.c b/source/xcb.c
index 85a40fd4..c637cc71 100644
--- a/source/xcb.c
+++ b/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 );
diff --git a/subprojects/libnkutils b/subprojects/libnkutils
-Subproject 3c620ed303781260337c0bd9fc691e3b675511e
+Subproject 1f0e3b3d12aa39d9f01c4b0bc9a2de34e79184c