1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

- improved behaviour for the shared appicon thing.

- added a 'Bool recursive' flag to WMMergePLDictionaries() in WINGs
This commit is contained in:
dan
2001-12-17 14:46:31 +00:00
parent 672c42cc48
commit 90c77b1a45
17 changed files with 81 additions and 32 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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);

View File

@@ -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)

View File

@@ -1211,17 +1211,26 @@ 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)) {
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;
}

View File

@@ -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];

View File

@@ -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;};
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -238,12 +238,12 @@ wWindowDestroy(WWindow *wwin)
}
}
if (wwin->fake_group) {
if (wwin->fake_group->retainCount > 0)
if (wwin->fake_group && 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;
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);

View File

@@ -171,7 +171,8 @@ typedef struct {
*/
typedef struct WFakeGroupLeader {
char *identifier;
Window window;
Window leader;
Window origLeader;
int retainCount;
} WFakeGroupLeader;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -549,7 +549,7 @@ main(int argc, char **argv)
}
}
WMMergePLDictionaries(prop, style);
WMMergePLDictionaries(prop, style, True);
WMWritePropListToFile(prop, path, True);
{