menu: Changes to support Kuroko bindings

This commit is contained in:
K. Lange 2021-01-25 20:12:13 +09:00
parent 76d674722d
commit befb010dc2
6 changed files with 30 additions and 8 deletions

View File

@ -1690,6 +1690,11 @@ static void arrow_select(int x, int y) {
redraw_window(); redraw_window();
} }
static void redraw_window_callback(struct menu_bar * self) {
(void)self;
redraw_window();
}
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
yctx = yutani_init(); yctx = yutani_init();
@ -1727,7 +1732,7 @@ int main(int argc, char * argv[]) {
set_title(NULL); set_title(NULL);
menu_bar.entries = menu_entries; menu_bar.entries = menu_entries;
menu_bar.redraw_callback = redraw_window; menu_bar.redraw_callback = redraw_window_callback;
menu_bar.set = menu_set_create(); menu_bar.set = menu_set_create();

View File

@ -329,6 +329,11 @@ static void _menu_action_about(struct MenuEntry * entry) {
redraw_window(); redraw_window();
} }
static void redraw_window_callback(struct menu_bar * self) {
(void)self;
redraw_window();
}
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
yctx = yutani_init(); yctx = yutani_init();
@ -340,7 +345,7 @@ int main(int argc, char * argv[]) {
yutani_window_advertise_icon(yctx, main_window, APPLICATION_TITLE, "help"); yutani_window_advertise_icon(yctx, main_window, APPLICATION_TITLE, "help");
menu_bar.entries = menu_entries; menu_bar.entries = menu_entries;
menu_bar.redraw_callback = redraw_window; menu_bar.redraw_callback = redraw_window_callback;
menu_bar.set = menu_set_create(); menu_bar.set = menu_set_create();

View File

@ -433,6 +433,11 @@ static void arrow_select(int y) {
redraw_window(); redraw_window();
} }
static void redraw_window_callback(struct menu_bar * self) {
(void)self;
redraw_window();
}
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
if (geteuid() != 0) { if (geteuid() != 0) {
@ -455,7 +460,7 @@ int main(int argc, char * argv[]) {
yutani_window_advertise_icon(yctx, main_window, APPLICATION_TITLE, "package"); yutani_window_advertise_icon(yctx, main_window, APPLICATION_TITLE, "package");
menu_bar.entries = menu_entries; menu_bar.entries = menu_entries;
menu_bar.redraw_callback = redraw_window; menu_bar.redraw_callback = redraw_window_callback;
menu_bar.set = menu_set_create(); menu_bar.set = menu_set_create();

View File

@ -2212,6 +2212,11 @@ static void _menu_action_set_scale(struct MenuEntry * self) {
reinit(); reinit();
} }
static void render_decors_callback(struct menu_bar * self) {
(void)self;
render_decors();
}
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
window_width = char_width * 80; window_width = char_width * 80;
@ -2324,7 +2329,7 @@ int main(int argc, char ** argv) {
/* Set up menus */ /* Set up menus */
terminal_menu_bar.entries = terminal_menu_entries; terminal_menu_bar.entries = terminal_menu_entries;
terminal_menu_bar.redraw_callback = render_decors; terminal_menu_bar.redraw_callback = render_decors_callback;
struct MenuEntry * _menu_exit = menu_create_normal("exit","exit","Exit", _menu_action_exit); struct MenuEntry * _menu_exit = menu_create_normal("exit","exit","Exit", _menu_action_exit);
struct MenuEntry * _menu_copy = menu_create_normal(NULL, NULL, "Copy", _menu_action_copy); struct MenuEntry * _menu_copy = menu_create_normal(NULL, NULL, "Copy", _menu_action_copy);

View File

@ -19,6 +19,7 @@ struct MenuList;
struct MenuEntry { struct MenuEntry {
enum MenuEntry_Type _type; enum MenuEntry_Type _type;
struct MenuList * _owner; struct MenuList * _owner;
void * _private;
int height; /* All must have a height, so put it here. */ int height; /* All must have a height, so put it here. */
int width; /* Actual width */ int width; /* Actual width */
@ -115,7 +116,8 @@ struct menu_bar {
int num_entries; int num_entries;
void (*redraw_callback)(void); void * _private;
void (*redraw_callback)(struct menu_bar *);
}; };
extern void menu_bar_render(struct menu_bar * self, gfx_context_t * ctx); extern void menu_bar_render(struct menu_bar * self, gfx_context_t * ctx);

View File

@ -713,7 +713,7 @@ void menu_key_action(struct MenuList * menu, struct yutani_msg_key_event * me) {
int active = (bar->active_entry_idx + 1 + bar->num_entries) % (bar->num_entries); int active = (bar->active_entry_idx + 1 + bar->num_entries) % (bar->num_entries);
bar->active_entry = &bar->entries[active]; bar->active_entry = &bar->entries[active];
if (bar->redraw_callback) { if (bar->redraw_callback) {
bar->redraw_callback(); bar->redraw_callback(bar);
} }
menu_bar_show_menu(yctx, bar->window, bar, -1, bar->active_entry); menu_bar_show_menu(yctx, bar->window, bar, -1, bar->active_entry);
} else { } else {
@ -738,7 +738,7 @@ void menu_key_action(struct MenuList * menu, struct yutani_msg_key_event * me) {
int active = (menu->_bar->active_entry_idx - 1 + menu->_bar->num_entries) % (menu->_bar->num_entries); int active = (menu->_bar->active_entry_idx - 1 + menu->_bar->num_entries) % (menu->_bar->num_entries);
menu->_bar->active_entry = &menu->_bar->entries[active]; menu->_bar->active_entry = &menu->_bar->entries[active];
if (menu->_bar->redraw_callback) { if (menu->_bar->redraw_callback) {
menu->_bar->redraw_callback(); menu->_bar->redraw_callback(menu->_bar);
} }
menu_bar_show_menu(yctx, menu->_bar->window, menu->_bar, -1, menu->_bar->active_entry); menu_bar_show_menu(yctx, menu->_bar->window, menu->_bar, -1, menu->_bar->active_entry);
} else if (menu->parent && menu->parent->window) { } else if (menu->parent && menu->parent->window) {
@ -941,7 +941,7 @@ void menu_bar_show_menu(yutani_t * yctx, yutani_window_t * window, struct menu_b
self->active_entry = _entries; self->active_entry = _entries;
self->active_entry_idx = i; self->active_entry_idx = i;
if (self->redraw_callback) { if (self->redraw_callback) {
self->redraw_callback(); self->redraw_callback(self);
} }
} }