window: menu leak fixes
When a menu self-destructs, free also the widget and struct menu.
As menus are self-destructing, it does not make sense to store the
window pointer, since we cannot clear it automatically. Therefore,
rename window_create_menu() to window_show_menu() that does not return
the window pointer. It also calls window_schedule_redraw() internally.
Fixes Valgrind reported memory leaks.
The alternative would be to explicitly destroy the menu in application's
menu callback.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/clients/window.h b/clients/window.h
index 4ff2fc8..e35d657 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -200,11 +200,11 @@
typedef void (*menu_func_t)(struct window *window, int index, void *data);
-struct window *
-window_create_menu(struct display *display,
- struct input *input, uint32_t time, struct window *parent,
- int32_t x, int32_t y,
- menu_func_t func, const char **entries, int count);
+void
+window_show_menu(struct display *display,
+ struct input *input, uint32_t time, struct window *parent,
+ int32_t x, int32_t y,
+ menu_func_t func, const char **entries, int count);
void
window_destroy(struct window *window);