summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-22 23:24:05 +1000
committerChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-22 23:24:05 +1000
commit8b5c6fa72e80c5705f5c5fe96538009e0b751ce2 (patch)
tree5de2192a36bc701883e39b6bf80aeea9cf9f94d2
parent575ae46a57cfc753480c686419003cfe63867444 (diff)
downloadradial-switcher-8b5c6fa72e80c5705f5c5fe96538009e0b751ce2.tar.gz
radial-switcher-8b5c6fa72e80c5705f5c5fe96538009e0b751ce2.tar.bz2
WindowTreeNode -> WindowTree.
Add WindowTree and WindowList destructors
-rw-r--r--radial-switcher.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/radial-switcher.c b/radial-switcher.c
index 70ef348..ca8289b 100644
--- a/radial-switcher.c
+++ b/radial-switcher.c
@@ -49,11 +49,11 @@ typedef struct _WindowList {
CompWindow **w;
} WindowList;
-typedef struct _WindowTreeNode {
+typedef struct _WindowTree {
WindowList *windows;
int childrenSize;
- struct _WindowTreeNode **children;
-} WindowTreeNode;
+ struct _WindowTree **children;
+} WindowTree;
typedef struct _RadialCairoContext
{
@@ -83,6 +83,15 @@ newWindowList (void)
}
/**
+ * WindowList destructor
+**/
+static void
+destroyWindowList (WindowList *l)
+{
+ free (l->w);
+}
+
+/**
* Add a window to the window list, reallocing if necessary
* @param l: @WindowList to add the window to.
* @param w: @CompWindow to add to the list
@@ -110,20 +119,30 @@ addWindowToList (WindowList *l,
/**
* WindowTree constructor
**/
-static WindowTreeNode *
-newWindowTreeNode (void)
+static WindowTree *
+newWindowTree (void)
{
- WindowTreeNode *ret;
- ret = malloc (sizeof(WindowTreeNode));
+ WindowTree *ret;
+ ret = malloc (sizeof(WindowTree));
ret->windows = newWindowList();
ret->childrenSize = 4;
- ret->children = malloc (sizeof (WindowTreeNode *) * 4);
+ ret->children = malloc (sizeof (WindowTree *) * 4);
return ret;
}
/**
+ * WindowTree destructor
+**/
+static void
+destroyWindowTree (WindowTree *node)
+{
+ destroyWindowList (node->windows);
+ free (node->children);
+}
+
+/**
* Add a window to the window tree
- * @param node: The @WindowTreeNode to add the window to
+ * @param node: The @WindowTree to add the window to
* @param w: The window to add to the tree
* @param isSameGroup: Comparison function to determine whether w should be
* a child of an existing window.
@@ -131,7 +150,7 @@ newWindowTreeNode (void)
* @return: True on success
**/
static Bool
-addWindowToTree (WindowTreeNode *node,
+addWindowToTree (WindowTree *node,
CompWindow *w,
WindowCmpProc isSameGroup)
{
@@ -140,13 +159,13 @@ addWindowToTree (WindowTreeNode *node,
if (isSameGroup (node->windows->w[i], w))
{
if (!node->children[i])
- node->children[i] = newWindowTreeNode();
+ node->children[i] = newWindowTree();
return addWindowToTree (node->children[i], w, isSameGroup);
}
}
if (node->childrenSize <= node->windows->nWindows)
node->children = realloc (node->children,
- sizeof(WindowTreeNode *) * \
+ sizeof(WindowTree *) * \
(node->childrenSize + 32));
if (!node->children)
return FALSE;
@@ -165,14 +184,13 @@ addWindowToTree (WindowTreeNode *node,
* @return: The root node of the tree. The caller is responsible for freeing
* the tree once it is no longer needed.
**/
-static WindowTreeNode *
+static WindowTree *
createWindowTree (WindowList *windows,
WindowCmpProc isSameGroup)
{
- CompWindow *w;
- WindowTreeNode *root;
+ WindowTree *root;
- root = newWindowTreeNode();
+ root = newWindowTree();
/* XXX: Most naieve possible algorithm! */
for (int i = 0; i < windows->nWindows; ++i)
{