>From ade4a2246b8c6f76df2c9c5a4799c356b29d0b94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sat, 6 Oct 2012 15:15:51 +0200
Subject: [PATCH] New function remove_wwindowstate
The common code in the functions wWindowDeleteSavedState and
wWindowDeleteSavedStatesForPID is moved to a new function remove_wwindowstate.
---
src/window.c | 54 ++++++++++++++++++++++--------------------------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/src/window.c b/src/window.c
index 12f276a..3d12c50 100644
--- a/src/window.c
+++ b/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)
--
1.7.10.4
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From ade4a2246b8c6f76df2c9c5a4799c356b29d0b94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sat, 6 Oct 2012 15:15:51 +0200
Subject: [PATCH] New function remove_wwindowstate
The common code in the functions wWindowDeleteSavedState and
wWindowDeleteSavedStatesForPID is moved to a new function remove_wwindowstate.
---
src/window.c | 54 ++++++++++++++++++++++--------------------------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/src/window.c b/src/window.c
index 12f276a..3d12c50 100644
--- a/src/window.c
+++ b/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)
--
1.7.10.4