The function wMenuCreateForApp() creates the menu without the screen.
The screen mapping is moved to the functions where the function is used.

Signed-off-by: Rodolfo García Peñas (kix) <[email protected]>
---
 src/appmenu.c  | 9 +++++++--
 src/menu.c     | 5 +++--
 src/menu.h     | 2 +-
 src/usermenu.c | 6 ++++--
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/appmenu.c b/src/appmenu.c
index 126d228..e72bc50 100644
--- a/src/appmenu.c
+++ b/src/appmenu.c
@@ -82,7 +82,7 @@ static void notifyClient(WMenu * menu, WMenuEntry * entry)
        sendMessage(data->window, wmSelectItem, data->tag);
 }
 
-static WMenu *parseMenuCommand(WScreen * scr, Window win, char **slist, int 
count, int *index)
+static WMenu *parseMenuCommand(WScreen *scr, Window win, char **slist, int 
count, int *index)
 {
        WMenu *menu;
        int command;
@@ -94,14 +94,19 @@ static WMenu *parseMenuCommand(WScreen * scr, Window win, 
char **slist, int coun
                wwarning("appmenu: menu command size exceeded in window %lx", 
win);
                return NULL;
        }
+
        if (sscanf(slist[*index], "%i %i %n", &command, &code, &pos) < 2 || 
command != wmBeginMenu) {
                wwarning("appmenu: bad menu entry \"%s\" in window %lx", 
slist[*index], win);
                return NULL;
        }
+
        strcpy(title, &slist[*index][pos]);
-       menu = wMenuCreateForApp(scr, title, *index == 1);
+       menu = wMenuCreateForApp(title, *index == 1);
        if (!menu)
                return NULL;
+
+       menu_map(menu, scr);
+
        *index += 1;
        while (*index < count) {
                int ecode, etag, enab;
diff --git a/src/menu.c b/src/menu.c
index dd5a70f..e015354 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -244,13 +244,14 @@ WMenu *wMenuCreate(WScreen *screen, const char *title, 
int main_menu)
        return menu;
 }
 
-WMenu *wMenuCreateForApp(WScreen *screen, const char *title, int main_menu)
+WMenu *wMenuCreateForApp(const char *title, int main_menu)
 {
        WMenu *menu;
 
-       menu = wMenuCreate(screen, title, main_menu);
+       menu = menu_create(title, main_menu);
        if (!menu)
                return NULL;
+
        menu->flags.app_menu = 1;
        menu->brother->flags.app_menu = 1;
 
diff --git a/src/menu.h b/src/menu.h
index a493f06..7874eec 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -120,7 +120,7 @@ void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, 
WMenu *cascade);
 void wMenuRemoveItem(WMenu *menu, int index);
 
 WMenu *wMenuCreate(WScreen *screen, const char *title, int main_menu);
-WMenu *wMenuCreateForApp(WScreen *screen, const char *title, int main_menu);
+WMenu *wMenuCreateForApp(const char *title, int main_menu);
 void wMenuMap(WMenu *menu);
 void wMenuMapAt(WMenu *menu, int x, int y, int keyboard);
 #define wMenuMapCopyAt(menu, x, y) wMenuMapAt((menu)->brother, (x), (y), False)
diff --git a/src/usermenu.c b/src/usermenu.c
index d3f6fcc..5435cde 100644
--- a/src/usermenu.c
+++ b/src/usermenu.c
@@ -195,7 +195,7 @@ static WUserMenuData *convertShortcuts(WScreen * scr, 
WMPropList * shortcut)
        return data;
 }
 
-static WMenu *configureUserMenu(WScreen * scr, WMPropList * plum)
+static WMenu *configureUserMenu(WScreen *scr, WMPropList *plum)
 {
        char *mtitle;
        WMenu *menu = NULL;
@@ -219,7 +219,9 @@ static WMenu *configureUserMenu(WScreen * scr, WMPropList * 
plum)
 
        mtitle = WMGetFromPLString(elem);
 
-       menu = wMenuCreateForApp(scr, mtitle, True);
+       menu = wMenuCreateForApp(mtitle, True);
+       if (menu)
+               menu_map(menu, scr);
 
        for (i = 1; i < count; i++) {
                elem = WMGetFromPLArray(plum, i);
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to