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

fixed memory leaks and crash with deminiaturization

This commit is contained in:
kojima
2000-03-29 03:58:25 +00:00
parent 03e14f363f
commit 3d7cb106af
5 changed files with 60 additions and 41 deletions

View File

@@ -2751,7 +2751,7 @@ setClearance(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo)
} }
static int static int
setIfDockPresent(WScreen *scr, WDefaultEntry *entry, int *flag, long which) setIfDockPresent(WScreen *scr, WDefaultEntry *entry, char *flag, long which)
{ {
switch (which) { switch (which) {
case WM_DOCK: case WM_DOCK:
@@ -3424,7 +3424,7 @@ setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
static int static int
setMultiByte(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) setMultiByte(WScreen *scr, WDefaultEntry *entry, char *value, void *foo)
{ {
extern _WINGsConfiguration WINGsConfiguration; extern _WINGsConfiguration WINGsConfiguration;

View File

@@ -1535,9 +1535,7 @@ static WAppIcon*
restore_icon_state(WScreen *scr, proplist_t info, int type, int index) restore_icon_state(WScreen *scr, proplist_t info, int type, int index)
{ {
WAppIcon *aicon; WAppIcon *aicon;
char *wclass, *winstance;
proplist_t cmd, value; proplist_t cmd, value;
char *command;
cmd = PLGetDictionaryEntry(info, dCommand); cmd = PLGetDictionaryEntry(info, dCommand);
@@ -1550,37 +1548,44 @@ restore_icon_state(WScreen *scr, proplist_t info, int type, int index)
if (!value) if (!value)
return NULL; return NULL;
ParseWindowName(value, &winstance, &wclass, "dock"); {
char *wclass, *winstance;
char *command;
if (!winstance && !wclass) { ParseWindowName(value, &winstance, &wclass, "dock");
return NULL;
}
/* get commands */ if (!winstance && !wclass) {
return NULL;
}
if (cmd) /* get commands */
command = wstrdup(PLGetString(cmd));
else
command = NULL;
if (!command || strcmp(command, "-")==0) { if (cmd)
if (command) command = wstrdup(PLGetString(cmd));
free(command); else
command = NULL;
if (!command || strcmp(command, "-")==0) {
if (command)
free(command);
if (wclass)
free(wclass);
if (winstance)
free(winstance);
return NULL;
}
aicon = wAppIconCreateForDock(scr, command, winstance, wclass,
TILE_NORMAL);
if (wclass) if (wclass)
free(wclass); free(wclass);
if (winstance) if (winstance)
free(winstance); free(winstance);
if (command)
return NULL; free(command);
} }
aicon = wAppIconCreateForDock(scr, command, winstance, wclass,
TILE_NORMAL);
if (wclass)
free(wclass);
if (winstance)
free(winstance);
aicon->icon->core->descriptor.handle_mousedown = iconMouseDown; aicon->icon->core->descriptor.handle_mousedown = iconMouseDown;
if (type == WM_CLIP) { if (type == WM_CLIP) {
aicon->icon->core->descriptor.handle_enternotify = clipEnterNotify; aicon->icon->core->descriptor.handle_enternotify = clipEnterNotify;

View File

@@ -653,6 +653,7 @@ handleButtonPress(XEvent *event)
} }
#endif /* !LITE */ #endif /* !LITE */
desc = NULL;
if (XFindContext(dpy, event->xbutton.subwindow, wWinContext, if (XFindContext(dpy, event->xbutton.subwindow, wWinContext,
(XPointer *)&desc)==XCNOENT) { (XPointer *)&desc)==XCNOENT) {
if (XFindContext(dpy, event->xbutton.window, wWinContext, if (XFindContext(dpy, event->xbutton.window, wWinContext,
@@ -661,10 +662,6 @@ handleButtonPress(XEvent *event)
} }
} }
if (desc->handle_mousedown!=NULL) {
(*desc->handle_mousedown)(desc, event);
}
if (desc->parent_type == WCLASS_WINDOW) { if (desc->parent_type == WCLASS_WINDOW) {
XSync(dpy, 0); XSync(dpy, 0);
@@ -689,6 +686,10 @@ handleButtonPress(XEvent *event)
} }
} }
if (desc->handle_mousedown!=NULL) {
(*desc->handle_mousedown)(desc, event);
}
/* save double-click information */ /* save double-click information */
if (scr->flags.next_click_is_not_double) { if (scr->flags.next_click_is_not_double) {
scr->flags.next_click_is_not_double = 0; scr->flags.next_click_is_not_double = 0;

View File

@@ -1164,6 +1164,19 @@ keysymToString(KeySym keysym, unsigned int state)
} }
#endif #endif
static char *
appendrealloc(char *a, char *b)
{
if (a == NULL)
return wstrdup(b);
else {
char *c = wstrappend(a, b);
free(a);
return c;
}
}
char* char*
GetShortcutString(char *text) GetShortcutString(char *text)
{ {
@@ -1189,33 +1202,33 @@ GetShortcutString(char *text)
modmask |= mod; modmask |= mod;
if (strcasecmp(text, "Meta")==0) { if (strcasecmp(text, "Meta")==0) {
buffer = wstrappend(buffer, "M+"); buffer = appendrealloc(buffer, "M+");
} else if (strcasecmp(text, "Alt")==0) { } else if (strcasecmp(text, "Alt")==0) {
buffer = wstrappend(buffer, "A+"); buffer = appendrealloc(buffer, "A+");
} else if (strcasecmp(text, "Shift")==0) { } else if (strcasecmp(text, "Shift")==0) {
buffer = wstrappend(buffer, "Sh+"); buffer = appendrealloc(buffer, "Sh+");
} else if (strcasecmp(text, "Mod1")==0) { } else if (strcasecmp(text, "Mod1")==0) {
buffer = wstrappend(buffer, "M1+"); buffer = appendrealloc(buffer, "M1+");
} else if (strcasecmp(text, "Mod2")==0) { } else if (strcasecmp(text, "Mod2")==0) {
buffer = wstrappend(buffer, "M2+"); buffer = appendrealloc(buffer, "M2+");
} else if (strcasecmp(text, "Mod3")==0) { } else if (strcasecmp(text, "Mod3")==0) {
buffer = wstrappend(buffer, "M3+"); buffer = appendrealloc(buffer, "M3+");
} else if (strcasecmp(text, "Mod4")==0) { } else if (strcasecmp(text, "Mod4")==0) {
buffer = wstrappend(buffer, "M4+"); buffer = appendrealloc(buffer, "M4+");
} else if (strcasecmp(text, "Mod5")==0) { } else if (strcasecmp(text, "Mod5")==0) {
buffer = wstrappend(buffer, "M5+"); buffer = appendrealloc(buffer, "M5+");
} else if (strcasecmp(text, "Control")==0) { } else if (strcasecmp(text, "Control")==0) {
control = 1; control = 1;
} else { } else {
buffer = wstrappend(buffer, text); buffer = appendrealloc(buffer, text);
} }
text = k+1; text = k+1;
} }
if (control) { if (control) {
buffer = wstrappend(buffer, "^"); buffer = appendrealloc(buffer, "^");
} }
buffer = wstrappend(buffer, text); buffer = appendrealloc(buffer, text);
/* get key */ /* get key */
/* ksym = XStringToKeysym(text); /* ksym = XStringToKeysym(text);

View File

@@ -256,7 +256,7 @@ x_reset_modifier_mapping (Display *display)
" by the keysyms used to control those bits. Mod1 does NOT always\n" " by the keysyms used to control those bits. Mod1 does NOT always\n"
" mean Meta, although some non-ICCCM-compliant programs assume that.\n"); " mean Meta, although some non-ICCCM-compliant programs assume that.\n");
#endif #endif
XFree(x_modifier_keymap); XFreeModifiermap(x_modifier_keymap);
} }