wmgen

Генератор WINGs апликација
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 962f7b852ac9c1b01fbdd8c6edee0dc14e75a73a
родитељ ee42b197a1ff4fbb3ce07e8f05a4e17c48c7faca
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun, 17 Dec 2023 13:38:25 +0100

Add notes about known bug; change behavior to "lesser evil" (like FSViewer)

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MREADME | 23++++++++++++++++++-----
Mmain.c | 13++++++++++---
Mmainwindow.c | 10++++++++--
Mmainwindow.h | 1+
Mmenu.c | 1+
измењених датотека: 5, додавања: 38(+), брисања: 10(-)

diff --git a/README b/README @@ -22,11 +22,24 @@ or Known Bugs ---------- -- When "Shared application icon" is selected for an application generated with - wmgen, every instance of that application will generate a "phantom copy" of - the application menu, which persists after closing the application, can't be - closed with xkill, apparently isn't associated with any process, and for which - xprop doesn't detect any properties. +- WINGs bug: when "Shared application icon" is selected for an application + generated with wmgen, one of the two things happen, depending on whether + WMMapSubwidgets and WMMapWidget for the main window is called before (A) or + after (B) creating the main menu: + + A) Every instance of that application will generate a "phantom copy" of the + application menu, which persists after closing the application, can't be + closed with xkill, apparently isn't associated with any process, and for + which xprop doesn't detect any properties. Interestingly, when the main + application is closed, and relaunched, the extra copies of menus work in + the new instance. + + B) The menu is not shown at all. This is the same behavior/known bug as in + FSViewer. + + I chose to follow option (B), same behavior as in FSViewer. I believe that + having no menu at all, and behaving consistently with known application is + better than having leftover uncloseable copies of menus around. License diff --git a/main.c b/main.c @@ -38,24 +38,30 @@ error(const int code, const char* msg, ...) return code; } +static void +do_exit(struct WMNewApp* wma) +{ + exit(0); +} + void exit_action(WMWidget* self, void* data) { struct WMNewApp* wma = (struct WMNewApp*)data; WMLog(wma, "exit_action called\n"); if (!wma->state.dirty) - exit(0); + do_exit(wma); switch (WMRunAlertPanel(wma->scr, NULL, "Confirm", "Document %s is modified. Save changes?", "Yes", "No", "Cancel")) { case 0: WMLog(wma, "Saving changes!\n"); - exit(0); + do_exit(wma); break; case 1: WMLog(wma, "NOT saving changes!\n"); - exit(0); + do_exit(wma); break; default: WMLog(wma, "Canceled exit!\n"); @@ -266,6 +272,7 @@ main(int argc, char** argv) create_icon(&wma); create_main_menu(&wma); + map_main_window(&wma); WMSetFocusToWidget(wma.mainwin->window); WMCreateEventHandler(WMWidgetView(wma.mainwin->window), KeyPressMask, diff --git a/mainwindow.c b/mainwindow.c @@ -83,12 +83,11 @@ create_main_window(struct WMNewApp* wma) MyWMSetWindowAttributes(wma->dpy, WMWidgetXID(wma->mainwin->window), &attributes); - WMMapSubwidgets(wma->mainwin->window); - WMMapWidget(wma->mainwin->window); WMSetViewNotifySizeChanges(WMWidgetView(wma->mainwin->window), True); WMAddNotificationObserver(handle_mainwin_resize, wma, WMViewSizeDidChangeNotification, WMWidgetView(wma->mainwin->window)); + } void @@ -112,6 +111,13 @@ handle_mainwin_resize(void* data, WMNotification* notification) } void +map_main_window(struct WMNewApp* wma) +{ + WMMapSubwidgets(wma->mainwin->window); + WMMapWidget(wma->mainwin->window); +} + +void set_mainwin_title(struct WMNewApp* wma) { if (wma->state.file_open) diff --git a/mainwindow.h b/mainwindow.h @@ -7,6 +7,7 @@ struct WMMainWindow { void create_icon(struct WMNewApp* wma); void create_main_window(struct WMNewApp* wma); void destroy_main_window(struct WMNewApp* wma); +void map_main_window(struct WMNewApp* wma); void set_mainwin_title(struct WMNewApp* wma); #ifdef INCLUDE_STATIC_FUNCS diff --git a/menu.c b/menu.c @@ -6,6 +6,7 @@ create_main_menu(struct WMNewApp* wma) { WMMenu* submenu; + WMLog(wma, "create_main_menu called\n"); wma->main_menu = WMMenuCreate(wma->app, (char*)program_name); submenu = WMMenuCreate(wma->app, "Info");