X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=mod_menu%2Fmenu.c;h=c87dc590ccb99f5693f52d19c545dad9c828f5a1;hb=ae4260bb64817c11f9a7140324cd3e3ba113e297;hp=d891c230b6690a014b3cf1ec5810af78c450031b;hpb=803afbc1cd633f6c025bcd9537e9b7e9aedadd0d;p=ion3.git diff --git a/mod_menu/menu.c b/mod_menu/menu.c index d891c23..c87dc59 100644 --- a/mod_menu/menu.c +++ b/mod_menu/menu.c @@ -3,10 +3,7 @@ * * Copyright (c) Tuomo Valkonen 1999-2007. * - * Ion is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. + * See the included file LICENSE for details. */ #include @@ -30,6 +27,8 @@ #include #include #include +#include +#include #include "menu.h" #include "main.h" @@ -391,6 +390,26 @@ bool menu_fitrep(WMenu *menu, WWindow *par, const WFitParams *fp) } +void menu_size_hints(WMenu *menu, WSizeHints *hints_ret) +{ + int n=menu->n_entries; + int w=menu->max_entry_w; + int h=menu->entry_h*n + menu->entry_spacing*maxof(0, n-1); + + if(menu->brush!=NULL){ + GrBorderWidths bdw; + grbrush_get_border_widths(menu->brush, &bdw); + + w+=bdw.left+bdw.right; + h+=bdw.top+bdw.bottom; + } + + hints_ret->min_set=TRUE; + hints_ret->min_width=w; + hints_ret->min_height=h; +} + + /*}}}*/ @@ -584,7 +603,8 @@ bool menu_init(WMenu *menu, WWindow *par, const WFitParams *fp, menu->handler=extl_ref_fn(params->handler); menu->pmenu_mode=params->pmenu_mode; menu->big_mode=params->big_mode; - + /*menu->cycle_bindmap=NULL;*/ + menu->last_fp=*fp; if(params->pmenu_mode){ @@ -668,6 +688,9 @@ void menu_deinit(WMenu *menu) if(menu->submenu!=NULL) destroy_obj((Obj*)menu->submenu); + /*if(menu->cycle_bindmap!=NULL) + bindmap_destroy(menu->cycle_bindmap);*/ + extl_unref_table(menu->tab); extl_unref_fn(menu->handler); @@ -945,10 +968,10 @@ static void menu_do_finish(WMenu *menu) ok=extl_table_geti_t(menu->tab, menu->selected_entry+1, &tab); - if(region_manager_allows_destroying((WRegion*)head)) - destroy_obj((Obj*)head); - else if(head->submenu!=NULL) - destroy_obj((Obj*)head->submenu); + if(!region_rqdispose((WRegion*)head)){ + if(head->submenu!=NULL) + destroy_obj((Obj*)head->submenu); + } if(ok) extl_call(handler, "t", NULL, tab); @@ -984,8 +1007,7 @@ void menu_finish(WMenu *menu) EXTL_EXPORT_MEMBER void menu_cancel(WMenu *menu) { - if(region_manager_allows_destroying((WRegion*)menu)) - region_dispose_((WRegion*)menu); + region_defer_rqdispose((WRegion*)menu); } @@ -1416,6 +1438,7 @@ static DynFunTab menu_dynfuntab[]={ {window_insstr, menu_insstr}, {region_restack, menu_restack}, {region_stacking, menu_stacking}, + {region_size_hints, menu_size_hints}, END_DYNFUNTAB };