Try not to put menus off screen

This commit is contained in:
K. Lange 2018-05-21 19:52:00 +09:00
parent 23c458e88a
commit 49850c0067
2 changed files with 11 additions and 3 deletions

View File

@ -1760,11 +1760,15 @@ void * handle_incoming(void) {
} else if (me->buttons & YUTANI_MOUSE_BUTTON_RIGHT) {
if (!menu_right_click->window) {
menu_show(menu_right_click, yctx);
if (window->x + me->new_x + menu_right_click->window->width > yctx->display_width) {
yutani_window_move(yctx, menu_right_click->window, window->x + me->new_x - menu_right_click->window->width, window->y + me->new_y);
} else {
yutani_window_move(yctx, menu_right_click->window, window->x + me->new_x, window->y + me->new_y);
}
}
}
}
}
break;
default:
break;

View File

@ -142,11 +142,15 @@ static void _decor_close(struct MenuEntry * self) {
yutani_special_request(_decor_menu_owner_window->ctx, _decor_menu_owner_window, YUTANI_SPECIAL_REQUEST_PLEASE_CLOSE);
}
yutani_window_t * decor_show_default_menu(yutani_window_t * window, int y, int x) {
yutani_window_t * decor_show_default_menu(yutani_window_t * window, int x, int y) {
if (_decor_menu->window) return NULL;
_decor_menu_owner_window = window;
menu_show(_decor_menu, window->ctx);
yutani_window_move(window->ctx, _decor_menu->window, y, x);
if (x + _decor_menu->window->width > window->ctx->display_width) {
yutani_window_move(window->ctx, _decor_menu->window, x - _decor_menu->window->width, y);
} else {
yutani_window_move(window->ctx, _decor_menu->window, x, y);
}
return _decor_menu->window;
}