From 90c77b1a459f364cbe0262c5efbbde080ed7d5ad Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 17 Dec 2001 14:46:31 +0000 Subject: [PATCH] - improved behaviour for the shared appicon thing. - added a 'Bool recursive' flag to WMMergePLDictionaries() in WINGs --- ChangeLog | 2 ++ WINGs/ChangeLog | 1 + WINGs/WINGs/WUtil.h | 3 ++- WINGs/WINGs/proplist-compat.h | 2 +- WINGs/proplist.c | 15 ++++++++++--- WINGs/userdefaults.c | 2 +- WindowMaker/Defaults/WMWindowAttributes.in | 8 +++---- src/client.c | 2 +- src/defaults.c | 4 ++-- src/dock.c | 2 +- src/event.c | 26 ++++++++++++++++++++++ src/wdefaults.c | 2 +- src/window.c | 35 +++++++++++++++++++----------- src/window.h | 3 ++- util/getstyle.c | 2 +- util/seticons.c | 2 +- util/setstyle.c | 2 +- 17 files changed, 81 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e6a118b..b919ce45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,8 @@ Changes since version 0.70.0: - Removed the collapse appicons thing. - Added real appicon sharing (apps of the same kind will have a single shared appicon). +- Fixed user and global defaults domain merging to preserve values present in + global but not in user in subdictionaries. Changes since version 0.65.1: diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index 56c5804a..6288c533 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -6,6 +6,7 @@ Changes since wmaker 0.70.0: included too - removed a wsyserror() message when reading a property list from file (the programmer should decide if to give that message or just ignore). +- added a 'Bool recursive' flag to WMMergePLDictionaries() Changes since wmaker 0.65.0: diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index 9b4c50d4..4869de96 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -772,7 +772,8 @@ void WMRemoveFromPLDictionary(WMPropList *plist, WMPropList *key); /* It inserts all key/value pairs from source into dest, overwriting * the values with the same keys from dest, keeping all values with keys * only present in dest unchanged */ -WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source); +WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source, + Bool recursive); int WMGetPropListItemCount(WMPropList *plist); diff --git a/WINGs/WINGs/proplist-compat.h b/WINGs/WINGs/proplist-compat.h index 79e03321..7077b2d2 100644 --- a/WINGs/WINGs/proplist-compat.h +++ b/WINGs/WINGs/proplist-compat.h @@ -86,7 +86,7 @@ typedef WMPropList* proplist_t; #define PLRemoveArrayElement(array, pos) WMDeleteFromPLArray(array, pos) #define PLInsertDictionaryEntry(dict, key, value) WMPutInPLDictionary(dict, key, value) #define PLRemoveDictionaryEntry(dict, key) WMRemoveFromPLDictionary(dict, key) -#define PLMergeDictionaries(dest, source) WMMergePLDictionaries(dest, source) +#define PLMergeDictionaries(dest, source) WMMergePLDictionaries(dest, source, False) #define PLGetNumberOfElements(pl) WMGetPropListItemCount(pl) diff --git a/WINGs/proplist.c b/WINGs/proplist.c index 15d309da..2e9ccad4 100644 --- a/WINGs/proplist.c +++ b/WINGs/proplist.c @@ -1211,16 +1211,25 @@ WMRemoveFromPLDictionary(WMPropList *plist, WMPropList *key) WMPropList* -WMMergePLDictionaries(WMPropList *dest, WMPropList *source) +WMMergePLDictionaries(WMPropList *dest, WMPropList *source, Bool recursive) { - WMPropList *key, *value; + WMPropList *key, *value, *dvalue; WMHashEnumerator e; wassertr(source->type==WPLDictionary && dest->type==WPLDictionary); e = WMEnumerateHashTable(source->d.dict); while (WMNextHashEnumeratorItemAndKey(&e, (void**)&value, (void**)&key)) { - WMPutInPLDictionary(dest, key, value); + if (recursive && value->type==WPLDictionary) { + dvalue = WMGetFromPLDictionary(dest, key); + if (dvalue && dvalue->type==WPLDictionary) { + WMMergePLDictionaries(dvalue, value, recursive); + } else { + WMPutInPLDictionary(dest, key, value); + } + } else { + WMPutInPLDictionary(dest, key, value); + } } return dest; diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index 892d7f65..aed5f464 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -181,7 +181,7 @@ WMSynchronizeUserDefaults(WMUserDefaults *database) if (database->dirty && fileIsNewer) { plF = WMReadPropListFromFile(path); if (plF) { - plF = WMMergePLDictionaries(plF, database->appDomain); + plF = WMMergePLDictionaries(plF, database->appDomain, False); WMReleasePropList(database->appDomain); database->appDomain = plF; key = database->searchList[0]; diff --git a/WindowMaker/Defaults/WMWindowAttributes.in b/WindowMaker/Defaults/WMWindowAttributes.in index 2711532d..77d2c1df 100644 --- a/WindowMaker/Defaults/WMWindowAttributes.in +++ b/WindowMaker/Defaults/WMWindowAttributes.in @@ -7,8 +7,8 @@ WSoundServer = {Icon = sound.#extension#;}; panel.Panel = {NoAppIcon = YES;}; gmc.Gmc = {NoAppIcon = YES;}; - XTerm = {SharedAppIcon = Yes;Icon = Terminal.#extension#;}; - NXTerm = {SharedAppIcon = Yes;Icon = Terminal.#extension#;}; + XTerm = {Icon = Terminal.#extension#;}; + NXTerm = {Icon = Terminal.#extension#;}; ScilabGraphic0.Xscilab = {KeepInsideScreen=YES;}; ScilabGraphic1.Xscilab = {KeepInsideScreen=YES;}; ScilabGraphic2.Xscilab = {KeepInsideScreen=YES;}; @@ -46,11 +46,11 @@ Xmag = {Icon = inspect.xpm;}; Xmessage = {Icon = Reference.xpm;}; XConsole = {Icon = inspect.xpm;Omnipresent = Yes;}; - Fte = {SharedAppIcon = Yes;Icon = Clipboard.tif;}; + Fte = {Icon = Clipboard.tif;}; xjed = {Icon = Clipboard.xpm;}; xedit = {Icon = notepad.#extension#;}; xmixer = {Icon = mixer.#extension#;}; xmcd = {Icon = Radio.xpm;}; xplaycd = {Icon = Radio.xpm;}; - "*" = {Icon = defaultAppIcon.#extension#;}; + "*" = {Icon = defaultAppIcon.#extension#;SharedAppIcon = Yes;}; } diff --git a/src/client.c b/src/client.c index 878e69fa..70851370 100644 --- a/src/client.c +++ b/src/client.c @@ -512,7 +512,7 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) else wwin->flags.urgent = 0; } else if (wwin->fake_group!=NULL) { - wwin->group_id = wwin->fake_group->window; + wwin->group_id = wwin->fake_group->leader; } else { wwin->group_id = None; } diff --git a/src/defaults.c b/src/defaults.c index 21117b4f..c074f98b 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -989,7 +989,7 @@ wDefaultsInitDomain(char *domain, Bool requireDictionary) } else { if (db->dictionary && WMIsPLDictionary(shared_dict) && WMIsPLDictionary(db->dictionary)) { - WMMergePLDictionaries(shared_dict, db->dictionary); + WMMergePLDictionaries(shared_dict, db->dictionary, True); WMReleasePropList(db->dictionary); db->dictionary = shared_dict; if (stbuf.st_mtime > db->timestamp) @@ -1087,7 +1087,7 @@ wDefaultsCheckDomains(void *foo) "WindowMaker", WDWindowMaker->path); } else { if (shared_dict) { - WMMergePLDictionaries(shared_dict, dict); + WMMergePLDictionaries(shared_dict, dict, True); WMReleasePropList(dict); dict = shared_dict; shared_dict = NULL; diff --git a/src/dock.c b/src/dock.c index ad08dd6b..42fc2e3d 100644 --- a/src/dock.c +++ b/src/dock.c @@ -237,7 +237,7 @@ toggleLoweredCallback(WMenu *menu, WMenuEntry *entry) static int matchWindow(void *item, void *cdata) { - return (((WFakeGroupLeader*)item)->window == (Window)cdata); + return (((WFakeGroupLeader*)item)->leader == (Window)cdata); } diff --git a/src/event.c b/src/event.c index 8fe05622..5bfec568 100644 --- a/src/event.c +++ b/src/event.c @@ -439,6 +439,13 @@ saveTimestamp(XEvent *event) } +static int +matchWindow(void *item, void *cdata) +{ + return (((WFakeGroupLeader*)item)->origLeader == (Window)cdata); +} + + static void handleExtensions(XEvent *event) { @@ -538,6 +545,8 @@ handleDestroyNotify(XEvent *event) WWindow *wwin; WApplication *app; Window window = event->xdestroywindow.window; + WScreen *scr = wScreenForRootWindow(event->xdestroywindow.event); + int index; #ifdef DEBUG L("got destroy notify"); @@ -547,6 +556,23 @@ handleDestroyNotify(XEvent *event) wUnmanageWindow(wwin, False, True); } + index = WMFindInArray(scr->fakeGroupLeaders, matchWindow, (void*)window); + if (index != WANotFound) { + WFakeGroupLeader *fPtr; + + fPtr = WMGetFromArray(scr->fakeGroupLeaders, index); + if (fPtr->retainCount > 0) { + fPtr->retainCount--; + if (fPtr->retainCount==0 && fPtr->leader!=None) { + XDestroyWindow(dpy, fPtr->leader); + fPtr->leader = None; + XFlush(dpy); + } + } + fPtr->origLeader = None; + } + + app = wApplicationOf(window); if (app) { if (window == app->main_window) { diff --git a/src/wdefaults.c b/src/wdefaults.c index 702e7e1e..477326aa 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -540,7 +540,7 @@ wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file) if ((attr = WMGetFromPLDictionary(dict, key)) != NULL) { if (WMIsPLDictionary(attr)) { if (icon_value!=NULL && !same) - WMMergePLDictionaries(attr, icon_value); + WMMergePLDictionaries(attr, icon_value, False); else WMRemoveFromPLDictionary(attr, AIcon); } diff --git a/src/window.c b/src/window.c index 72a8fc34..8051d95c 100644 --- a/src/window.c +++ b/src/window.c @@ -238,13 +238,13 @@ wWindowDestroy(WWindow *wwin) } } - if (wwin->fake_group) { - if (wwin->fake_group->retainCount > 0) - wwin->fake_group->retainCount--; - if (wwin->fake_group->retainCount==0 && wwin->fake_group->window!=None) { - XDestroyWindow(dpy, wwin->fake_group->window); - wwin->fake_group->window = None; - XFlush(dpy); + if (wwin->fake_group && wwin->fake_group->retainCount>0) { + wwin->fake_group->retainCount--; + if (wwin->fake_group->retainCount==0 && wwin->fake_group->leader!=None) { + XDestroyWindow(dpy, wwin->fake_group->leader); + wwin->fake_group->leader = None; + wwin->fake_group->origLeader = None; + XFlush(dpy); } } @@ -811,27 +811,36 @@ wManageWindow(WScreen *scr, Window window) if (index != WANotFound) { fPtr = WMGetFromArray(scr->fakeGroupLeaders, index); if (fPtr->retainCount == 0) { - fPtr->window = createFakeWindowGroupLeader(scr, wwin->main_window, + fPtr->leader = createFakeWindowGroupLeader(scr, wwin->main_window, instance, class); } fPtr->retainCount++; + if (wwin->main_window!=wwin->client_win && fPtr->origLeader==None) { + fPtr->retainCount++; + fPtr->origLeader = wwin->main_window; + } wwin->fake_group = fPtr; - wwin->group_id = fPtr->window; - wwin->main_window = wwin->group_id; + //wwin->group_id = fPtr->leader; + wwin->main_window = fPtr->leader; wfree(buffer); } else { fPtr = (WFakeGroupLeader*)wmalloc(sizeof(WFakeGroupLeader)); fPtr->identifier = buffer; - fPtr->window = createFakeWindowGroupLeader(scr, wwin->main_window, + fPtr->leader = createFakeWindowGroupLeader(scr, wwin->main_window, instance, class); + fPtr->origLeader = None; fPtr->retainCount = 1; WMAddToArray(scr->fakeGroupLeaders, fPtr); + if (wwin->main_window!=wwin->client_win) { + fPtr->retainCount++; + fPtr->origLeader = wwin->main_window; + } wwin->fake_group = fPtr; - wwin->group_id = fPtr->window; - wwin->main_window = wwin->group_id; + //wwin->group_id = fPtr->leader; + wwin->main_window = fPtr->leader; } if (instance) XFree(instance); diff --git a/src/window.h b/src/window.h index 16a20c03..a35f9b89 100644 --- a/src/window.h +++ b/src/window.h @@ -171,7 +171,8 @@ typedef struct { */ typedef struct WFakeGroupLeader { char *identifier; - Window window; + Window leader; + Window origLeader; int retainCount; } WFakeGroupLeader; diff --git a/util/getstyle.c b/util/getstyle.c index 9f5dcf23..dbe74564 100644 --- a/util/getstyle.c +++ b/util/getstyle.c @@ -597,7 +597,7 @@ main(int argc, char **argv) path = globalDefaultsPathForDomain("WindowMaker"); val = WMReadPropListFromFile(path); if (val) { - WMMergePLDictionaries(val, prop); + WMMergePLDictionaries(val, prop, True); WMReleasePropList(prop); prop = val; } diff --git a/util/seticons.c b/util/seticons.c index 0c5fe952..d0b5e6ae 100644 --- a/util/seticons.c +++ b/util/seticons.c @@ -138,7 +138,7 @@ main(int argc, char **argv) window_attrs = WMGetFromPLDictionary(all_windows, window_name); if (window_attrs) { if (WMIsPLDictionary(window_attrs)) { - WMMergePLDictionaries(window_attrs, icon_value); + WMMergePLDictionaries(window_attrs, icon_value, True); } } else { WMPutInPLDictionary(all_windows, window_name, icon_value); diff --git a/util/setstyle.c b/util/setstyle.c index 09225cbb..946932cc 100644 --- a/util/setstyle.c +++ b/util/setstyle.c @@ -549,7 +549,7 @@ main(int argc, char **argv) } } - WMMergePLDictionaries(prop, style); + WMMergePLDictionaries(prop, style, True); WMWritePropListToFile(prop, path, True); { -- 2.11.4.GIT