mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
simplify width calculation
This commit is contained in:
parent
6452c98c15
commit
3a4d17381e
1 changed files with 4 additions and 10 deletions
14
wayland.c
14
wayland.c
|
|
@ -463,18 +463,12 @@ int menu_run(struct menu *menu) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_widths(menu);
|
|
||||||
|
|
||||||
if (menu->position == POSITION_CENTER) {
|
if (menu->position == POSITION_CENTER) {
|
||||||
int maxItemWidth = 0;
|
calc_widths(menu);
|
||||||
for (size_t i = 0; i < menu->item_count; i++) {
|
|
||||||
struct item *item = &menu->items[i];
|
menu->width = menu->promptw + menu->inputw + 2 * menu->padding;
|
||||||
if (item->width > maxItemWidth) {
|
menu->width = MAX(menu->width, menu->minwidth); // Ensure minimum width
|
||||||
maxItemWidth = item->width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
menu->width = menu->promptw + menu->inputw + maxItemWidth +
|
|
||||||
menu->left_arrow + menu->right_arrow + 2 * menu->padding;
|
|
||||||
zwlr_layer_surface_v1_set_margin(layer_surface, -1, -1, -1, -1);
|
zwlr_layer_surface_v1_set_margin(layer_surface, -1, -1, -1, -1);
|
||||||
zwlr_layer_surface_v1_set_size(layer_surface, menu->width, menu->height);
|
zwlr_layer_surface_v1_set_size(layer_surface, menu->width, menu->height);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue