From 4700e5f0b22a3005c0472f671072b0878b3099af Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Thu, 21 Jun 2012 15:06:22 +0100 Subject: [PATCH] Make create_appicon_from_dock() do only what its name implies Function names are important and should not do more than their names imply. In this case, create_appicon_from_dock() should only try to get an icon from the dock (or clip). If the icon is not there, do not try to make an icon from scratch. You were told to create it from the dock! Signed-off-by: Carlos R. Mafra --- src/appicon.c | 4 ---- src/application.c | 16 +++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 6cc2bca2..6827c2f4 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -955,8 +955,6 @@ static WAppIcon *findDockIconFor(WDock *dock, Window main_window) void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window) { WScreen *scr = wwin->screen_ptr; - - /* Create the application icon */ wapp->app_icon = NULL; if (scr->last_dock) @@ -990,7 +988,5 @@ void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_win wAppIconPaint(wapp->app_icon); wAppIconSave(wapp->app_icon); - } else { - makeAppIconFor(wapp); } } diff --git a/src/application.c b/src/application.c index f0122f0c..f08f435d 100644 --- a/src/application.c +++ b/src/application.c @@ -132,22 +132,24 @@ WApplication *wApplicationCreate(WWindow * wwin) #ifdef USER_MENU if (!wapp->menu) wapp->menu = wUserMenuGet(scr, wapp->main_window_desc); -#endif /* USER_MENU */ +#endif - /* - * Set application wide attributes from the leader. - */ + /* Set application wide attributes from the leader */ wapp->flags.hidden = WFLAGP(wapp->main_window_desc, start_hidden); wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon); /* application descriptor */ XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp); - /* Create the application icon using the icon from docks - * If not found in docks, create a new icon - * using the function wAppIconCreate() */ + /* First try to create an icon from the dock or clip */ create_appicon_from_dock(wwin, wapp, main_window); + /* + * In case it was not found in the dock, make it from scratch. + * Note: makeAppIconFor() returns early if wapp->app_icon exists + */ + makeAppIconFor(wapp); + /* Save the app_icon in a file */ save_app_icon(wapp); -- 2.11.4.GIT