diff --git a/src/application.c b/src/application.c index 8a1e3bb8..0b820789 100644 --- a/src/application.c +++ b/src/application.c @@ -114,8 +114,10 @@ static void extractIcon(WWindow * wwin) { char *progname; + /* Get the application name */ progname = GetProgramNameForWindow(wwin->client_win); if (progname) { + /* Save the icon path if the application is ".app" */ wApplicationExtractDirPackIcon(wwin->screen_ptr, progname, wwin->wm_instance, wwin->wm_class); wfree(progname); } @@ -148,8 +150,8 @@ void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_cla key = WMCreatePLString(tmp); wfree(tmp); - adict = WMGetFromPLDictionary(dict, key); + adict = WMGetFromPLDictionary(dict, key); iconk = WMCreatePLString("Icon"); if (adict) { @@ -161,6 +163,7 @@ void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_cla WMReleasePropList(adict); val = NULL; } + if (!val) { val = WMCreatePLString(iconPath); WMPutInPLDictionary(adict, iconk, val); @@ -168,20 +171,20 @@ void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_cla } else { val = NULL; } + WMReleasePropList(key); WMReleasePropList(iconk); - if (val && !wPreferences.flags.noupdates) { + if (val && !wPreferences.flags.noupdates) UpdateDomainFile(WDWindowAttributes); - } } +/* This function is used if the application is a .app. It checks if it has an icon in it + * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff + */ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance, char *wm_class) { char *iconPath = NULL; - /* Maybe the app is a .app and it has an icon in it, like - * /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff - */ if (strstr(path, ".app")) { char *tmp; diff --git a/src/defaults.c b/src/defaults.c index 793d1d51..69832751 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -906,10 +906,12 @@ void wDefaultsCheckDomains(void* arg) if (stat(WDWindowMaker->path, &stbuf) >= 0 && WDWindowMaker->timestamp < stbuf.st_mtime) { WDWindowMaker->timestamp = stbuf.st_mtime; - /* global dictionary */ + /* Global dictionary */ shared_dict = readGlobalDomain("WindowMaker", True); - /* user dictionary */ + + /* User dictionary */ dict = WMReadPropListFromFile(WDWindowMaker->path); + if (dict) { if (!WMIsPLDictionary(dict)) { WMReleasePropList(dict); @@ -923,22 +925,25 @@ void wDefaultsCheckDomains(void* arg) dict = shared_dict; shared_dict = NULL; } + for (i = 0; i < wScreenCount; i++) { scr = wScreenWithNumber(i); if (scr) wReadDefaults(scr, dict); } - if (WDWindowMaker->dictionary) { + + if (WDWindowMaker->dictionary) WMReleasePropList(WDWindowMaker->dictionary); - } + WDWindowMaker->dictionary = dict; } } else { wwarning(_("could not load domain %s from user defaults database"), "WindowMaker"); } - if (shared_dict) { + + if (shared_dict) WMReleasePropList(shared_dict); - } + } if (stat(WDWindowAttributes->path, &stbuf) >= 0 && WDWindowAttributes->timestamp < stbuf.st_mtime) { @@ -1051,9 +1056,9 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) if (!plvalue && !old_value) { /* no default in the DB. Use builtin default */ plvalue = entry->plvalue; - if (plvalue && new_dict) { + if (plvalue && new_dict) WMPutInPLDictionary(new_dict, entry->plkey, plvalue); - } + } else if (!plvalue) { /* value was deleted from DB. Keep current value */ continue; @@ -1062,7 +1067,6 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) } else if (!WMIsPropListEqualTo(plvalue, old_value)) { /* value has changed */ } else { - if (strcmp(entry->key, "WorkspaceBack") == 0 && update_workspace_back && scr->flags.backimage_helper_launched) { } else { @@ -1080,13 +1084,13 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) * sure to send the default background texture config * to the helper. */ - if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 - && !scr->flags.backimage_helper_launched) { + if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 && + !scr->flags.backimage_helper_launched) update_workspace_back = 1; - } - if (entry->update) { + + if (entry->update) needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data); - } + } } } @@ -1116,29 +1120,23 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo); foo = 0; - if (needs_refresh & REFRESH_WINDOW_FONT) { + if (needs_refresh & REFRESH_WINDOW_FONT) foo |= WFontSettings; - } - if (needs_refresh & REFRESH_WINDOW_TEXTURES) { + if (needs_refresh & REFRESH_WINDOW_TEXTURES) foo |= WTextureSettings; - } - if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR) { + if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR) foo |= WColorSettings; - } if (foo) WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo); if (!(needs_refresh & REFRESH_ICON_TILE)) { foo = 0; - if (needs_refresh & REFRESH_ICON_FONT) { + if (needs_refresh & REFRESH_ICON_FONT) foo |= WFontSettings; - } - if (needs_refresh & REFRESH_ICON_TITLE_COLOR) { + if (needs_refresh & REFRESH_ICON_TITLE_COLOR) foo |= WTextureSettings; - } - if (needs_refresh & REFRESH_ICON_TITLE_BACK) { + if (needs_refresh & REFRESH_ICON_TITLE_BACK) foo |= WTextureSettings; - } if (foo) WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo); diff --git a/src/main.c b/src/main.c index 36f5a1e1..431d41b9 100644 --- a/src/main.c +++ b/src/main.c @@ -574,9 +574,9 @@ static void execInitScript() wfree(paths); if (file) { - if (system(file) != 0) { + if (system(file) != 0) werror(_("%s:could not execute initialization script"), file); - } + wfree(file); } } @@ -592,9 +592,9 @@ void ExecExitScript() wfree(paths); if (file) { - if (system(file) != 0) { + if (system(file) != 0) werror(_("%s:could not execute exit script"), file); - } + wfree(file); } } diff --git a/src/misc.c b/src/misc.c index 3381c2a0..fd283c28 100644 --- a/src/misc.c +++ b/src/misc.c @@ -407,9 +407,8 @@ char *FindImage(char *paths, char *file) path = wfindfile(paths, file); *tmp = ':'; } - if (!tmp || !path) { + if (!tmp || !path) path = wfindfile(paths, file); - } return path; } diff --git a/src/rootmenu.c b/src/rootmenu.c index 91833809..b2b28cec 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -296,7 +296,7 @@ static void legalPanelCommand(WMenu * menu, WMenuEntry * entry) /********************************************************************/ -static char *getLocalizedMenuFile(char *menu) +static char * getLocalizedMenuFile(char *menu) { char *buffer, *ptr, *locale; int len; @@ -309,9 +309,8 @@ static char *getLocalizedMenuFile(char *menu) /* try menu.locale_name */ snprintf(buffer, len, "%s.%s", menu, Locale); - if (access(buffer, F_OK) == 0) { + if (access(buffer, F_OK) == 0) return buffer; - } /* position of locale in our buffer */ locale = buffer + strlen(menu) + 1; @@ -320,17 +319,16 @@ static char *getLocalizedMenuFile(char *menu) ptr = strchr(locale, '.'); if (ptr) { *ptr = 0; - if (access(buffer, F_OK) == 0) { + if (access(buffer, F_OK) == 0) return buffer; - } } + /* now check for aa */ ptr = strchr(locale, '_'); if (ptr) { *ptr = 0; - if (access(buffer, F_OK) == 0) { + if (access(buffer, F_OK) == 0) return buffer; - } } wfree(buffer); diff --git a/src/session.c b/src/session.c index a2795a37..8ae5fb8b 100644 --- a/src/session.c +++ b/src/session.c @@ -214,9 +214,8 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp) for (mask = 0, i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { if (scr->shortcutWindows[i] != NULL && - WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) { + WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) mask |= 1 << i; - } } snprintf(buffer, sizeof(buffer), "%u", mask); @@ -535,6 +534,7 @@ void wSessionRestoreLastWorkspace(WScreen * scr) tmp = WMGetFromPLString(wks); + /* clean up */ WMPLSetCaseSensitive(False); @@ -550,7 +550,6 @@ void wSessionRestoreLastWorkspace(WScreen * scr) w--; } - if (w != scr->current_workspace && w < scr->workspace_count) { + if (w != scr->current_workspace && w < scr->workspace_count) wWorkspaceChange(scr, w); - } } diff --git a/src/startup.c b/src/startup.c index 149147c6..190cd92a 100644 --- a/src/startup.c +++ b/src/startup.c @@ -540,9 +540,8 @@ void StartUp(Bool defaultScreenOnly) { int i; - for (i = 0; i < sizeof(atomNames) / sizeof(char *); i++) { + for (i = 0; i < sizeof(atomNames) / sizeof(char *); i++) atom[i] = XInternAtom(dpy, atomNames[i], False); - } } #endif @@ -591,17 +590,17 @@ void StartUp(Bool defaultScreenOnly) wCursor[WCUR_QUESTION] = XCreateFontCursor(dpy, XC_question_arrow); wCursor[WCUR_TEXT] = XCreateFontCursor(dpy, XC_xterm); /* odd name??? */ wCursor[WCUR_SELECT] = XCreateFontCursor(dpy, XC_cross); - { - Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1); - GC gc = XCreateGC(dpy, cur, 0, NULL); - XColor black; - memset(&black, 0, sizeof(XColor)); - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, cur, gc, 0, 0, 16, 16); - XFreeGC(dpy, gc); - wCursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0); - XFreePixmap(dpy, cur); - } + + Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1); + GC gc = XCreateGC(dpy, cur, 0, NULL); + XColor black; + memset(&black, 0, sizeof(XColor)); + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, cur, gc, 0, 0, 16, 16); + XFreeGC(dpy, gc); + wCursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0); + XFreePixmap(dpy, cur); + #ifndef HAVE_INOTIFY /* signal handler stuff that gets called when a signal is caught */ @@ -668,9 +667,8 @@ void StartUp(Bool defaultScreenOnly) /* initialize defaults stuff */ WDWindowMaker = wDefaultsInitDomain("WindowMaker", True); - if (!WDWindowMaker->dictionary) { + if (!WDWindowMaker->dictionary) wwarning(_("could not read domain \"%s\" from defaults database"), "WindowMaker"); - } /* read defaults that don't change until a restart and are * screen independent */ @@ -685,15 +683,14 @@ void StartUp(Bool defaultScreenOnly) /* init other domains */ WDRootMenu = wDefaultsInitDomain("WMRootMenu", False); - if (!WDRootMenu->dictionary) { + if (!WDRootMenu->dictionary) wwarning(_("could not read domain \"%s\" from defaults database"), "WMRootMenu"); - } + wDefaultsMergeGlobalMenus(WDRootMenu); WDWindowAttributes = wDefaultsInitDomain("WMWindowAttributes", True); - if (!WDWindowAttributes->dictionary) { + if (!WDWindowAttributes->dictionary) wwarning(_("could not read domain \"%s\" from defaults database"), "WMWindowAttributes"); - } XSetErrorHandler((XErrorHandler) catchXError); @@ -714,11 +711,11 @@ void StartUp(Bool defaultScreenOnly) } #endif - if (defaultScreenOnly) { + if (defaultScreenOnly) max = 1; - } else { + else max = ScreenCount(dpy); - } + wScreen = wmalloc(sizeof(WScreen *) * max); wScreenCount = 0; @@ -783,11 +780,10 @@ void StartUp(Bool defaultScreenOnly) } /* go to workspace where we were before restart */ - if (lastDesktop >= 0) { + if (lastDesktop >= 0) wWorkspaceForceChange(wScreen[j], lastDesktop); - } else { + else wSessionRestoreLastWorkspace(wScreen[j]); - } } if (wScreenCount == 0) { @@ -796,10 +792,9 @@ void StartUp(Bool defaultScreenOnly) } #ifndef HAVE_INOTIFY - if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) { - /* setup defaults file polling */ + /* setup defaults file polling */ + if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL); - } #endif } diff --git a/src/usermenu.c b/src/usermenu.c index 49473c87..e0acc57d 100644 --- a/src/usermenu.c +++ b/src/usermenu.c @@ -125,6 +125,7 @@ static void removeUserMenudata(void *menudata) WUserMenuData *data = menudata; if (data->key) wfree(data->key); + wfree(data); } @@ -132,22 +133,21 @@ static WUserMenuData *convertShortcuts(WScreen * scr, WMPropList * shortcut) { WUserMenuData *data; KeySym ksym; - char *k; - char *buffer; - char buf[MAX_SHORTCUT_LENGTH], *b; + char *k, *buffer, buf[MAX_SHORTCUT_LENGTH], *b; int keycount, i, j, mod; if (WMIsPLString(shortcut)) { keycount = 1; } else if (WMIsPLArray(shortcut)) { keycount = WMGetPropListItemCount(shortcut); - } else + } else { return NULL; - /*for (i=0;ikey = wmalloc(sizeof(WShortKey) * keycount); if (!data->key) { wfree(data); @@ -156,32 +156,30 @@ static WUserMenuData *convertShortcuts(WScreen * scr, WMPropList * shortcut) for (i = 0, j = 0; i < keycount; i++) { data->key[j].modifier = 0; - if (WMIsPLArray(shortcut)) { + if (WMIsPLArray(shortcut)) wstrlcpy(buf, WMGetFromPLString(WMGetFromPLArray(shortcut, i)), MAX_SHORTCUT_LENGTH); - } else { + else wstrlcpy(buf, WMGetFromPLString(shortcut), MAX_SHORTCUT_LENGTH); - } + b = (char *)buf; while ((k = strchr(b, '+')) != NULL) { *k = 0; mod = wXModifierFromKey(b); - if (mod < 0) { + if (mod < 0) break; - } + data->key[j].modifier |= mod; b = k + 1; } ksym = XStringToKeysym(b); - if (ksym == NoSymbol) { + if (ksym == NoSymbol) continue; - } data->key[j].keycode = XKeysymToKeycode(dpy, ksym); - if (data->key[j].keycode) { + if (data->key[j].keycode) j++; - } } keyover: @@ -209,18 +207,17 @@ static WMenu *configureUserMenu(WScreen * scr, WMPropList * plum) if (!plum) return NULL; - if (!WMIsPLArray(plum)) { + + if (!WMIsPLArray(plum)) return NULL; - } count = WMGetPropListItemCount(plum); if (!count) return NULL; elem = WMGetFromPLArray(plum, 0); - if (!WMIsPLString(elem)) { + if (!WMIsPLString(elem)) return NULL; - } mtitle = WMGetFromPLString(elem); @@ -257,10 +254,10 @@ static WMenu *configureUserMenu(WScreen * scr, WMPropList * plum) notifyClient, data); if (entry) { - if (WMIsPLString(params)) { + if (WMIsPLString(params)) entry->rtext = GetShortcutString(WMGetFromPLString(params)); - } + entry->free_cdata = removeUserMenudata; if (WMGetPropListItemCount(elem) >= 4) { @@ -323,14 +320,11 @@ void wUserMenuRefreshInstances(WMenu * menu, WWindow * wwin) static WMenu *readUserMenuFile(WScreen * scr, char *file_name) { - WMenu *menu; - char *mtitle; - WMPropList *plum, *elem, *title, *command, *params; - int count, i; + WMenu *menu = NULL; + WMPropList *plum; - menu = NULL; plum = WMReadPropListFromFile(file_name); - /**/ if (plum) { + if (plum) { menu = configureUserMenu(scr, plum); WMReleasePropList(plum); } @@ -353,9 +347,8 @@ WMenu *wUserMenuGet(WScreen * scr, WWindow * wwin) if (!path) return NULL; - if (wwin) { + if (wwin) menu = readUserMenuFile(scr, path); - } wfree(path); } diff --git a/src/window.c b/src/window.c index d6a2a1ba..f05be9ed 100644 --- a/src/window.c +++ b/src/window.c @@ -786,10 +786,10 @@ WWindow *wManageWindow(WScreen *scr, Window window) index = WMFindInArray(scr->fakeGroupLeaders, matchIdentifier, (void *)buffer); if (index != WANotFound) { fPtr = WMGetFromArray(scr->fakeGroupLeaders, index); - if (fPtr->retainCount == 0) { + if (fPtr->retainCount == 0) fPtr->leader = createFakeWindowGroupLeader(scr, wwin->main_window, instance, class); - } + fPtr->retainCount++; if (fPtr->origLeader == None) { if (ADEQUATE(wwin->main_window)) { diff --git a/src/winspector.c b/src/winspector.c index adaf8b73..37ae0b2e 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -648,9 +648,8 @@ static void saveSettings(WMButton * button, InspectorPanel * panel) different |= different2; } else { WMRemoveFromPLDictionary(dict, key2); - if (different2) { + if (different2) WMPutInPLDictionary(dict, key2, appDic); - } } WMReleasePropList(key2); WMReleasePropList(appDic); @@ -1053,11 +1052,10 @@ static void selectSpecification(WMWidget * bPtr, void *data) WWindow *wwin = panel->inspected; int len; - if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class)) { + if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class)) WMSetButtonEnabled(panel->applyBtn, False); - } else { + else WMSetButtonEnabled(panel->applyBtn, True); - } len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?") + strlen(wwin->wm_class ? wwin->wm_class : "?");