From eacdd97287a602ef18284ebf221504679aeb63d3 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 20 May 2018 11:22:15 +0900 Subject: [PATCH] Handle nested menus extending past display width --- lib/menu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/menu.c b/lib/menu.c index 7bc97317..2ae8ff0b 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -145,7 +145,11 @@ void _menu_activate_MenuEntry_Submenu(struct MenuEntry * self, int focused) { new_menu->parent->child = new_menu; if (new_menu->closed) { menu_show(new_menu, _self->_owner->window->ctx); - yutani_window_move(_self->_owner->window->ctx, new_menu->window, _self->_owner->window->width + _self->_owner->window->x - 2, _self->_owner->window->y + _self->offset - 4); + if (_self->_owner->window->width + _self->_owner->window->x - 2 + new_menu->window->width > _self->_owner->window->ctx->display_width) { + yutani_window_move(_self->_owner->window->ctx, new_menu->window, _self->_owner->window->x + 2 - new_menu->window->width, _self->_owner->window->y + _self->offset - 4); + } else { + yutani_window_move(_self->_owner->window->ctx, new_menu->window, _self->_owner->window->width + _self->_owner->window->x - 2, _self->_owner->window->y + _self->offset - 4); + } } }