mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
New helper function remove_wwindowstate()
The common code in the functions wWindowDeleteSavedState and wWindowDeleteSavedStatesForPID is moved to a new function remove_wwindowstate.
This commit is contained in:
committed by
Carlos R. Mafra
parent
727b25d947
commit
41af9ca07f
54
src/window.c
54
src/window.c
@@ -109,6 +109,8 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event);
|
||||
static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event);
|
||||
static void resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event);
|
||||
|
||||
static void remove_wwindowstate(WWindowState *wstate);
|
||||
|
||||
/****** Notification Observers ******/
|
||||
|
||||
static void appearanceObserver(void *self, WMNotification * notif)
|
||||
@@ -2600,26 +2602,12 @@ void wWindowDeleteSavedState(WMagicNumber id)
|
||||
tmp = windowState;
|
||||
if (tmp == wstate) {
|
||||
windowState = wstate->next;
|
||||
if (wstate->instance)
|
||||
wfree(wstate->instance);
|
||||
if (wstate->class)
|
||||
wfree(wstate->class);
|
||||
if (wstate->command)
|
||||
wfree(wstate->command);
|
||||
wfree(wstate->state);
|
||||
wfree(wstate);
|
||||
remove_wwindowstate(wstate);
|
||||
} else {
|
||||
while (tmp->next) {
|
||||
if (tmp->next == wstate) {
|
||||
tmp->next = wstate->next;
|
||||
if (wstate->instance)
|
||||
wfree(wstate->instance);
|
||||
if (wstate->class)
|
||||
wfree(wstate->class);
|
||||
if (wstate->command)
|
||||
wfree(wstate->command);
|
||||
wfree(wstate->state);
|
||||
wfree(wstate);
|
||||
remove_wwindowstate(wstate);
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
@@ -2638,27 +2626,14 @@ void wWindowDeleteSavedStatesForPID(pid_t pid)
|
||||
if (tmp->pid == pid) {
|
||||
wstate = windowState;
|
||||
windowState = tmp->next;
|
||||
if (wstate->instance)
|
||||
wfree(wstate->instance);
|
||||
if (wstate->class)
|
||||
wfree(wstate->class);
|
||||
if (wstate->command)
|
||||
wfree(wstate->command);
|
||||
wfree(wstate->state);
|
||||
wfree(wstate);
|
||||
|
||||
remove_wwindowstate(wstate);
|
||||
} else {
|
||||
while (tmp->next) {
|
||||
if (tmp->next->pid == pid) {
|
||||
wstate = tmp->next;
|
||||
tmp->next = wstate->next;
|
||||
if (wstate->instance)
|
||||
wfree(wstate->instance);
|
||||
if (wstate->class)
|
||||
wfree(wstate->class);
|
||||
if (wstate->command)
|
||||
wfree(wstate->command);
|
||||
wfree(wstate->state);
|
||||
wfree(wstate);
|
||||
remove_wwindowstate(wstate);
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
@@ -2666,6 +2641,21 @@ void wWindowDeleteSavedStatesForPID(pid_t pid)
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_wwindowstate(WWindowState *wstate)
|
||||
{
|
||||
if (wstate->instance)
|
||||
wfree(wstate->instance);
|
||||
|
||||
if (wstate->class)
|
||||
wfree(wstate->class);
|
||||
|
||||
if (wstate->command)
|
||||
wfree(wstate->command);
|
||||
|
||||
wfree(wstate->state);
|
||||
wfree(wstate);
|
||||
}
|
||||
|
||||
void wWindowSetOmnipresent(WWindow *wwin, Bool flag)
|
||||
{
|
||||
if (wwin->flags.omnipresent == flag)
|
||||
|
||||
Reference in New Issue
Block a user