Skip to content

Commit

Permalink
Implement mouse events for title bar (cmus#1025)
Browse files Browse the repository at this point in the history
* Implement mouse events for title bar (cmus#1015)

* Rename title binding

* Add default bindings for mouse_scroll_{up,down}_title to {left,right}-view
  • Loading branch information
pgaskin authored Dec 17, 2020
1 parent 3e5db69 commit 45c33cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Doc/cmus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ i win-sel-cur
space win-toggle
g, home win-top
k, up, mouse_scroll_up win-up
mouse_scroll_up_title left-view
mouse_scroll_down_title right-view
@endpre

@h2 Browser Context
Expand Down
2 changes: 2 additions & 0 deletions data/rc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ bind common y win-add-p
bind common z player-prev
bind common { vol -1% -0
bind common } vol -0 -1%
bind common mouse_scroll_up_title left-view
bind common mouse_scroll_down_title right-view
fset 90s=date>=1990&date<2000
fset classical=genre="Classical"
fset unheard=play_count=0
Expand Down
14 changes: 13 additions & 1 deletion keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static const enum key_context view_to_context[] = {
#define KEY_M_TYPE_NONE (0<<3)
#define KEY_M_TYPE_SEL (1<<3)
#define KEY_M_TYPE_BAR (2<<3)
#define KEY_M_TYPE_TIT (3<<3)

#define KEY_MLB_CLICK 0
#define KEY_MRB_CLICK 1
Expand All @@ -70,6 +71,10 @@ static const enum key_context view_to_context[] = {
#define KEY_MRB_CLICK_BAR (KEY_MRB_CLICK|KEY_M_TYPE_BAR)
#define KEY_MSCRL_UP_BAR (KEY_MSCRL_UP|KEY_M_TYPE_BAR)
#define KEY_MSCRL_DOWN_BAR (KEY_MSCRL_DOWN|KEY_M_TYPE_BAR)
#define KEY_MLB_CLICK_TIT (KEY_MLB_CLICK|KEY_M_TYPE_TIT)
#define KEY_MRB_CLICK_TIT (KEY_MRB_CLICK|KEY_M_TYPE_TIT)
#define KEY_MSCRL_UP_TIT (KEY_MSCRL_UP|KEY_M_TYPE_TIT)
#define KEY_MSCRL_DOWN_TIT (KEY_MSCRL_DOWN|KEY_M_TYPE_TIT)

/* key_table {{{
*
Expand Down Expand Up @@ -430,13 +435,17 @@ const struct key key_table[] = {
{ "mlb_click", KEY_MOUSE, KEY_MLB_CLICK },
{ "mlb_click_selected", KEY_MOUSE, KEY_MLB_CLICK_SEL },
{ "mlb_click_bar", KEY_MOUSE, KEY_MLB_CLICK_BAR },
{ "mlb_click_title", KEY_MOUSE, KEY_MLB_CLICK_TIT },
{ "mrb_click", KEY_MOUSE, KEY_MRB_CLICK },
{ "mrb_click_selected", KEY_MOUSE, KEY_MRB_CLICK_SEL },
{ "mrb_click_bar", KEY_MOUSE, KEY_MRB_CLICK_BAR },
{ "mrb_click_title", KEY_MOUSE, KEY_MRB_CLICK_TIT },
{ "mouse_scroll_up", KEY_MOUSE, KEY_MSCRL_UP },
{ "mouse_scroll_up_bar", KEY_MOUSE, KEY_MSCRL_UP_BAR },
{ "mouse_scroll_up_title", KEY_MOUSE, KEY_MSCRL_UP_TIT },
{ "mouse_scroll_down", KEY_MOUSE, KEY_MSCRL_DOWN },
{ "mouse_scroll_down_bar", KEY_MOUSE, KEY_MSCRL_DOWN_BAR },
{ "mouse_scroll_down_title", KEY_MOUSE, KEY_MSCRL_DOWN_TIT },
{ NULL, 0, 0 }
};
/* }}} */
Expand Down Expand Up @@ -717,7 +726,10 @@ static const struct key *normal_mode_mouse_handle(MEVENT* event)
struct window* win = NULL;
struct iter it, sel;

if (event->y == LINES - 2) {
if (event->y == 0) {
need_sel = 0;
type = KEY_M_TYPE_TIT;
} else if (event->y == LINES - 2) {
need_sel = 0;
type = KEY_M_TYPE_BAR;
} else {
Expand Down

0 comments on commit 45c33cb

Please sign in to comment.