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;
|
||||
}
|
||||
|
||||
calc_widths(menu);
|
||||
|
||||
if (menu->position == POSITION_CENTER) {
|
||||
int maxItemWidth = 0;
|
||||
for (size_t i = 0; i < menu->item_count; i++) {
|
||||
struct item *item = &menu->items[i];
|
||||
if (item->width > maxItemWidth) {
|
||||
maxItemWidth = item->width;
|
||||
}
|
||||
}
|
||||
menu->width = menu->promptw + menu->inputw + maxItemWidth +
|
||||
menu->left_arrow + menu->right_arrow + 2 * menu->padding;
|
||||
calc_widths(menu);
|
||||
|
||||
menu->width = menu->promptw + menu->inputw + 2 * menu->padding;
|
||||
menu->width = MAX(menu->width, menu->minwidth); // Ensure minimum width
|
||||
zwlr_layer_surface_v1_set_margin(layer_surface, -1, -1, -1, -1);
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, menu->width, menu->height);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue