diff options
author | nicm <nicm> | 2017-11-03 17:02:33 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-11-03 17:02:33 +0000 |
commit | 50a5f84cb4accf806dea2235ca8d3749b107aac8 (patch) | |
tree | 4b385f0816915a783b911680d6ec141652023ad7 /mode-tree.c | |
parent | ba93a647f1b59d85340f9708ee2ae4fb6f201a64 (diff) | |
download | rtmux-50a5f84cb4accf806dea2235ca8d3749b107aac8.tar.gz rtmux-50a5f84cb4accf806dea2235ca8d3749b107aac8.tar.bz2 rtmux-50a5f84cb4accf806dea2235ca8d3749b107aac8.zip |
Support mouse on preview in tree mode.
Diffstat (limited to 'mode-tree.c')
-rw-r--r-- | mode-tree.c | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/mode-tree.c b/mode-tree.c index 28f97805..79af6ab5 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -190,27 +190,6 @@ mode_tree_clear_tagged(struct mode_tree_list *mtl) } } -static void -mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) -{ - u_int i; - - for (i = 0; i < mtd->line_size; i++) { - if (mtd->line_list[i].item->tag == tag) - break; - } - if (i != mtd->line_size) { - mtd->current = i; - if (mtd->current > mtd->height - 1) - mtd->offset = mtd->current - mtd->height + 1; - else - mtd->offset = 0; - } else { - mtd->current = 0; - mtd->offset = 0; - } -} - void mode_tree_up(struct mode_tree_data *mtd, int wrap) { @@ -248,6 +227,36 @@ mode_tree_get_current(struct mode_tree_data *mtd) return (mtd->line_list[mtd->current].item->itemdata); } +void +mode_tree_expand_current(struct mode_tree_data *mtd) +{ + if (!mtd->line_list[mtd->current].item->expanded) { + mtd->line_list[mtd->current].item->expanded = 1; + mode_tree_build(mtd); + } +} + +void +mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) +{ + u_int i; + + for (i = 0; i < mtd->line_size; i++) { + if (mtd->line_list[i].item->tag == tag) + break; + } + if (i != mtd->line_size) { + mtd->current = i; + if (mtd->current > mtd->height - 1) + mtd->offset = mtd->current - mtd->height + 1; + else + mtd->offset = 0; + } else { + mtd->current = 0; + mtd->offset = 0; + } +} + u_int mode_tree_count_tagged(struct mode_tree_data *mtd) { @@ -718,7 +727,7 @@ mode_tree_filter_free(void *data) int mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, - struct mouse_event *m) + struct mouse_event *m, u_int *xp, u_int *yp) { struct mode_tree_line *line; struct mode_tree_item *current, *parent; @@ -731,8 +740,13 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, *key = KEYC_NONE; return (0); } + if (xp != NULL) + *xp = x; + if (yp != NULL) + *yp = y; if (x > mtd->width || y > mtd->height) { - *key = KEYC_NONE; + if (!mtd->preview || y < mtd->height) + *key = KEYC_NONE; return (0); } if (mtd->offset + y < mtd->line_size) { |